extern SOAP_NMAC struct Namespace jp__namespaces[];
-static const char *get_opt_string = "dq:c:k:C:V:nm:p:i:o:x:s:Df:";
+static const char *get_opt_string = "dq:c:k:C:V:nm:p:i:o:x:s:Df:F";
static struct option opts[] = {
{"debug", 0, NULL, 'd'},
{"slaves", 1, NULL, 's'},
{"delete-db", 0, NULL, 'D'},
{"feeding", 1, NULL, 'f'},
+ {"force-feed", 0, NULL, 'F'},
{NULL, 0, NULL, 0}
};
"\t-s, --slaves\t number of slaves for responses\n"
"\t-D, --delete-db\t delete and restore data in the database\n"
"\t-f, --feeding\t feed index server from local file\n"
+ "\t-F, --force-feed\t force reloading feeds from the config file\n"
"\n"
,me);
}
case 's': conf->slaves = atoi(optarg); if (conf->slaves > 0) break;
case 'D': conf->delete_db = 1; break;
case 'f': conf->feeding = optarg; break;
+ case 'F': conf->force_feed = 1; break;
default : usage(argv[0]); exit(0); break;
}
char **attrs, *attrid, *num;
const char *type_index, *type_full;
size_t i;
- int indexed, state, locked, nattrs;
- size_t conds_len;
+ int indexed, nattrs;
char sql[2048];
- glite_jp_is_feed **feeds;
- void *conds;
glite_jp_context_t jpctx = ctx->jpctx;
glite_lbu_Statement stmt = NULL;
}
glite_jp_db_FreeStmt(&stmt);
+ // create jobs table
+ snprintf(sql, sizeof(sql) - 1, SQLCMD_CREATE_JOBS_TABLE_BEGIN);
+ if (ctx->conf->attrs) for (i = 0; ctx->conf->attrs[i]; i++)
+ if (is_singleval(ctx->conf, ctx->conf->attrs[i])
+ && is_queriable(ctx->conf, ctx->conf->attrs[i])){
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql),
+ " `attr_%s` %s NOT NULL,\n",
+ glite_jp_indexdb_attr2id(ctx->conf->attrs[i]),
+ glite_jp_attrval_db_type_index(jpctx, ctx->conf->attrs[i], INDEX_LENGTH));
+
+ if (is_indexed(ctx->conf, ctx->conf->attrs[i]))
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql),
+ " index (attr_%s), \n",
+ glite_jp_indexdb_attr2id(ctx->conf->attrs[i]));
+ }
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), SQLCMD_CREATE_JOBS_TABLE_END);
+ llprintf(LOG_SQL, "sql=%s\n", sql);
+ if ((glite_jp_db_ExecSQL(jpctx, sql, NULL)) == -1) {
+ glite_jpis_stack_error(ctx->jpctx, EAGAIN, "Cannot create table 'jobs'!");
+ goto fail;
+ }
+
+ return 0;
+
+fail:
+ glite_jp_db_FreeStmt(&stmt);
+ if (!jpctx->error) glite_jpis_stack_error(ctx->jpctx, EIO, "error during initial filling of the database");
+ return jpctx->error->code;
+}
+
+
+int glite_jpis_initDatabaseFeeds(glite_jpis_context_t ctx) {
+ glite_jp_context_t jpctx = ctx->jpctx;
+ glite_lbu_Statement stmt = NULL;
+ glite_jp_is_feed **feeds;
+ size_t i;
+ size_t conds_len;
+ void *conds;
+ int state, locked;
+
+ if (glite_jp_db_ExecSQL(jpctx, "DELETE FROM feeds", NULL) == -1) {
+ glite_jpis_stack_error(ctx->jpctx, EIO, "can't delete feeds");
+ goto fail;
+ }
+
// feeds table
if (glite_jp_db_PrepareStmt(jpctx, "INSERT INTO feeds (`state`, `locked`, `source`, `condition`) VALUES (?, ?, ?, ?)", &stmt) != 0) {
glite_jpis_stack_error(ctx->jpctx, EIO, "can't create insert feeds statement");
GLITE_LBU_DB_TYPE_MEDIUMBLOB, conds, conds_len) == -1)
goto fail_conds;
free(conds);
+ conds = NULL;
feeds[i]->uniqueid = glite_lbu_Lastid(stmt);
i++;
}
glite_jp_db_FreeStmt(&stmt);
-
- // create jobs table
- snprintf(sql, sizeof(sql) - 1, SQLCMD_CREATE_JOBS_TABLE_BEGIN);
- if (ctx->conf->attrs) for (i = 0; ctx->conf->attrs[i]; i++)
- if (is_singleval(ctx->conf, ctx->conf->attrs[i])
- && is_queriable(ctx->conf, ctx->conf->attrs[i])){
- snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql),
- " `attr_%s` %s NOT NULL,\n",
- glite_jp_indexdb_attr2id(ctx->conf->attrs[i]),
- glite_jp_attrval_db_type_index(jpctx, ctx->conf->attrs[i], INDEX_LENGTH));
-
- if (is_indexed(ctx->conf, ctx->conf->attrs[i]))
- snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql),
- " index (attr_%s), \n",
- glite_jp_indexdb_attr2id(ctx->conf->attrs[i]));
- }
- snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), SQLCMD_CREATE_JOBS_TABLE_END);
- llprintf(LOG_SQL, "sql=%s\n", sql);
- if ((glite_jp_db_ExecSQL(jpctx, sql, NULL)) == -1) {
- glite_jpis_stack_error(ctx->jpctx, EAGAIN, "Cannot create table 'jobs'!");
- goto fail;
- }
-
return 0;
fail_conds: