From 754a16da50dcc1f765afede6244244a5fdcf8ede Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Fri, 11 Nov 2005 14:39:27 +0000 Subject: [PATCH] Basic test (requires mysql). Store the origin of attribute into DB. --- org.glite.jp.index/Makefile | 5 +++-- org.glite.jp.index/config/glite-jp-index-dbsetup.sql | 3 ++- org.glite.jp.index/examples/jpis-test.c | 2 ++ org.glite.jp.index/src/common_server.c | 5 ++++- org.glite.jp.index/src/db_ops.c | 10 +++++++--- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/org.glite.jp.index/Makefile b/org.glite.jp.index/Makefile index 85f2db6..d472190 100644 --- a/org.glite.jp.index/Makefile +++ b/org.glite.jp.index/Makefile @@ -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 diff --git a/org.glite.jp.index/config/glite-jp-index-dbsetup.sql b/org.glite.jp.index/config/glite-jp-index-dbsetup.sql index 231627a..485c04f 100644 --- a/org.glite.jp.index/config/glite-jp-index-dbsetup.sql +++ b/org.glite.jp.index/config/glite-jp-index-dbsetup.sql @@ -60,7 +60,8 @@ create table users ( #create table attr_ ( # 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) diff --git a/org.glite.jp.index/examples/jpis-test.c b/org.glite.jp.index/examples/jpis-test.c index 4ecfdf0..b15b8ad 100644 --- a/org.glite.jp.index/examples/jpis-test.c +++ b/org.glite.jp.index/examples/jpis-test.c @@ -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", diff --git a/org.glite.jp.index/src/common_server.c b/org.glite.jp.index/src/common_server.c index 61f987c..63052b4 100644 --- a/org.glite.jp.index/src/common_server.c +++ b/org.glite.jp.index/src/common_server.c @@ -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); diff --git a/org.glite.jp.index/src/db_ops.c b/org.glite.jp.index/src/db_ops.c index 5320bf0..a965906 100644 --- a/org.glite.jp.index/src/db_ops.c +++ b/org.glite.jp.index/src/db_ops.c @@ -25,14 +25,16 @@ 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); -- 1.8.2.3