Basic test (requires mysql).
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Fri, 11 Nov 2005 14:39:27 +0000 (14:39 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Fri, 11 Nov 2005 14:39:27 +0000 (14:39 +0000)
Store the origin of attribute into DB.

org.glite.jp.index/Makefile
org.glite.jp.index/config/glite-jp-index-dbsetup.sql
org.glite.jp.index/examples/jpis-test.c
org.glite.jp.index/src/common_server.c
org.glite.jp.index/src/db_ops.c

index 85f2db6..d472190 100644 (file)
@@ -118,8 +118,8 @@ ${ps_prefix}C.c ${ps_prefix}H.h ${ps_prefix}_Stub.h: JobProvenancePS.xh
 #      rm -f JobProvenanceTypes.wsdl
 #      ${gsoap_prefix}/bin/soapcpp2 -w -c -p env_ env.xh
 
-check: 
-       -echo nothing yet
+check:
+       ../test/run-test.sh
 
 doc:
 
@@ -168,5 +168,6 @@ soap_ps_calls.o: soap_ps_calls.c jpps_H.h jpps_.nsmap soap_version.h conf.h db_o
 soap_ops.o: soap_ops.c jpis_H.h jpis_.nsmap soap_version.h db_ops.h ws_ps_typeref.h ws_is_typeref.h context.h
 ws_ps_typeref.o: ws_ps_typeref.c jpis_H.h ws_typemap.h ws_ps_typeref.h
 ws_is_typeref.o: ws_is_typeref.c jpis_H.h ws_typemap.h ws_is_typeref.h
+comon_server.o: common_server.c common_server.h
 
 .PHONY: default all compile check doc stage dist distsrc distbin install clean
index 231627a..485c04f 100644 (file)
@@ -60,7 +60,8 @@ create table users (
 #create table attr_<attrid> (
 #        jobid         char(32)        binary not null,
 #        value         varchar(255)    binary not null,
-#       full_value     mediumblob      not null,
+#        full_value    mediumblob      not null,
+#        origin                int             not null,
 #
 #        index (jobid),
 #        index (value)
index 4ecfdf0..b15b8ad 100644 (file)
@@ -51,6 +51,8 @@ int main(int argc,char *argv[])
                glite_jp_get_conf(0, NULL, NULL, &conf);
                if (default_server) strcpy(server, default_server);
                else snprintf(server, sizeof(server), "http://localhost:%s", conf->port ? conf->port : GLITE_JPIS_DEFAULT_PORT_STR);
+               printf("JP index server: %s\n", server);
+
                glite_jpis_init_context(&isctx, ctx, conf);
                if (glite_jpis_init_db(isctx) != 0) {
                        fprintf(stderr, "Connect DB failed: %s (%s)\n", 
index 61f987c..63052b4 100644 (file)
@@ -30,7 +30,10 @@ int glite_jpis_daemonize(const char *servername, const char *custom_pidfile, con
 //     printf("logfile: %s\n", logfile ? logfile : custom_logfile);
        free(logfile);
 
-       daemon(0,1);
+       if (daemon(0,1) == -1) {
+               perror("can't daemonize");
+               return 0;
+       }
        dup2(lfd,1);
        dup2(lfd,2);
 
index 5320bf0..a965906 100644 (file)
         jobid          CHAR(32)    BINARY NOT NULL,\n\
         value          %s          BINARY NOT NULL,\n\
         full_value     %s          NOT NULL,\n\
+        origin         INT         NOT NULL,\n\
 \n\
         INDEX (jobid),\n\
         INDEX (value)\n\
 );"
-#define SQLCMD_INSERT_ATTRVAL "INSERT INTO " TABLE_PREFIX_DATA "%s (jobid, value, full_value) VALUES (\n\
+#define SQLCMD_INSERT_ATTRVAL "INSERT INTO " TABLE_PREFIX_DATA "%s (jobid, value, full_value, origin) VALUES (\n\
        '%s',\n\
        '%s',\n\
-       '%s'\n\
+       '%s',\n\
+       '%d'\n\
 )"
 #define INDEX_LENGTH 255
 
@@ -573,12 +575,14 @@ int glite_jpis_tryReconnectFeed(glite_jpis_context_t ctx, long int uniqueid, tim
 
 int glite_jpis_insertAttrVal(glite_jpis_context_t ctx, const char *jobid, glite_jp_attrval_t *av) {
        char *sql, *table, *value, *full_value, *md5_jobid;
+       long int origin;
 
        table = glite_jpis_attr_name2id(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);
-       asprintf(&sql, SQLCMD_INSERT_ATTRVAL, table, md5_jobid, value, full_value);
+       origin = av->origin;
+       asprintf(&sql, SQLCMD_INSERT_ATTRVAL, table, md5_jobid, value, full_value, origin);
        free(md5_jobid);
        free(table);
        free(value);