From 97093c065031daa7745d68034ade92fbd23c8f96 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ale=C5=A1=20K=C5=99enek?= Date: Tue, 16 Dec 2008 15:30:20 +0000 Subject: [PATCH] partial cleanup -- getversion and jobstat - lb client library is not required anymore - other examples are still broken --- org.glite.lb.ws-test/Makefile | 6 +- org.glite.lb.ws-test/examples/ws_fault.c | 55 ++-------- org.glite.lb.ws-test/examples/ws_fault.h | 9 +- org.glite.lb.ws-test/examples/ws_getversion.c | 14 +-- org.glite.lb.ws-test/examples/ws_jobstat.c | 151 ++------------------------ 5 files changed, 30 insertions(+), 205 deletions(-) diff --git a/org.glite.lb.ws-test/Makefile b/org.glite.lb.ws-test/Makefile index 5bf6426..1c4e9a8 100644 --- a/org.glite.lb.ws-test/Makefile +++ b/org.glite.lb.ws-test/Makefile @@ -26,7 +26,8 @@ VPATH=${top_srcdir}/examples CC=gcc CFLAGS=-I${gsoap_prefix}/include -I${gsoap_prefix}/ \ -I${stagedir}/include -I${top_srcdir}/src -I. \ - -I${globus_prefix}/include/${nothrflavour} + -I${globus_prefix}/include/${nothrflavour} \ + ${DEBUG} COMPILE:=libtool --mode=compile ${CC} ${CFLAGS} LINK:=libtool --mode=link ${CC} -rpath ${stagedir}/lib ${LDFLAGS} @@ -37,8 +38,7 @@ GSOAP_LIB:=-L${stagedir}/lib -lglite_security_gsoap_plugin_${dotless_gsoap_ver}_ WS_CLIENT_OBJS:= $(GSOAP_FILES_PREFIX)C.o $(GSOAP_FILES_PREFIX)Client.o ws_fault.o # ws_typeref.o -WS_CLIENT_LIBS:= ${GSOAP_LIB} -lglite_lb_common_${nothrflavour} \ - -lglite_lb_common_${nothrflavour} +WS_CLIENT_LIBS:= ${GSOAP_LIB} SOAP_FILES:=${GSOAP_FILES_PREFIX}H.h ${GSOAP_FILES_PREFIX}C.c ${GSOAP_FILES_PREFIX}Server.c ${GSOAP_FILES_PREFIX}Client.c ${GSOAP_FILES_PREFIX}ServerLib.c ${GSOAP_FILES_PREFIX}ClientLib.c LoggingAndBookkeeping.nsmap diff --git a/org.glite.lb.ws-test/examples/ws_fault.c b/org.glite.lb.ws-test/examples/ws_fault.c index 844d9f3..dfc4de6 100644 --- a/org.glite.lb.ws-test/examples/ws_fault.c +++ b/org.glite.lb.ws-test/examples/ws_fault.c @@ -1,6 +1,6 @@ #include +#include -#include "glite/lb/context-int.h" #include "soap_version.h" #include "glite/security/glite_gscompat.h" @@ -17,51 +17,14 @@ #endif -void edg_wll_ErrToFault(const edg_wll_Context ctx,struct soap *soap) -{ - char *et,*ed; - struct SOAP_ENV__Detail *detail = soap_malloc(soap,sizeof *detail); -#if GSOAP_VERSION >= 20709 - struct lbt__genericFault *f = soap_malloc(soap,sizeof *f); -#else - struct _genericFault *f = soap_malloc(soap,sizeof *f); -#endif - - f->GFITEM = soap_malloc(soap,sizeof *f->GFITEM); - memset(f->GFITEM, 0, sizeof(*f->GFITEM)); - - f->GFITEM->code = edg_wll_Error(ctx,&et,&ed); - f->GFITEM->text = soap_malloc(soap,strlen(et)+1); - strcpy(f->GFITEM->text,et); - free(et); - if (ed) { - f->GFITEM->description = soap_malloc(soap,strlen(ed)+1); - strcpy(f->GFITEM->description,ed); - free(ed); - } - - detail->__type = GFNUM; -#if GSOAP_VERSION >= 20700 - detail->fault = f; -#else - detail->value = f; -#endif - detail->__any = NULL; - - soap_receiver_fault(soap,"An error occurred, see detail",NULL); - if (soap->version == 2) soap->fault->SOAP_ENV__Detail = detail; - else soap->fault->detail = detail; -} - - -void edg_wll_FaultToErr(const struct soap *soap,edg_wll_Context ctx) +int glite_lb_FaultToErr(const struct soap *soap,char **text) { struct SOAP_ENV__Detail *detail; struct lbt__genericFault *f; if (!soap->fault) { - edg_wll_SetError(ctx,EINVAL,"SOAP: (no error info)"); - return; + *text = NULL; + return EINVAL; } detail = soap->version == 2 ? soap->fault->SOAP_ENV__Detail : soap->fault->detail; @@ -75,14 +38,12 @@ void edg_wll_FaultToErr(const struct soap *soap,edg_wll_Context ctx) f = ((struct _genericFault *) detail->value) ->lbe__genericFault; #endif - edg_wll_SetError(ctx,f->code,f->description); + *text = strdup(f->description); + return f->code; } else { - char *s; - - asprintf(&s,"SOAP: %s", soap->version == 2 ? + asprintf(text,"SOAP: %s", soap->version == 2 ? GLITE_SECURITY_GSOAP_REASON(soap) : soap->fault->faultstring); - edg_wll_SetError(ctx,EINVAL,s); - free(s); + return EINVAL; } } diff --git a/org.glite.lb.ws-test/examples/ws_fault.h b/org.glite.lb.ws-test/examples/ws_fault.h index 70870cd..d5b9045 100644 --- a/org.glite.lb.ws-test/examples/ws_fault.h +++ b/org.glite.lb.ws-test/examples/ws_fault.h @@ -1,7 +1,6 @@ -#ifndef __EDG_WORKLOAD_LOGGING_LBSERVER_WS_FAULT_H__ -#define __EDG_WORKLOAD_LOGGING_LBSERVER_WS_FAULT_H__ +#ifndef __GLITE_LB_WS_FAULT_H__ +#define __GLITE_LB_WS_FAULT_H__ -extern void edg_wll_ErrToFault(const edg_wll_Context, struct soap *); -extern void edg_wll_FaultToErr(const struct soap *, edg_wll_Context); +int glite_lb_FaultToErr(const struct soap *soap,char **text); -#endif /* __EDG_WORKLOAD_LOGGING_LBSERVER_WS_FAULT_H__ */ +#endif diff --git a/org.glite.lb.ws-test/examples/ws_getversion.c b/org.glite.lb.ws-test/examples/ws_getversion.c index 83a6172..3bc4b91 100644 --- a/org.glite.lb.ws-test/examples/ws_getversion.c +++ b/org.glite.lb.ws-test/examples/ws_getversion.c @@ -2,7 +2,6 @@ #include #include "glite/security/glite_gsplugin.h" -#include "glite/lb/context.h" #include "bk_ws_H.h" #include "ws_fault.h" @@ -27,11 +26,8 @@ static void usage(char *me) , me); } -//static void printstat(edg_wll_JobStat stat, int level); - int main(int argc,char** argv) { - edg_wll_Context ctx; glite_gsplugin_Context gsplugin_ctx; struct soap soap; struct _lbe__GetVersion in; @@ -51,7 +47,6 @@ int main(int argc,char** argv) case '?': usage(name); return 1; } - edg_wll_InitContext(&ctx); glite_gsplugin_init_context(&gsplugin_ctx); soap_init(&soap); @@ -71,11 +66,11 @@ int main(int argc,char** argv) case SOAP_FAULT: case SOAP_SVR_FAULT: { - char *et,*ed; + char *et; + int err; - edg_wll_FaultToErr(&soap,ctx); - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"%s: %s (%s)\n",argv[0],et,ed); + err = glite_lb_FaultToErr(&soap,&et); + fprintf(stderr,"%s: %s (%s)\n",argv[0],strerror(err),et); exit(1); } default: @@ -86,7 +81,6 @@ int main(int argc,char** argv) soap_end(&soap); soap_done(&soap); glite_gsplugin_free_context(gsplugin_ctx); - edg_wll_FreeContext(ctx); return 0; } diff --git a/org.glite.lb.ws-test/examples/ws_jobstat.c b/org.glite.lb.ws-test/examples/ws_jobstat.c index 1c83ebb..1377890 100644 --- a/org.glite.lb.ws-test/examples/ws_jobstat.c +++ b/org.glite.lb.ws-test/examples/ws_jobstat.c @@ -4,11 +4,8 @@ #include "soap_version.h" #include "glite/security/glite_gsplugin.h" #include "glite/security/glite_gscompat.h" -#include "glite/lb/consumer.h" #include "bk_ws_H.h" -// #include "ws_typeref.h" -#include "ws_fault.h" #if GSOAP_VERSION <= 20602 #define soap_call___lb__JobStatus soap_call___ns1__JobStatus @@ -31,11 +28,8 @@ static void usage(char *me) , me); } -static void printstat(edg_wll_JobStat stat, int level); - int main(int argc,char** argv) { - edg_wll_Context ctx; glite_gsplugin_Context gsplugin_ctx; struct soap *mydlo = soap_new(); struct _lbe__JobStatusResponse out; @@ -64,7 +58,6 @@ int main(int argc,char** argv) return 1; } - edg_wll_InitContext(&ctx); soap_set_namespaces(mydlo, namespaces); glite_gsplugin_init_context(&gsplugin_ctx); @@ -74,31 +67,31 @@ int main(int argc,char** argv) return 1; } - glite_gsplugin_set_udata(mydlo, ctx); in.jobid = soap_strdup(mydlo, jobid); - in.flags = soap_malloc(mydlo, sizeof(*in.flags)); - edg_wll_JobStatFlagsToSoap(mydlo, 0, in.flags); + in.flags = NULL; switch (err = soap_call___lb__JobStatus(mydlo, server, "",&in,&out)) { case SOAP_OK: { - edg_wll_JobStat s; + struct soap *outsoap = soap_new();; - edg_wll_SoapToStatus(mydlo,out.stat,&s); - printstat(s, 0); - edg_wll_FreeStatus(&s); + outsoap->sendfd = 1; + soap_serialize_PointerTolbt__jobStatus(outsoap,&out.stat); + soap_begin_send(outsoap); + soap_put_PointerTolbt__jobStatus(outsoap,&out.stat,"status","http://glite.org/wsdl/types/lb:jobStatus"); + soap_end_send(outsoap); } break; case SOAP_FAULT: case SOAP_SVR_FAULT: { - char *et,*ed; + char *et; + int err; - edg_wll_FaultToErr(mydlo,ctx); - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"%s: %s (%s)\n",argv[0],et,ed); + err = glite_lb_FaultToErr(mydlo,&et); + fprintf(stderr,"%s: %s (%s)\n",argv[0],strerror(err),et); exit(1); } default: @@ -110,128 +103,6 @@ int main(int argc,char** argv) soap_done(mydlo); free(mydlo); glite_gsplugin_free_context(gsplugin_ctx); - edg_wll_FreeContext(ctx); return 0; } - -static void printstat(edg_wll_JobStat stat, int level) -{ - char *s, *j1,*j2, ind[10]; - int i; - - - for (i=0; i < level; i++) - ind[i]='\t'; - ind[i]='\0'; - - s = edg_wll_StatToString(stat.state); -/* print whole flat structure */ - printf("%sstate : %s\n", ind, s); - printf("%sjobId : %s\n", ind, j1 = edg_wlc_JobIdUnparse(stat.jobId)); - printf("%sowner : %s\n", ind, stat.owner); - switch (stat.jobtype) { - case EDG_WLL_STAT_SIMPLE: - printf("%sjobtype : SIMPLE\n", ind); - break; - case EDG_WLL_STAT_DAG: - printf("%sjobtype : DAG\n", ind); - break; - case EDG_WLL_STAT_COLLECTION: - printf("%sjobtype : COLLECTION\n", ind); - break; - case EDG_WLL_STAT_PBS: - printf("%sjobtype : PBS\n", ind); - break; - default: - break; - } - printf("%sparent_job : %s\n", ind, - j2 = edg_wlc_JobIdUnparse(stat.parent_job)); - if (stat.jobtype) {; - printf("%sseed : %s\n", ind, stat.seed); - printf("%schildren_num : %d\n", ind, stat.children_num); - printf("%schildren :\n", ind); - if (stat.children) - for (i=0; stat.children[i]; i++) - printf("%s\tchildren : %s\n", ind, stat.children[i]); - printf("%schildren_states :\n", ind); - if (stat.children_states) - for (i=0; stat.children_states[i].state; i++) - printstat(stat.children_states[i], level+1); - printf("%schildren_hist :\n",ind); - if (stat.children_hist) - for (i=1; i<=stat.children_hist[0]; i++) - printf("%s%14s %d\n", ind, edg_wll_StatToString(i-1),stat.children_hist[i]); - } - printf("%scondorId : %s\n", ind, stat.condorId); - printf("%sglobusId : %s\n", ind, stat.globusId); - printf("%slocalId : %s\n", ind, stat.localId); - printf("%sjdl : %s\n", ind, stat.jdl); - printf("%smatched_jdl : %s\n", ind, stat.matched_jdl); - printf("%sdestination : %s\n", ind, stat.destination); - printf("%snetwork server : %s\n", ind, stat.network_server); - printf("%scondor_jdl : %s\n", ind, stat.condor_jdl); - printf("%srsl : %s\n", ind, stat.rsl); - printf("%sreason : %s\n", ind, stat.reason); - printf("%slocation : %s\n", ind, stat.location); - printf("%sce_node : %s\n", ind, stat.ce_node); - printf("%ssubjob_failed : %d\n", ind, stat.subjob_failed); - printf("%sdone_code : %s\n", ind, edg_wll_done_codeToString(stat.done_code)); - printf("%sexit_code : %d\n", ind, stat.exit_code); - printf("%sresubmitted : %d\n", ind, stat.resubmitted); - printf("%scancelling : %d\n", ind, stat.cancelling); - printf("%scancelReason : %s\n", ind, stat.cancelReason); - printf("%scpuTime : %d\n", ind, stat.cpuTime); - printf("%suser_tags :\n",ind); - if (stat.user_tags) - for (i=0; stat.user_tags[i].tag; i++) printf("%s%14s = \"%s\"\n", ind, - stat.user_tags[i].tag,stat.user_tags[i].value); - printf("%sstateEnterTime : %ld.%06ld\n", ind, stat.stateEnterTime.tv_sec,stat.stateEnterTime.tv_usec); - printf("%sstateEnterTimes : \n",ind); - if (stat.stateEnterTimes) - for (i=1; i<=stat.stateEnterTimes[0]; i++) { - time_t st = stat.stateEnterTimes[i]; - - printf("%s%14s %s", ind, edg_wll_StatToString(i-1), st == 0 ? - " - not available -\n" : ctime(&st)); - } - printf("%slastUpdateTime : %ld.%06ld\n", ind, stat.lastUpdateTime.tv_sec,stat.lastUpdateTime.tv_usec); - printf("%sexpectUpdate : %d\n", ind, stat.expectUpdate); - printf("%sexpectFrom : %s\n", ind, stat.expectFrom); - printf("%sacl : %s\n", ind, stat.acl); - printf("%spayload_running: %d\n", ind, stat.payload_running); - if (stat.possible_destinations) { - printf("%spossible_destinations : \n", ind); - for (i=0; stat.possible_destinations[i]; i++) - printf("%s\t%s \n", ind, stat.possible_destinations[i]); - } - if (stat.possible_ce_nodes) { - printf("%spossible_ce_nodes : \n", ind); - for (i=0; stat.possible_ce_nodes[i]; i++) - printf("%s\t%s \n", ind, stat.possible_ce_nodes[i]); - } - /* PBS state section */ - if (stat.jobtype == EDG_WLL_STAT_PBS) { - printf("%spbs_state : %s\n", ind, stat.pbs_state); - printf("%spbs_queue : %s\n", ind, stat.pbs_queue); - printf("%spbs_owner : %s\n", ind, stat.pbs_owner); - printf("%spbs_name : %s\n", ind, stat.pbs_name); - printf("%spbs_reason : %s\n", ind, stat.pbs_reason); - printf("%spbs_scheduler : %s\n", ind, stat.pbs_scheduler); - printf("%spbs_dest_host : %s\n", ind, stat.pbs_dest_host); - printf("%spbs_pid : %d\n", ind, stat.pbs_pid); - printf("%spbs_resource_usage : %s%s\n", ind, - (stat.pbs_resource_usage) ? "\n" : "", stat.pbs_resource_usage); - printf("%spbs_exit_status : %d\n", ind, stat.pbs_exit_status); - printf("%spbs_error_desc : %s%s\n", ind, - (stat.pbs_error_desc) ? "\n" : "", stat.pbs_error_desc); - } - - printf("\n"); - - free(j1); - free(j2); - free(s); -} - -- 1.8.2.3