From: František Dvořák Date: Wed, 18 Apr 2007 11:56:30 +0000 (+0000) Subject: improved and added some log messages, print more WS errors X-Git-Tag: glite-yaim-myproxy_R_3_1_1_2~3 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=6a87cf4e144a4bb499ab2cd926edb74d05d21ee4;p=jra1mw.git improved and added some log messages, print more WS errors dropping attributes tables just before creating (nifty when deleted attrs table) fixed ugly bug in updateJobs (forgotten fetch) --- diff --git a/org.glite.jp.index/src/conf.c b/org.glite.jp.index/src/conf.c index c378d75..0600bdb 100644 --- a/org.glite.jp.index/src/conf.c +++ b/org.glite.jp.index/src/conf.c @@ -2,6 +2,7 @@ #ident "$Header$" +#include #include #include #include @@ -149,7 +150,7 @@ void glite_jp_free_conf(glite_jp_is_conf *conf) void glite_jp_lprintf(const char *source, const char *fmt, ...) { va_list ap; - printf("%s: ", source); + printf("[%d] %s: ", getpid(), source); va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); diff --git a/org.glite.jp.index/src/db_ops.c b/org.glite.jp.index/src/db_ops.c index 988b7e8..e6bc5b8 100644 --- a/org.glite.jp.index/src/db_ops.c +++ b/org.glite.jp.index/src/db_ops.c @@ -315,6 +315,13 @@ int glite_jpis_initDatabase(glite_jpis_context_t ctx) { // insert if (glite_jp_db_execute(stmt) == -1) goto fail; + // silently drop + sql[sizeof(sql) - 1] = '\0'; + snprintf(sql, sizeof(sql), SQLCMD_DROP_DATA_TABLE, attrid); + llprintf(LOG_SQL, "preventive dropping '%s' ==> '%s'\n", attrid, sql); + glite_jp_db_execstmt(jpctx, sql, NULL); + + // create table sql[sizeof(sql) - 1] = '\0'; snprintf(sql, sizeof(sql) - 1, SQLCMD_CREATE_DATA_TABLE, attrid, type_index, type_full); llprintf(LOG_SQL, "creating table: '%s'\n", sql); @@ -426,7 +433,7 @@ int glite_jpis_init_db(glite_jpis_context_t isctx) { glite_jp_db_create_results(&myres, 2, GLITE_JP_DB_TYPE_INT, NULL, &(isctx->param_uniqueid), GLITE_JP_DB_TYPE_VARCHAR, NULL, isctx->param_ps, sizeof(isctx->param_ps), &isctx->param_ps_len); - if ((ret = glite_jp_db_prepare(jpctx, "SELECT uniqueid, source FROM feeds WHERE (locked=0) AND (feedid IS NULL) AND ((state <> " GLITE_JP_IS_STATE_ERROR_STR ") OR (expires <= ?))", &isctx->select_unlocked_feed_stmt, myparam, myres)) != 0) goto fail; + if ((ret = glite_jp_db_prepare(jpctx, "SELECT uniqueid, source FROM feeds WHERE (locked=0) AND (feedid IS NULL) AND ((state < " GLITE_JP_IS_STATE_ERROR_STR ") OR (expires <= ?))", &isctx->select_unlocked_feed_stmt, myparam, myres)) != 0) goto fail; // sql command: lock the feed (via uniqueid) glite_jp_db_create_params(&myparam, 1, GLITE_JP_DB_TYPE_INT, &isctx->param_uniqueid); diff --git a/org.glite.jp.index/src/soap_ops.c b/org.glite.jp.index/src/soap_ops.c index 7282e47..450eb91 100644 --- a/org.glite.jp.index/src/soap_ops.c +++ b/org.glite.jp.index/src/soap_ops.c @@ -26,9 +26,7 @@ /* Helper functions */ /*------------------*/ -#define dprintf(FMT, ARGS, ...) #include "glite/jp/ws_fault.c" -#define err2fault(CTX, SOAP) glite_jp_server_err2fault((CTX), (SOAP)) @@ -79,6 +77,8 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__UpdateJobs( // get info about the feed feedid = jpelem__UpdateJobs->feedId; + lprintf("feedid='%s'\n", feedid); + GLITE_JPIS_PARAM(ctx->param_feedid, ctx->param_feedid_len, feedid); if ((ret = glite_jp_db_execute(ctx->select_info_feed_stmt)) != 1) { fprintf(stderr, "can't get info about feed '%s', returned %d records", feedid, ret); @@ -86,7 +86,15 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__UpdateJobs( else fprintf(stderr, "\n"); goto fail; } + if (glite_jp_db_fetch(ctx->select_info_feed_stmt) != 0) { + fprintf(stderr, "can't fetch feed '%s'", feedid); + if (jpctx->error) fprintf(stderr, ": %s (%s)\n", jpctx->error->desc, jpctx->error->source); + else fprintf(stderr, "\n"); + goto fail; + } + lprintf("uniqueid=%ld, state=%d, source='%s'\n", ctx->param_uniqueid, ctx->param_state, ctx->param_ps); ps = strdup(ctx->param_ps); + // update status, if needed (only orig) status = ctx->param_state; done = jpelem__UpdateJobs->feedDone ? GLITE_JP_IS_STATE_DONE : 0; @@ -591,7 +599,7 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__QueryJobs( struct jptype__jobRecord *jr; char **jobids = NULL, **ps_list = NULL; - int i, size; + int i, size, err; puts(__FUNCTION__); @@ -610,8 +618,8 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__QueryJobs( } /* get all jobids matching the conditions */ - if ( get_jobids(ctx, in, &jobids, &ps_list) ) { - glite_jpis_stack_error(ctx->jpctx, 0, NULL); + if ( (err = get_jobids(ctx, in, &jobids, &ps_list)) != 0 ) { + glite_jpis_stack_error(ctx->jpctx, err, "Error getting jobs"); goto fail; } @@ -621,8 +629,8 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__QueryJobs( GLITE_SECURITY_GSOAP_LIST_CREATE(soap, out, jobs, struct jptype__jobRecord, size); for (i=0; (jobids && jobids[i]); i++) { jr = GLITE_SECURITY_GSOAP_LIST_GET(out->jobs, i); - if ( get_attrs(soap, ctx, jobids[i], in, jr) ) { - glite_jpis_stack_error(ctx->jpctx, 0, NULL); + if ( (err = get_attrs(soap, ctx, jobids[i], in, jr)) != 0 ) { + glite_jpis_stack_error(ctx->jpctx, err, "Error getting attributes of the job '%s'", jobids[i]); goto fail; } diff --git a/org.glite.jp.index/src/soap_ps_calls.c b/org.glite.jp.index/src/soap_ps_calls.c index 576dc72..d3dcce8 100644 --- a/org.glite.jp.index/src/soap_ps_calls.c +++ b/org.glite.jp.index/src/soap_ps_calls.c @@ -19,14 +19,13 @@ extern struct Namespace jp__namespaces[]; -int debug = 0; /*------------------*/ /* Helper functions */ /*------------------*/ -#define dprintf(FMT, ARGS...) if (debug) fprintf(stderr, FMT, ##ARGS) +#define dprintf(FMT, ARGS...) do {fprintf(stderr, "[%d] %s: ", getpid(), __FUNCTION__); fprintf(stderr, FMT, ##ARGS); } while(0); #include "glite/jp/ws_fault.c" #define check_fault(SOAP, ERR) glite_jp_clientCheckFault((SOAP), (ERR), NULL, 0) @@ -61,7 +60,6 @@ int MyFeedIndex(glite_jpis_context_t ctx, glite_jp_is_conf *conf, long int uniqu char *src, *desc = NULL; lprintf("(%ld) for %s called\n", uniqueid, dest); - debug = conf->debug; glite_gsplugin_init_context(&plugin_ctx); if (ctx->conf->server_key) plugin_ctx->key_filename = strdup(ctx->conf->server_key); @@ -99,7 +97,7 @@ int MyFeedIndex(glite_jpis_context_t ctx, glite_jp_is_conf *conf, long int uniqu in.history = conf->feeds[dest_index]->history; in.continuous = conf->feeds[dest_index]->continuous; in.destination = ctx->hname; - lprintf("(%ld) destination IS: %s\n", uniqueid, ctx->hname); + lprintf("(%ld) destination IS: '%s'\n", uniqueid, ctx->hname); if (check_fault(soap,soap_call___jpsrv__FeedIndex(soap,dest,"", &in, &out)) != 0) { fprintf(stderr, "\n");