improved and added some log messages, print more WS errors
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Wed, 18 Apr 2007 11:56:30 +0000 (11:56 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Wed, 18 Apr 2007 11:56:30 +0000 (11:56 +0000)
dropping attributes tables just before creating (nifty when deleted attrs table)
fixed ugly bug in updateJobs (forgotten fetch)

org.glite.jp.index/src/conf.c
org.glite.jp.index/src/db_ops.c
org.glite.jp.index/src/soap_ops.c
org.glite.jp.index/src/soap_ps_calls.c

index c378d75..0600bdb 100644 (file)
@@ -2,6 +2,7 @@
 
 #ident "$Header$"
 
+#include <sys/types.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -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);
index 988b7e8..e6bc5b8 100644 (file)
@@ -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);
index 7282e47..450eb91 100644 (file)
@@ -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;
                }
 
index 576dc72..d3dcce8 100644 (file)
 
 
 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");