- another step towards filetype plugins
authorAleš Křenek <ljocha@ics.muni.cz>
Fri, 8 Apr 2005 11:48:28 +0000 (11:48 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Fri, 8 Apr 2005 11:48:28 +0000 (11:48 +0000)
- should build now

org.glite.jp.primary/Makefile
org.glite.jp.primary/examples/jpps-test.c
org.glite.jp.primary/src/backend.h
org.glite.jp.primary/src/bones_server.c
org.glite.jp.primary/src/feed.c
org.glite.jp.primary/src/feed.h
org.glite.jp.primary/src/ftp_backend.c
org.glite.jp.primary/src/soap_ops.c

index bfcac49..e1ab3ed 100644 (file)
@@ -33,7 +33,7 @@ GLOBUS_CFLAGS:=-I${globus_prefix}/include/${nothrflavour}
 
 DEBUG:=-g -O0  -DDEBUG
 
-CFLAGS:=${DEBUG} -I. -I${top_srcdir}/src -I${gsoap_prefix}/include -I${stagedir}/include ${GLOBUS_CFLAGS}
+CFLAGS:=${DEBUG} -I. -I${top_srcdir}/interface -I${top_srcdir}/src -I${gsoap_prefix}/include -I${stagedir}/include ${GLOBUS_CFLAGS}
 LDFLAGS:=-L${stagedir}/lib
 
 LINK:=libtool --mode=link ${CC} ${LDFLAGS} 
@@ -52,7 +52,7 @@ CFLAGS+=-DGSOAP_VERSION=${gsoap_version}
 
 
 SRCS:= bones_server.c soap_ops.c \
-       ftp_backend.c \
+       ftp_backend.c file_plugin.c \
        feed.c tags.c\
        is_client.c \
        ${ps_prefix}ServerLib.c \
index 638005a..350c386 100644 (file)
@@ -183,8 +183,16 @@ int main(int argc,char *argv[])
                if (!check_fault(soap,soap_call_jpsrv__GetJob(soap,server,"",
                                                argv[2],&r)))
                {
-                       printf("JobLog:\t%s\nInput:\t%s\nOutput:\t%s\nTags:\t%s\n",
-                                       r.jobLog,r.inputSandbox,r.outputSandbox,r.tags);
+                       int     i;
+
+                       printf("JobLog:\n");
+
+                       for (i=0; i<r.files->__sizefile;i++) {
+                               printf("\tclass = %s, name = %s, url = %s\n",
+                                               r.files->file[i]->class_,
+                                               r.files->file[i]->name,
+                                               r.files->file[i]->url);
+                       }
                }
 
        }
index 538361c..54c152d 100644 (file)
@@ -35,11 +35,19 @@ int glite_jppsbe_commit_upload(
        const char *destination
 );
 
+int glite_jppsbe_get_names(
+       glite_jp_context_t ctx,
+       const char *job,
+       const char *class,
+       char    ***names_out
+);
+
 int glite_jppsbe_destination_info(
        glite_jp_context_t ctx,
        const char *destination,
        char **job_out,
-       char **class_out
+       char **class_out,
+       char **name_out
 );
 
 int glite_jppsbe_get_job_url(
index ac348b1..921dbca 100644 (file)
@@ -56,6 +56,12 @@ int main(int argc, char *argv[])
                exit(1);
        }
 
+       if (glite_jpps_fplug_load(ctx, &argc, argv)) {
+               /* XXX log */
+               fputs(glite_jp_error_chain(ctx), stderr);
+               exit(1);
+       }
+
        srand48(time(NULL)); /* feed id generation */
 
        stab.conn = socket(PF_INET, SOCK_STREAM, 0);
