allow to register file transfer collection (currently, all jobs have same from,to)
authorJiří Filipovič <fila@ics.muni.cz>
Thu, 24 Feb 2011 12:12:12 +0000 (12:12 +0000)
committerJiří Filipovič <fila@ics.muni.cz>
Thu, 24 Feb 2011 12:12:12 +0000 (12:12 +0000)
org.glite.lb.client/src/register_sandbox.c

index 348ce03..9947719 100644 (file)
@@ -43,6 +43,7 @@ static void usage(char *me)
                        "       -t,--to URI\n"
                        "       [ -s,--source lb-source ]       (default LRMS)\n"
                        "       [ -c,--sequence lb-seqcode ]\n"
+                       "       [ -n,--subjobs n]\n"
                        ,me);
 }
 
@@ -65,15 +66,17 @@ int main(int argc,char **argv)
                { "to",1,NULL,'t' },
                { "source",1,NULL,'s' },
                { "sequence",1,NULL,'c' },
+               { "subjobs",1,NULL,'n' },
        };
 
        char    *jobid_s = NULL, *ftjobid_s = NULL, *from = NULL, *to = NULL, *source_s = "LRMS",
                *sequence = NULL, *srv, *uniq, type_c = 'x';
 
        unsigned int    port;
-       int     o;
+       int             o, i;
+       unsigned int    nsubjobs = 0;
 
-       glite_jobid_t   jobid, ftjobid;
+       glite_jobid_t   jobid, ftjobid, *subjobs;
        edg_wll_Source  source;
 
        enum edg_wll_SandboxSandbox_type type =
@@ -81,7 +84,7 @@ int main(int argc,char **argv)
 
        edg_wll_Context ctx;
 
-       while ((o = getopt_long(argc,argv,"j:iof:t:s:c:",opts,NULL)) != EOF) switch(o) {
+       while ((o = getopt_long(argc,argv,"j:iof:t:s:c:n:",opts,NULL)) != EOF) switch(o) {
                case 'j':       jobid_s = optarg; break;
                case 'i':       if (type != EDG_WLL_SANDBOX_SANDBOX_TYPE_UNDEFINED) { usage(argv[0]); exit(1); }
                                type = EDG_WLL_SANDBOX_INPUT;
@@ -93,6 +96,7 @@ int main(int argc,char **argv)
                case 't':       to = optarg; break;
                case 's':       source_s = optarg; break;
                case 'c':       sequence = optarg; break;
+               case 'n':       nsubjobs = atoi(optarg); break;
                default:        usage(argv[0]); exit(1);
        }
 
@@ -134,11 +138,17 @@ int main(int argc,char **argv)
 
        check_log(edg_wll_RegisterJob,ftjobid_s,(
                ctx,
-               ftjobid, EDG_WLL_REGJOB_FILE_TRANSFER,
+               ftjobid, (nsubjobs==0) ? EDG_WLL_REGJOB_FILE_TRANSFER : EDG_WLL_REGJOB_FILE_TRANSFER_COLLECTION,
                "n/a","n/a",
-               0,NULL,NULL));
-               
-       check_log(edg_wll_LogFileTransferRegister,ftjobid_s,(ctx,from,to));
+               nsubjobs,NULL,&subjobs));
+
+       if (nsubjobs == 0) {    
+               check_log(edg_wll_LogFileTransferRegister,ftjobid_s,(ctx,from,to));
+       }
+       else {
+               check_log(edg_wll_LogFileTransferRegister,ftjobid_s,(ctx,"n/a","n/a"));
+       }
+
        check_log(edg_wll_LogSandbox,ftjobid_s,(
                                ctx,
                                edg_wll_SandboxSandbox_typeToString(type),
@@ -165,5 +175,36 @@ int main(int argc,char **argv)
 
        printf("GLITE_WMS_SEQUENCE_CODE=\"%s\"\n",edg_wll_GetSequenceCode(ctx));
 
+       if (nsubjobs){
+               for (i = 0; i < nsubjobs; i++){
+                       char    *ftsubjobid_s = edg_wlc_JobIdUnparse(subjobs[i]);
+                       printf("EDG_WL_SUB_JOBID[%d]=\"%s\"\n", i, ftsubjobid_s);
+                       free(ftsubjobid_s);
+               }
+
+               edg_wll_SetLoggingJob(ctx,ftjobid,NULL,EDG_WLL_SEQ_NORMAL);
+               check_log(edg_wll_RegisterFTSubjobs, ftjobid_s, (
+                       ctx,
+                       ftjobid,
+                       "NS",
+                       nsubjobs, subjobs
+               ));
+
+               for (i=0; subjobs[i]; i++) {
+                       char    *ftsubjobid_s = edg_wlc_JobIdUnparse(subjobs[i]);
+                       edg_wll_SetLoggingJob(ctx, subjobs[i], NULL, EDG_WLL_SEQ_NORMAL);
+                       check_log(edg_wll_LogFileTransferRegister, ftsubjobid_s,(
+                               ctx, from, to
+                       ));
+                       check_log(edg_wll_LogSandbox, ftsubjobid_s, (
+                               ctx,
+                               edg_wll_SandboxSandbox_typeToString(type),
+                               NULL,
+                               jobid_s
+                       ));
+                        free(ftsubjobid_s);
+               }
+       }
+
        return 0;
 }