From 93f531e548e886d850982686040aaa83aea74567 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Milo=C5=A1=20Mula=C4=8D?= Date: Wed, 17 Aug 2005 12:02:21 +0000 Subject: [PATCH] various adds-on, mainly for sharing - compiles --- org.glite.jp.index/Makefile | 33 ++++++++--- org.glite.jp.index/examples/jpis-test.c | 101 ++++++++++++++++++++++++++++++++ org.glite.jp.index/src/bones_server.c | 24 +++++++- org.glite.jp.index/src/conf.c | 41 ++++++++++++- org.glite.jp.index/src/conf.h | 18 +++++- org.glite.jp.index/src/soap_ops.c | 89 +++++++++++++++++++++++----- 6 files changed, 275 insertions(+), 31 deletions(-) create mode 100644 org.glite.jp.index/examples/jpis-test.c diff --git a/org.glite.jp.index/Makefile b/org.glite.jp.index/Makefile index f0896b5..9d2afb5 100644 --- a/org.glite.jp.index/Makefile +++ b/org.glite.jp.index/Makefile @@ -42,15 +42,18 @@ INSTALL:=libtool --mode=install install daemon:=glite-jp-indexd -soap_prefix:=jpis_ +example:=jpis-test +is_prefix:=jpis_ +ps_prefix:=jpps_ SRCS:= conf.c bones_server.c soap_ops.c \ - ${soap_prefix}C.c \ - ${soap_prefix}ServerLib.c \ - ${soap_prefix}ClientLib.c + ${is_prefix}ServerLib.c \ + ${ps_prefix}ClientLib.c ${ps_prefix}C.c +EXA_SRCS:=jpis-test.c ${is_prefix}C.c ${is_prefix}Client.c OBJS:=${SRCS:.c=.o} +EXA_OBJS:=${EXA_SRCS:.c=.o} COMMONLIB:=-lglite_jp_common @@ -77,16 +80,28 @@ compile: ${daemon} ${daemon}: ${OBJS} ${LINK} -o $@ -export-dynamic ${OBJS} ${BONESLIB} ${TRIOLIB} ${COMMONLIB} ${GSOAPLIB} ${GLOBUS_LIBS} ${MYSQLIB} +${example}: ${EXA_OBJS} + ${LINK} -o $@ ${EXA_OBJS} ${GSOAPLIB} ${GLOBUS_LIBS} JobProvenanceIS.xh: JobProvenanceIS.wsdl JobProvenanceTypes.wsdl typemap.dat cp ${stagedir}/interface/JobProvenanceTypes.wsdl . ${gsoap_prefix}/bin/wsdl2h -t ${top_srcdir}/src/typemap.dat -c -o $@ $< rm -f JobProvenanceTypes.wsdl -${soap_prefix}ClientLib.c ${soap_prefix}Client.c \ -${soap_prefix}Server.c ${soap_prefix}ServerLib.c \ -${soap_prefix}C.c ${soap_prefix}H.h: JobProvenanceIS.xh - ${gsoap_prefix}/bin/soapcpp2 -n -w -c -p ${soap_prefix} JobProvenanceIS.xh +JobProvenancePS.xh: %.xh: %.wsdl JobProvenanceTypes.wsdl typemap.dat + cp ${stagedir}/interface/JobProvenanceTypes.wsdl . + ${gsoap_prefix}/bin/wsdl2h -t ${top_srcdir}/src/typemap.dat -c -o $@ $< + rm -f JobProvenanceTypes.wsdl + +${is_prefix}ClientLib.c ${is_prefix}Client.c \ +${is_prefix}Server.c ${is_prefix}ServerLib.c \ +${is_prefix}C.c ${is_prefix}H.h: JobProvenanceIS.xh + ${gsoap_prefix}/bin/soapcpp2 -n -w -c -p ${is_prefix} JobProvenanceIS.xh + +${ps_prefix}Client.c ${ps_prefix}ClientLib.c \ +${ps_prefix}C.c ${ps_prefix}H.h: JobProvenancePS.xh + ${gsoap_prefix}/bin/soapcpp2 -n -w -c -p ${ps_prefix} JobProvenancePS.xh + #env_C.c env_Server.c: # touch env.xh @@ -131,7 +146,7 @@ install: clean: -soap_ops.o bones_server.o simple_server.o: ${soap_prefix}H.h +soap_ops.o bones_server.o simple_server.o: ${is_prefix}H.h ${ps_prefix}H.h # we have no real config.h but have to force gSoap not to use # linux ftime with broken (aka obsolete) DST information diff --git a/org.glite.jp.index/examples/jpis-test.c b/org.glite.jp.index/examples/jpis-test.c new file mode 100644 index 0000000..7aa7573 --- /dev/null +++ b/org.glite.jp.index/examples/jpis-test.c @@ -0,0 +1,101 @@ +#include +#include +#include +#include + +#include "glite/security/glite_gsplugin.h" + +#include "jpis_H.h" +#include "jpis_.nsmap" + +//#include "jptype_map.h" + +#include "soap_version.h" +#if GSOAP_VERSION <= 20602 +#define soap_call___jpsrv__UpdateJobs soap_call___ns1__UpdateJobs +#define soap_call___jpsrv__QueryJobs soap_call___ns1__QueryJobs +#endif + + + +static int check_fault(struct soap *soap,int err) { + struct SOAP_ENV__Detail *detail; + struct jptype__genericFault *f; + char *reason,indent[200] = " "; + + switch(err) { + case SOAP_OK: puts("OK"); + break; + case SOAP_FAULT: + case SOAP_SVR_FAULT: + if (soap->version == 2) { + detail = soap->fault->SOAP_ENV__Detail; + reason = soap->fault->SOAP_ENV__Reason; + } + else { + detail = soap->fault->detail; + reason = soap->fault->faultstring; + } + fputs(reason,stderr); + putc('\n',stderr); + assert(detail->__type == SOAP_TYPE__genericFault); +#if GSOAP_VERSION >=20700 + f = ((struct _genericFault *) detail->fault) +#else + f = ((struct _genericFault *) detail->value) +#endif + -> jpelem__genericFault; + + while (f) { + fprintf(stderr,"%s%s: %s (%s)\n",indent, + f->source,f->text,f->description); + f = f->reason; + strcat(indent," "); + } + return -1; + + default: soap_print_fault(soap,stderr); + return -1; + } + return 0; +} + + +int main(int argc,char *argv[]) +{ + char *server = "http://localhost:8902"; + int opt; + struct soap *soap = soap_new(); + + + soap_init(soap); + soap_set_namespaces(soap, jpis__namespaces); + + soap_register_plugin(soap,glite_gsplugin); + + // test calls of server functions + { + struct _jpelem__QueryJobs in; + struct _jpelem__QueryJobsResponse out; + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + check_fault(soap, + soap_call___jpsrv__UpdateJobs(soap,server,"",&in,&out)); + } + { + struct _jpelem__QueryJobs in; + struct _jpelem__QueryJobsResponse out; + + memset(&in, 0, sizeof(in)); + memset(&out, 0, sizeof(out)); + check_fault(soap, + soap_call___jpsrv__QueryJobs(soap, server, "",&in,&out)); + } + + return 0; +} + + +/* XXX: we don't use it */ +SOAP_NMAC struct Namespace namespaces[] = { {NULL,NULL} }; diff --git a/org.glite.jp.index/src/bones_server.c b/org.glite.jp.index/src/bones_server.c index 12b39bc..60ff01e 100644 --- a/org.glite.jp.index/src/bones_server.c +++ b/org.glite.jp.index/src/bones_server.c @@ -17,12 +17,19 @@ #include "soap_version.h" #include "jpis_H.h" +#if GSOAP_VERSION <= 20602 +#define soap_call___jpsrv__FeedIndex soap_call___ns1__FeedIndex +#define soap_call___jpsrv__FeedIndexRefresh soap_call___ns1__FeedIndexRefresh +#endif + #define CONN_QUEUE 20 extern SOAP_NMAC struct Namespace jpis__namespaces[],jpps__namespaces[]; extern SOAP_NMAC struct Namespace namespaces[] = { {NULL,NULL} }; // namespaces[] not used here, but need to prevent linker to complain... +extern void MyFeedIndex(glite_jp_is_conf *conf, char *dest); + static int newconn(int,struct timeval *,void *); static int request(int,struct timeval *,void *); static int reject(int); @@ -54,13 +61,14 @@ int main(int argc, char *argv[]) int one = 1,opt,i; edg_wll_GssStatus gss_code; struct sockaddr_in a; - glite_jp_is_conf conf; + glite_jp_is_conf *conf; char *config_file; glite_jp_init_context(&ctx); /* Read config options/file */ + // XXX: need add something meaningfull to src/conf.c ! config_file = NULL; glite_jp_get_conf(argc, argv, config_file, &conf); @@ -114,6 +122,16 @@ int main(int argc, char *argv[]) glite_srvbones_set_param(GLITE_SBPARAM_SLAVES_COUNT,1); glite_srvbones_run(data_init,&stab,1 /* XXX: entries in stab */,debug); + + // XXX: need solve 2 WSDLs problem :( + /* + for (i=0; conf->PS_list[i]; i++) + MyFeedIndex(conf,conf->PS_list[i]); + */ + + + glite_jp_free_conf(conf); + return 0; } @@ -267,6 +285,8 @@ static int disconn(int conn,struct timeval *to,void *data) { struct soap *soap = (struct soap *) data; soap_end(soap); // clean up everything and close socket - + return 0; } + + diff --git a/org.glite.jp.index/src/conf.c b/org.glite.jp.index/src/conf.c index 3a2590f..fc1328b 100644 --- a/org.glite.jp.index/src/conf.c +++ b/org.glite.jp.index/src/conf.c @@ -2,14 +2,51 @@ #ident "$Header$" -#include "conf.h" +#include +#include +#include "conf.h" -int glite_jp_get_conf(int argc, char **argv, char *config_file, glite_jp_is_conf *conf) +int glite_jp_get_conf(int argc, char **argv, char *config_file, glite_jp_is_conf **configuration) { // read comman line options and configuration file // XXX: use EGEE global configure tools in future... + + glite_jp_is_conf *conf; + + + conf = calloc(1, sizeof(*conf)); + + conf->attrs = calloc(5, sizeof(*conf->attrs)); + conf->attrs[0] = strdup("owner"); + conf->attrs[1] = strdup("status"); + conf->attrs[2] = strdup("location"); + conf->attrs[3] = strdup("jobid"); + + conf->PS_list = calloc(2, sizeof(*conf->PS_list)); + conf->PS_list[0] = strdup("http://localhost:8901"); + conf->indexed_attrs = calloc(3, sizeof(*conf->indexed_attrs)); + conf->indexed_attrs[0] = strdup("owner"); + conf->indexed_attrs[1] = strdup("location"); + + // all job since Epoche + conf->query = calloc(2,sizeof(*conf->query)); + conf->query[0] = calloc(2,sizeof(**conf->query)); + conf->query[0][0].attr = strdup("date"); + conf->query[0][0].op = GLITE_JP_QUERYOP_GREATER; + conf->query[0][0].value = strdup("0"); + + conf->continuous = 1; + + *configuration = conf; + return 0; } + + +void glite_jp_free_conf(glite_jp_is_conf *conf) +{ + // XXX: structure dealocation +} diff --git a/org.glite.jp.index/src/conf.h b/org.glite.jp.index/src/conf.h index 4771b0e..2b95243 100644 --- a/org.glite.jp.index/src/conf.h +++ b/org.glite.jp.index/src/conf.h @@ -1,17 +1,29 @@ +#ident "$Header$" + #ifndef _CONF_H #define _CONF_H -#ident "$Header$" + +#include "glite/jp/types.h" typedef struct _glite_jp_is_conf { // all I need to get from comman line options and configuration file + + // arrays are zero-terminated + char **attrs; // atributes to obtain + char **PS_list; // URLs of Primary Storage servers + char **indexed_attrs; // list of indexed atributes + + glite_jp_query_rec_t **query; // query to Primary Server + + int history, continuous; // type of query } glite_jp_is_conf; // read commad line options and configuration file -int glite_jp_get_conf(int argc, char **argv, char *config_file, glite_jp_is_conf *conf); - +int glite_jp_get_conf(int argc, char **argv, char *config_file, glite_jp_is_conf **configuration); +void glite_jp_free_conf(glite_jp_is_conf *conf); #endif diff --git a/org.glite.jp.index/src/soap_ops.c b/org.glite.jp.index/src/soap_ops.c index ef12fe1..c9ab90a 100644 --- a/org.glite.jp.index/src/soap_ops.c +++ b/org.glite.jp.index/src/soap_ops.c @@ -6,9 +6,20 @@ #include "jpis_H.h" #include "jpis_.nsmap" +// XXX: need solve 2 WSDLs problem :( +//#include "jpps_H.h" +//#include "jpps_.nsmap" #include "soap_version.h" + + + +/*------------------*/ +/* Helper functions */ +/*------------------*/ + + static struct jptype__genericFault *jp2s_error(struct soap *soap, const glite_jp_error_t *err) { @@ -47,21 +58,14 @@ static void err2fault(const glite_jp_context_t ctx,struct soap *soap) else soap->fault->detail = detail; } -/* -static void s2jp_tag(const struct jptype__TagValue *stag,glite_jp_tagval_t *jptag) -{ - memset(jptag,0,sizeof *jptag); - jptag->name = strdup(stag->name); - jptag->sequence = stag->sequence ? *stag->sequence : 0; - jptag->timestamp = stag->timestamp ? *stag->timestamp : 0; - if (stag->stringValue) jptag->value = strdup(stag->stringValue); - else if (stag->blobValue) { - jptag->binary = 1; - jptag->size = stag->blobValue->__size; - jptag->value = (char *) stag->blobValue->__ptr; - } -} -*/ + + + + +/*-----------------------------------------*/ +/* IS WSDL server function implementations */ +/*-----------------------------------------*/ + #define CONTEXT_FROM_SOAP(soap,ctx) glite_jp_context_t ctx = (glite_jp_context_t) ((soap)->user) @@ -84,3 +88,58 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__QueryJobs( return SOAP_OK; } + + + + +/*----------------------*/ +/* PS WSDL client calls */ +/*----------------------*/ + +/* +// XXX: need solve 2 WSDLs problem :( + +// call PS FeedIndex for a given destination +void MyFeedIndex(glite_jp_is_conf *conf, char *dest) +{ + struct _jpelem__FeedIndex in; + struct jpsrv__FeedIndexResponse out; + struct jptype__PrimaryQuery query; + struct jptype__stringOrBlob value; +// struct xsd__base64Binary blob; + int i; + + + memset(&in, 0, sizeof(in)); + + for (i=0; conf->attrs[i]; i++) ; + in.__sizeattributes = i; + in.attributes = conf->attrs; + + // XXX: we need C -> WSDL conversion function ! + query.attr = conf->query[0][0].attr; + query.op = conf->query[0][0].op; // XXX: nasty, needs conversion + query.origin = jptype__attrOrig__USER; + value.string = conf->query[0][0].value; // XXX: hope string +// memset(&blob, 0, sizeof(blob)); +// value.blob = &blob; + value.blob = NULL; + query.value = &value; + query.value2 = NULL; + + in.__sizeconditions = 1 + in.conditions = malloc(sizeof(*in.conditions)); + in.conditions[0] = &query; // XXX: supp. only one dimensional queries ! (no ORs) + // for 2D queries one more _sizeconditions needed IMO + + in.history = conf->history; + in.continuous = conf->continuous; + + if (!check_fault(soap,soap_call_jpsrv___FeedIndex(soap,server,"", + dest, &in, &out))) + { + printf("FeedId: %s\nExpires: %s\n",out.feedId,ctime(&out.expires)); + } + +} +*/ -- 1.8.2.3