index 297eb23..89ea840 100644 (file)
@@ -176,7 +176,8 @@ int glite_jpps_match_attr(
 int glite_jpps_match_file(
        glite_jp_context_t ctx,
        const char *job,
-       glite_jp_fileclass_t class
+       const char *class,
+       const char *name
 )
 {
        fprintf(stderr,"%s: \n",__FUNCTION__);
index 1551a82..c3c2461 100644 (file)
@@ -12,7 +12,7 @@ struct jpfeed {
 
 
 int glite_jpps_match_attr(glite_jp_context_t,const char *,const glite_jp_attrval_t[]);
-int glite_jpps_match_file(glite_jp_context_t,const char *,glite_jp_fileclass_t);
+int glite_jpps_match_file(glite_jp_context_t,const char *,const char *,const char *);
 int glite_jpps_match_tag(glite_jp_context_t,const char *,const glite_jp_tagval_t *);
 int glite_jpps_run_feed(glite_jp_context_t,const char *,const glite_jp_attr_t *,const glite_jp_query_rec_t *,char **);
 int glite_jpps_register_feed(glite_jp_context_t,const char *,const glite_jp_attr_t *,const glite_jp_query_rec_t *,char **,time_t *);
index 6a7fcf6..dc4ed60 100644 (file)
@@ -618,7 +618,8 @@ int glite_jppsbe_destination_info(
        glite_jp_context_t ctx,
        const char *destination,
        char **job,
-       char **class
+       char **class,
+       char **name
 )
 {
        size_t dest_len;
@@ -635,6 +636,7 @@ int glite_jppsbe_destination_info(
        assert(destination != NULL);
        assert(job != NULL);
        assert(class != NULL);
+       assert(name != NULL);
 
        glite_jp_clear_error(ctx);
        memset(&err,0,sizeof err);
@@ -681,6 +683,9 @@ int glite_jppsbe_destination_info(
        }
 */
 
+       /* TODO: */
+       *name = NULL;
+
        if (asprintf(&dest_rw_info, "%s/_info", dest_rw) == -1) {
                err.code = ENOMEM;
                goto error_out;
index 53fc46d..9f8f93b 100644 (file)
@@ -12,6 +12,9 @@
 
 #include "jptype_map.h"
 
+#include "file_plugin.h"
+#include "builtin_plugins.h"
+
 static struct jptype__GenericJPFaultType *jp2s_error(struct soap *soap,
                const glite_jp_error_t *err)
 {
@@ -135,19 +138,22 @@ SOAP_FMAC5 int SOAP_FMAC6 jpsrv__CommitUpload(
                struct jpsrv__CommitUploadResponse *response)
 {
        CONTEXT_FROM_SOAP(soap,ctx);
-       char    *job = NULL;
-       glite_jp_fileclass_t    class;
+       char    *job,*class,*name;
 
+       job = class = name = NULL;
+       
        if (glite_jppsbe_commit_upload(ctx,destination)) {
                err2fault(ctx,soap);
                return SOAP_FAULT;
        }
 
        /* XXX: should not fail when commit_upload was OK */
-       glite_jppsbe_destination_info(ctx,destination,&job,&class);
+       glite_jppsbe_destination_info(ctx,destination,&job,&class,&name);
 
        /* XXX: ignore errors but don't fail silenty */
-       glite_jpps_match_file(ctx,job,class);
+       glite_jpps_match_file(ctx,job,class,name);
+
+       free(job); free(class); free(name);
 
        return SOAP_OK;
 }
@@ -159,31 +165,41 @@ SOAP_FMAC5 int SOAP_FMAC6 jpsrv__RecordTag(
                struct jpsrv__RecordTagResponse *response)
 {
        CONTEXT_FROM_SOAP(soap,ctx);
-       void    *tagfile;
+       void    *file_be,*file_p;
+       glite_jpps_fplug_data_t pd;
 
        glite_jp_tagval_t       mytag;
 
-       if (glite_jppsbe_open_file(ctx,job,GLITE_JP_FILECLASS_TAGS,
-                                       O_WRONLY|O_CREAT,&tagfile))
-       {
+       file_be = file_p = NULL;
+
+       /* XXX: we assume that TAGS plugin handles just one uri/class */
+       if (glite_jpps_fplug_lookup(ctx,GLITE_JP_FILETYPE_TAGS,&pd)
+               || glite_jppsbe_open_file(ctx,job,pd.classes[0],NULL,
+                                               O_WRONLY|O_CREAT,&file_be)
+       ) {
                err2fault(ctx,soap);
                return SOAP_FAULT;
        }
 
-       if (glite_jpps_tag_append(ctx,tagfile,&mytag)) {
+       s2jp_tag(tag,&mytag);
+
+       if (pd.ops.open(pd.fpctx,file_be,&file_p)
+               || pd.ops.generic(pd.fpctx,file_p,GLITE_JP_FPLUG_TAGS_APPEND,&mytag))
+       {
                err2fault(ctx,soap);
-               glite_jppsbe_close_file(ctx,tagfile);
+               if (file_p) pd.ops.close(pd.fpctx,file_p);
+               glite_jppsbe_close_file(ctx,file_be);
                return SOAP_FAULT;
        }
 
-       if (glite_jppsbe_close_file(ctx,tagfile)) {
+       if (pd.ops.close(pd.fpctx,file_p)
+               || glite_jppsbe_close_file(ctx,file_be))
+       {
                err2fault(ctx,soap);
                return SOAP_FAULT;
        }
 
        /* XXX: ignore errors but don't fail silenty */
-
-       s2jp_tag(tag,&mytag);
        glite_jpps_match_tag(ctx,job,&mytag);
 
        return SOAP_OK;
@@ -325,43 +341,44 @@ SOAP_FMAC5 int SOAP_FMAC6 jpsrv__GetJob(
        CONTEXT_FROM_SOAP(soap,ctx);
        char    *url;
 
-       struct {
-               glite_jp_fileclass_t    type;
-               char    **url;
-               char    *name;
-       } tab[] = {
-               { GLITE_JP_FILECLASS_INPUT, &response->inputSandbox, "input sandbox" },
-               { GLITE_JP_FILECLASS_OUTPUT, &response->outputSandbox, "output sandbox" },
-               { GLITE_JP_FILECLASS_LBLOG, &response->jobLog, "L&B log" },
-               { GLITE_JP_FILECLASS_TAGS, &response->tags, "JP tags" },
-               { GLITE_JP_FILECLASS_UNDEF, NULL, NULL }
-       };
-
-       int     i,gotone = 0;
+       int     i,n;
        glite_jp_error_t        err;
-               
-       for (i=0; tab[i].type; i++) {
-               glite_jp_clear_error(ctx);
-               switch (glite_jppsbe_get_job_url(ctx,job,tab[i].type,&url)) {
-                       case 0: *tab[i].url = soap_strdup(soap,url);
-                               free(url);
-                               gotone = 1;
-                               break;
-                       case ENOENT:
-                               *tab[i].url = NULL;
-                               break;
-                       default: 
-                               err.code = ctx->error->code;
-                               err.source = "jpsrv__GetJob()";
-                               err.desc = tab[i].name;
-                               glite_jp_stack_error(ctx,&err);
-                               err2fault(ctx,soap);
-                               glite_jp_clear_error(ctx);
-                               return SOAP_FAULT;
+       void    **pd;
+       struct jptype__Files    *files;
+       struct jptype__File     **f = NULL;
+
+       files = response->files = soap_malloc(soap,sizeof *response->files);
+       files->__sizefile = 0;
+
+       for (pd = ctx->plugins; *pd; pd++) {
+               glite_jpps_fplug_data_t *plugin = *pd;
+
+               for (i=0; plugin->uris[i]; i++) {
+                       glite_jp_clear_error(ctx);
+                       switch (glite_jppsbe_get_job_url(ctx,job,plugin->classes[i],NULL,&url)) {
+                               case 0: n = files->__sizefile++;
+                                       f = realloc(f,files->__sizefile * sizeof *f);
+                                       f[n] = soap_malloc(soap, sizeof **f);
+                                       f[n]->class_ = soap_strdup(soap,plugin->uris[i]);
+                                       f[n]->name = NULL;
+                                       f[n]->url = soap_strdup(soap,url);
+                                       free(url);
+                                       break;
+                               case ENOENT:
+                                       break;
+                               default: 
+                                       err.code = ctx->error->code;
+                                       err.source = "jpsrv__GetJob()";
+                                       err.desc = plugin->uris[i];
+                                       glite_jp_stack_error(ctx,&err);
+                                       err2fault(ctx,soap);
+                                       glite_jp_clear_error(ctx);
+                                       return SOAP_FAULT;
+                       }
                }
        }
 
-       if (!gotone) {
+       if (!files->__sizefile) {
                glite_jp_clear_error(ctx);
                err.code = ENOENT;
                err.source = __FUNCTION__;
@@ -371,6 +388,10 @@ SOAP_FMAC5 int SOAP_FMAC6 jpsrv__GetJob(
                glite_jp_clear_error(ctx);
                return SOAP_FAULT;
        }
+
+       files->file = soap_malloc(soap,files->__sizefile * sizeof *f);
+       memcpy(files->file,f,files->__sizefile * sizeof *f);
+
        return SOAP_OK;
 }