[ -z "$GLITE_LB_EXPORT_JPREG_MAILDIR" ] && GLITE_LB_EXPORT_JPREG_MAILDIR=$GLITE_LOCATION_VAR/jpreg
jpreg_maildir="--reg-mdir $GLITE_LB_EXPORT_JPREG_MAILDIR "
- [ -d "$GLITE_LB_EXPORT_JPREG_MAILDIR" ] || mkdir "$GLITE_LB_EXPORT_JPREG_MAILDIR" && chown $GLITE_USER:$GLITE_GROUP "$GLITE_LB_EXPORT_JPREG_MAILDIR"
+ [ -d "$GLITE_LB_EXPORT_JPREG_MAILDIR" ] || mkdir -p "$GLITE_LB_EXPORT_JPREG_MAILDIR" && chown $GLITE_USER:$GLITE_GROUP "$GLITE_LB_EXPORT_JPREG_MAILDIR"
[ -z "$GLITE_LB_EXPORT_JPDUMP_MAILDIR" ] && GLITE_LB_EXPORT_JPDUMP_MAILDIR=$GLITE_LOCATION_VAR/jpdump
jpdump_maildir="--dump-mdir $GLITE_LB_EXPORT_JPDUMP_MAILDIR "
- [ -d "$GLITE_LB_EXPORT_JPDUMP_MAILDIR" ] || mkdir "$GLITE_LB_EXPORT_JPDUMP_MAILDIR" && chown $GLITE_USER:$GLITE_GROUP "$GLITE_LB_EXPORT_JPDUMP_MAILDIR"
+ [ -d "$GLITE_LB_EXPORT_JPDUMP_MAILDIR" ] || mkdir -p "$GLITE_LB_EXPORT_JPDUMP_MAILDIR" && chown $GLITE_USER:$GLITE_GROUP "$GLITE_LB_EXPORT_JPDUMP_MAILDIR"
[ -n "$GLITE_LB_EXPORT_JPPS" ] && jpps="--jpps $GLITE_LB_EXPORT_JPPS "
[ -n "$GLITE_LB_EXPORT_SANDBOX_MAILDIR" ] && sandbox_maildir="--sandbox-mdir $GLITE_LB_EXPORT_SANDBOX_MAILDIR "
dprintf("[%s] dump JP import request received\n", name);
if ( !debug ) syslog(LOG_INFO, "dump JP import request received");
+ soap_begin(soap);
+
ret = 0;
if ( parse_msg(msg, tab) < 0 ) {
dprintf("[%s] Wrong format of message!\n", name);
}
if (perf.name && !perf.limit) stats_get_limit(&perf, name);
}
- soap_begin(soap)
if (!(sink & 2)) {
#endif
retry_upload = 2;
GLOBUSINC:= -I${globus_prefix}/include/${nothrflavour}
GLOBUSINCTHR:= -I${globus_prefix}/include/${thrflavour}
-DEBUG:=-g -O0
-CFLAGS:=${DEBUG} -I. -I${top_srcdir}/interface -I${stagedir}/include
+DEBUG:=-g -O0 -W -Wno-sign-compare
+CFLAGS:=${DEBUG} -D_GNU_SOURCE -I. -I${top_srcdir}/interface -I${stagedir}/include
offset=0
version_info:=-version-info ${shell \
INSTALL:=libtool --mode=install install
COMPILE:=libtool --mode=compile ${CC} ${CFLAGS}
-HDRS:=types.h context.h attr.h known_attr.h backend.h builtin_plugins.h file_plugin.h
+HDRS:=types.h context.h attr.h known_attr.h backend.h builtin_plugins.h file_plugin.h indexdb.h
-SRCS:=context.c attr.c utils.c
+SRCS:=context.c attr.c utils.c indexdb.c
OBJS:=${SRCS:.c=.lo}
THROBJS:=${OBJS:.o=.thr.lo}
-LIBS:=-L${globus_prefix}/lib -lcrypto_${nothrflavour} -L${stagedir}/lib -lglite_jobid
+LIBS:=-L${globus_prefix}/lib -lcrypto_${nothrflavour} -L${stagedir}/lib -lglite_jobid -lglite_lbu_db
THRLIBS:=-L${globus_prefix}/lib -lcrypto_${thrflavour}
commonlib:= libglite_jp_common_${nothrflavour}.la
--- /dev/null
+#ifndef GLITE_JP_INDEXDB_H
+#define GLITE_JP_INDEXDB_H
+
+/**
+ * \file indexdb.h
+ * \brief Helper functions for accessing Job Provenance Index Server database.
+ */
+
+#include "glite/lbu/db.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#ifdef GLITE_JP_INDEX_COMPILE
+
+/**
+ * For generating table names.
+ */
+#define GLITE_JP_INDEXDB_TABLE_ATTR_PREFIX "attr_"
+
+#endif
+
+
+/**
+ * Returns internal id from attribute name.
+ *
+ * The attribute id is used in some places in the database schema. Because of the future possible changes in the schema, you should rather use other functions to get SQL commands (table names and where conditions).
+ *
+ * \param[in] name attribute name
+ * \return attribute id string
+ */
+char *glite_jp_indexdb_attr2id(const char *name);
+
+/**
+ * Get parts of the SQL SELECT command to the given attribute:
+ *
+ * SELECT column, full_value_column FROM table WHERE where;
+ *
+ * This is quick version requiring additional information about indexing of the attribute.
+ */
+int glite_jp_indexdb_attr2select_from_index(const char *name, int indexed, char **column, char **full_value_column, char **table, char **where);
+
+/**
+ * Get parts of the SQL SELECT command to the given attribute:
+ *
+ * SELECT column, full_value_column FROM table WHERE where;
+ *
+ * This is the most portable way - it will peep to the DB for information about indexing.
+ */
+int glite_jp_indexdb_attr2select_from_db(const char *name, glite_lbu_DBContext dbctx, char **column, char **full_value_column, char **table, char **where);
+
+#ifdef __cplusplus
+};
+#endif
+
+
+#endif /* GLITE_JP_INDEXDB_H */
#include "types.h"
#include "attr.h"
#include "type_plugin.h"
+#include "context.h"
void glite_jp_attrval_free(glite_jp_attrval_t *a,int f)
{
dst->timestamp = src->timestamp;
dst->origin_detail = src->origin_detail ?
strdup(src->origin_detail) : NULL;
- if (dst->binary = src->binary) {
+ if ((dst->binary = src->binary)) {
dst->value = malloc(src->size);
memcpy(dst->value,src->value,src->size);
}
#include <string.h>
#include <stdlib.h>
+#include <stdio.h>
#include "types.h"
#include "context.h"
ret = realloc(ret,len + add + 1);
strncpy(ret + len,buf,add); ret[len += add] = 0;
strcat(indent," ");
- } while (ep = ep->reason);
+ } while ((ep = ep->reason));
return ret;
}
glite_jp_clear_error(ctx);
for (cnt=0;ctx->deferred_func[cnt];cnt++);
for (i=0; i<cnt; i++) {
- if (ret = (*ctx->deferred_func)(ctx,*ctx->deferred_arg)) {
+ if ((ret = (*ctx->deferred_func)(ctx,*ctx->deferred_arg))) {
glite_jp_error_t err;
char desc[100];
--- /dev/null
+#ident "$Header:"
+
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#include <glite/jobid/strmd5.h>
+#include <glite/lbu/db.h>
+#include <glite/lbu/trio.h>
+
+#define GLITE_JP_INDEX_COMPILE 1
+
+#include "indexdb.h"
+
+char *glite_jp_indexdb_attr2id(const char *name) {
+ size_t i, len;
+ char *lname, *id;
+
+ len = strlen(name);
+ lname = malloc(len + 1);
+ for (i = 0; i < len + 1; i++) lname[i] = tolower(name[i]);
+ id = str2md5(lname);
+ free(lname);
+
+ return id;
+}
+
+
+int glite_jp_indexdb_attr2select_from_index(const char *name, int indexed __attribute__((unused)), char **column, char **full_value_column, char **table, char **where) {
+ char *id;
+
+ if (column) *column = strdup("value");
+ if (full_value_column) *full_value_column = strdup("full_value");
+ if (table) {
+ id = glite_jp_indexdb_attr2id(name);
+ asprintf(table, GLITE_JP_INDEXDB_TABLE_ATTR_PREFIX "%s", id);
+ free(id);
+ }
+ if (where) *where = strdup("");
+
+ return 0;
+}
+
+
+int glite_jp_indexdb_attr2select_from_db(const char *name, glite_lbu_DBContext dbctx, char **column, char **full_value_column, char **table, char **where) {
+ char *sql, *id;
+ glite_lbu_Statement stmt;
+ int ret;
+
+ if (table) {
+ trio_asprintf(&sql, "SELECT attrid FROM attrs WHERE name='%|Ss'", name);
+ ret = glite_lbu_ExecSQL(dbctx, sql, &stmt);
+ free(sql);
+ switch (ret) {
+ case -1: return glite_lbu_DBError(dbctx, NULL, NULL);
+ case 1: break;
+ default: return EINVAL;
+ }
+ if (glite_lbu_FetchRow(stmt, 1, NULL, &id) < 0) return glite_lbu_DBError(dbctx, NULL, NULL);
+ asprintf(table, GLITE_JP_INDEXDB_TABLE_ATTR_PREFIX "%s", id);
+ free(id);
+ glite_lbu_FreeStmt(&stmt);
+ }
+ if (column) *column = strdup("value");
+ if (full_value_column) *full_value_column = strdup("full_value");
+ if (where) *where = strdup("");
+
+ return 0;
+}
unique (cert_subj)
) engine=innodb;
-
-# data tables - created one for each configured attribute, index on
-# value is created only for attributes configured to be indexed
+# data tables - created one for each configured and indexed attribute,
+# in future values of the non-indexed attributes will be stored in attr_values
#
#create table attr_<attrid> (
# `jobid` char(32) binary not null,
# index (value)
#) engine=innodb;
+
+# ---- future schema improvements ----
+
+#create table attr_values (
+# `jobid` char(32),
+# `attrid` char(32) binary not null,
+# `value` varchar(255) binary not null,
+# `full_value` mediumblob not null,
+# `origin` int not null,
+## `is_multival` int,
+#
+## primary key (jobid, attrid)
+# index (jobid),
+# index (attrid),
+# index (value)
+#) engine=innodb;
+
+#create table attr_multivalues (
+# `jobid` char(32),
+# `attrid` char(32) binary not null,
+# `value` varchar(255) binary not null,
+# `full_value` mediumblob not null,
+# `origin` int not null,
+#
+# index (jobid),
+# index (attrid)
+# index (value)
+#) engine=innodb;
#include <ctype.h>
#include <string.h>
+#define GLITE_JP_INDEX_COMPILE 1
+
#include <glite/lbu/trio.h>
#include <glite/jobid/strmd5.h>
#include <glite/jobid/cjobid.h>
#include <glite/jp/db.h>
#include <glite/jp/attr.h>
#include "glite/jp/known_attr.h"
+#include "glite/jp/indexdb.h"
#include "conf.h"
#include "context.h"
#define LOG_SQL 1
#endif
-#define TABLE_PREFIX_DATA "attr_"
-#define SQLCMD_DROP_DATA_TABLE "DROP TABLE " TABLE_PREFIX_DATA "%s"
-#define SQLCMD_CREATE_DATA_TABLE "CREATE TABLE " TABLE_PREFIX_DATA "%s (\n\
+#define SQLCMD_DROP_DATA_TABLE "DROP TABLE " GLITE_JP_INDEXDB_TABLE_ATTR_PREFIX "%s"
+#define SQLCMD_CREATE_DATA_TABLE "CREATE TABLE " GLITE_JP_INDEXDB_TABLE_ATTR_PREFIX "%s (\n\
`jobid` CHAR(32) BINARY NOT NULL,\n\
`value` %s BINARY NOT NULL,\n\
`full_value` %s NOT NULL,\n\
INDEX (jobid),\n\
INDEX (value)\n\
) ENGINE=innodb;"
-#define SQLCMD_INSERT_ATTRVAL "INSERT INTO " TABLE_PREFIX_DATA "%|Ss (jobid, value, full_value, origin) VALUES (\n\
+#define SQLCMD_INSERT_ATTRVAL "INSERT INTO " GLITE_JP_INDEXDB_TABLE_ATTR_PREFIX "%|Ss (jobid, value, full_value, origin) VALUES (\n\
'%|Ss',\n\
'%|Ss',\n\
'%|Ss',\n\
}
-/**
- * Convert attribute name to attribute id.
- */
-char *glite_jpis_attr_name2id(const char *name) {
- size_t i, len;
- char *lname, *id;
-
- len = strlen(name);
- lname = malloc(len + 1);
- for (i = 0; i < len + 1; i++) lname[i] = tolower(name[i]);
- id = str2md5(lname);
- free(lname);
-
- return id;
-// return str2md5(name);
-}
-
-
/* Init the database.
*
* \retval 0 OK
type_full = glite_jp_attrval_db_type_full(jpctx, attrs[i]);
type_index = glite_jp_attrval_db_type_index(jpctx, attrs[i], INDEX_LENGTH);
- attrid = glite_jpis_attr_name2id(attrs[i]);
+ attrid = glite_jp_indexdb_attr2id(attrs[i]);
indexed = is_indexed(ctx->conf, attrs[i]);
if (glite_jp_db_ExecPreparedStmt(jpctx, stmt, 4,
GLITE_LBU_DB_TYPE_VARCHAR, attrid,
while ((ret = glite_jp_db_FetchRow(jpctx, stmt_tabs, 1, &len, &attrid)) > 0) {
snprintf(sql, sizeof(sql), SQLCMD_DROP_DATA_TABLE, attrid);
llprintf(LOG_SQL, "dropping '%s' ==> '%s'\n", attrid, sql);
- if (glite_jp_db_ExecSQL(jpctx, sql, NULL) == -1) printf("warning: can't drop table '" TABLE_PREFIX_DATA "%s': %s (%s)\n", attrid, jpctx->error->desc, jpctx->error->source);
+ if (glite_jp_db_ExecSQL(jpctx, sql, NULL) == -1) printf("warning: can't drop table '" GLITE_JP_INDEXDB_TABLE_ATTR_PREFIX "%s': %s (%s)\n", attrid, jpctx->error->desc, jpctx->error->source);
}
if (ret != 0) goto fail;
glite_jp_db_FreeStmt(&stmt_tabs);
char *sql, *table, *value, *full_value, *md5_jobid;
long int origin;
- table = glite_jpis_attr_name2id(av->name);
+ table = glite_jp_indexdb_attr2id(av->name);
value = glite_jp_attrval_to_db_index(ctx->jpctx, av, INDEX_LENGTH);
full_value = glite_jp_attrval_to_db_full(ctx->jpctx, av);
md5_jobid = str2md5(jobid);
#include "glite/jp/context.h"
#include "glite/jp/attr.h"
#include "glite/jp/known_attr.h"
+#include "glite/jp/indexdb.h"
#include "jp_H.h"
#include "soap_version.h"
attr_md5 = NULL;
qa = strdup("");
} else {
- attr_md5 = glite_jpis_attr_name2id(condition->attr);
+ attr_md5 = glite_jp_indexdb_attr2id(condition->attr);
add_attr_table(attr_md5, &attr_tables);
/* origin */
memset(&jav,0,sizeof(jav));
jobid_md5 = str2md5(jobid);
- attr_md5 = glite_jpis_attr_name2id(attr_name);
+ attr_md5 = glite_jp_indexdb_attr2id(attr_name);
trio_asprintf(&query,"SELECT full_value FROM attr_%|Ss WHERE jobid = \"%s\"",
attr_md5, jobid_md5);
free(attr_md5);