source: branches/prototype-v0/zoo-project/zoo-kernel/service_internal_hpc.c @ 877

Last change on this file since 877 was 877, checked in by djay, 6 years ago

Fixes for supporting properly the memory=protect which force the ZOO-Kernel to not store any downloaded files in memory. Add footer to the HPC support. Fix the autotools to build service_json and sshapi only when required so, when HPC support is activated, this also avoid adding too much dependencies at compilation time. Store md5 of the downloaded files to avoid uploading on HPC server the same file more than once, in case the md5 correspond.

  • Property svn:keywords set to Id
File size: 39.6 KB
Line 
1/*
2 * Author : Gérald FENOY
3 *
4 * Copyright (c) 2017 GeoLabs SARL
5 *
6 * This work was supported by public funds received in the framework of GEOSUD,
7 * a project (ANR-10-EQPX-20) of the program "Investissements d'Avenir" managed
8 * by the French National Research Agency
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 * THE SOFTWARE.
27 *
28 */
29
30#include "service_internal_hpc.h"
31#include "response_print.h"
32#include "server_internal.h"
33#include "service_callback.h"
34#include "mimetypes.h"
35#include <sys/un.h>
36
37typedef struct {
38  maps* conf;
39  char* local_file;
40  char* target_file;
41} local_params;
42
43/**
44 * Add nested outputs to every outputs that is geographic format
45 * @see isGeographic
46 * @param s the service current definition
47 */ 
48void addNestedOutputs(service** s){
49  if((*s)==NULL){
50    return;
51  }   
52  if(*s==NULL || (*s)->outputs==NULL || (*s)->content==NULL){
53    return;
54  }
55  elements *out=(*s)->outputs;
56  elements* cur=out;
57  map* serviceType=getMap((*s)->content,"ServiceType");
58  if(strncmp(serviceType->value,"HPC",3)!=0)
59    return;
60  while(cur!=NULL && cur->defaults!=NULL){
61    map* mimeType=getMap(cur->defaults->content,"mimeType");
62    map* useMS=getMap(cur->defaults->content,"useMapserver");
63    if(mimeType!=NULL && useMS!=NULL && strncasecmp(useMS->value,"true",4)==0){
64      int geo=isGeographic(mimeType->value);
65      if(geo>0){
66        elements *tmp[3]={
67          dupElements(cur),
68          dupElements(cur),
69          dupElements(cur)
70        };
71        char *geoLink="wcs_link";
72        if(geo==2){
73          geoLink="wfs_link";
74        }
75        int i=0;
76        for(;i<3;i++){
77          if(tmp[i]->next!=NULL){
78            freeElements(&tmp[i]->next);
79            free(tmp[i]->next);
80            tmp[i]->next=NULL;
81          }
82          free(tmp[i]->name);
83          if(tmp[i]->format!=NULL)
84            free(tmp[i]->format);
85          tmp[i]->format=zStrdup("ComplexData");
86          freeMap(&tmp[i]->content);
87          free(tmp[i]->content);
88          tmp[i]->content=NULL;
89          switch(i){
90          case 0:
91            tmp[i]->name=zStrdup("download_link");
92            tmp[i]->content=createMap("Title",_("Download link"));
93            addToMap(tmp[i]->content,"Abstract",_("The download link"));
94            addToMap(tmp[i]->defaults->content,"useMapserver","false");
95            if(tmp[i]->supported!=NULL){
96              freeIOType(&tmp[i]->supported);
97              free(tmp[i]->supported);
98              tmp[i]->supported=NULL;
99            }
100            break;
101          case 1:
102            tmp[i]->name=zStrdup("wms_link");
103            tmp[i]->content=createMap("Title",_("WMS link"));
104            addToMap(tmp[i]->content,"Abstract",_("The WMS link"));
105            if(tmp[i]->supported!=NULL && tmp[i]->supported->next!=NULL){
106              freeIOType(&tmp[i]->supported->next);
107              free(tmp[i]->supported->next);
108              tmp[i]->supported->next=NULL;
109            }else{
110              if(tmp[i]->supported!=NULL)
111                addToMap(tmp[i]->supported->content,"useMapserver","true");
112              addToMap(tmp[i]->defaults->content,"useMapserver","true");
113            }
114            break;
115          case 2:
116            if(geo==2){
117              tmp[i]->name=zStrdup("wfs_link");
118              tmp[i]->content=createMap("Title",_("WFS link"));
119              addToMap(tmp[i]->content,"Abstract",_("The WFS link"));
120            }else{
121              tmp[i]->name=zStrdup("wcs_link");
122              tmp[i]->content=createMap("Title",_("WCS link"));
123              addToMap(tmp[i]->content,"Abstract",_("The WCS link"));
124            }
125            if(tmp[i]->supported!=NULL && tmp[i]->supported->next!=NULL &&
126               tmp[i]->supported->next->content!=NULL){
127              freeIOType(&tmp[i]->supported);
128              free(tmp[i]->supported);
129              tmp[i]->supported=NULL;
130              tmp[i]->supported=createIoType();
131              iotype* cnext=cur->supported->next;
132              tmp[i]->supported->content=createMap(cnext->content->name,cnext->content->value);
133              addMapToMap(&tmp[i]->supported->content,cnext->content->next);
134              addToMap(tmp[i]->supported->content,"useMapserver","true");
135            }else
136              addToMap(tmp[i]->defaults->content,"useMapserver","true");
137            break;
138          }
139        }
140        addToElements(&cur->child,tmp[0]);
141        addToElements(&cur->child,tmp[1]);
142        addToElements(&cur->child,tmp[2]);
143        free(cur->format);
144        cur->format=NULL;
145        if(cur->defaults!=NULL){
146          freeIOType(&cur->defaults);
147          free(cur->defaults);
148          cur->defaults=NULL;
149        }
150        if(cur->supported!=NULL){
151          freeIOType(&cur->supported);
152          free(cur->supported);
153          cur->supported=NULL;
154        }
155        freeElements(&tmp[2]);
156        free(tmp[2]);
157        freeElements(&tmp[1]);
158        free(tmp[1]);
159        freeElements(&tmp[0]);
160        free(tmp[0]);
161        //addToMap(cur->content,"internal","true");
162      }     
163    }
164    cur=cur->next;
165  }
166  //dumpElements((*s)->outputs);
167}
168
169/**
170 * Acquire a read lock on every files used as input for executing a service.
171 * @param conf the main configuration file map
172 * @return 0 if every file can be locked, -1 if one lock has failed.
173 */
174int addReadLocks(maps** conf){
175  map* queueLengthMap=getMapFromMaps(*conf,"uploadQueue","length");
176  maps* queueMaps=getMaps(*conf,"uploadQueue");
177  if(queueLengthMap!=NULL){
178    int cnt=atoi(queueLengthMap->value);
179    int i=0;
180    for(i=0;i<cnt;i++){
181      map* argv[2]={
182        getMapArray(queueMaps->content,"input",i),
183        getMapArray(queueMaps->content,"localPath",i)
184      };
185      zooLock* lck;
186      if((lck=lockFile(*conf,argv[1]->value,'r'))==NULL){
187        char* templateStr=_("Unable to lock the file for %s in read mode.");
188        char *tmpMessage=(char*)malloc((strlen(templateStr)+strlen(argv[0]->value)+1)*sizeof(char));
189        sprintf(tmpMessage,templateStr,argv[0]->value);
190        setMapInMaps(*conf,"lenv","message",tmpMessage);
191        free(tmpMessage);
192        return -1;
193      }else{
194        if(zoo_file_locks_cnt==0){
195          zoo_file_locks=(zooLock**)malloc(sizeof(zooLock*));
196        }
197        else{
198          zoo_file_locks=(zooLock**)realloc(zoo_file_locks,(zoo_file_locks_cnt+1)*sizeof(zooLock*));
199        }
200        zoo_file_locks[zoo_file_locks_cnt]=lck;
201        zoo_file_locks_cnt++;
202      }
203    }
204  }
205  return 0;
206}
207
208/**
209 * Remove all read locks set for files used as input for executing the service.
210 * @param conf the main configuration maps pointer
211 * @return 0 in case of success, -1 if any error occured. In case of error, one
212 * can refer to the message map array from the lenv section.
213 */
214int removeReadLocks(maps** conf){
215  int res=0;
216  int nberr=0;
217  map* queueLengthMap=getMapFromMaps(*conf,"uploadQueue","length");
218  maps* queueMaps=getMaps(*conf,"uploadQueue");
219  if(queueLengthMap!=NULL){
220    int cnt=atoi(queueLengthMap->value);
221    int i=0;
222    for(i=0;i<cnt;i++){
223      if(unlockFile(*conf,zoo_file_locks[i])<1){
224        map* argv=getMapArray(queueMaps->content,"input",i);
225        char* templateStr=_("Unable to unlock the file for %s after execution.");
226        char *tmpMessage=(char*)malloc((strlen(templateStr)+strlen(argv->value)+1)*sizeof(char));
227        sprintf(tmpMessage,templateStr,argv->value);
228        maps* lenv=getMaps(*conf,"lenv");
229        setMapArray(lenv->content,"message",nberr,tmpMessage);
230        free(tmpMessage);
231        res=-1;
232        nberr++;
233      }
234    }
235  }
236  free(zoo_file_locks);
237  return res;
238}
239
240/**
241 * Get the section name depending on number of features and/or pixels of each
242 * inputs and the threshold defined in a section.
243 * It supposes that your inputs has been published using MapServer support,
244 * implying that the number of features (nb_features), respectively pixels
245 * (nb_pixels), are defined. The section, identified by confId, should contain
246 * preview_max_features and preview_max_pixels defining the threshold values.
247 * @param conf the main configuration file maps pointer
248 * @param inputs the inputs maps pointer
249 * @param confId the section identifier
250 * @return "preview_conf" in case the numbers are lower than the threshold,
251 * "fullres_conf" in other cases.
252 */
253char* getConfiguration(maps** conf,maps** inputs,const char* confId){
254  maps* input=*inputs;
255  map* max_pixels=getMapFromMaps(*conf,confId,"preview_max_pixels");
256  map* max_features=getMapFromMaps(*conf,confId,"preview_max_features");
257  int i_max_pixels=atoi(max_pixels->value);
258  int i_max_features=atoi(max_features->value);
259  while(input!=NULL && input->content!=NULL){
260    map* tmpMap=getMap(input->content,"geodatatype");
261    if(tmpMap!=NULL){
262      map* currentNb;
263      if(strcasecmp(tmpMap->value,"raster")==0 ){
264        currentNb=getMap(input->content,"nb_pixels");
265        if(atoi(currentNb->value)>i_max_pixels)
266          return "fullres_conf";
267      }else{
268        if(strcasecmp(tmpMap->value,"vector")==0 ){
269          currentNb=getMap(input->content,"nb_features");
270          if(atoi(currentNb->value)>i_max_features)
271            return "fullres_conf";
272        }
273      }
274    }
275    input=input->next;
276  }
277  return "preview_conf";
278}
279
280/**
281 * Load and run a HPC Application corresponding to the service.
282 *
283 * @param main_conf the conf maps containing the main.cfg settings
284 * @param request the map containing the HTTP request
285 * @param s the service structure
286 * @param real_inputs the maps containing the inputs
287 * @param real_outputs the maps containing the outputs
288 * @return SERVICE_SUCCEEDED in case of success, -1 or SERVICE_FAILED when failing.
289 */
290int zoo_hpc_support(maps** main_conf,map* request,service* s,maps **real_inputs,maps **real_outputs){
291  maps* m=*main_conf;
292  maps* inputs=*real_inputs;
293  maps* outputs=*real_outputs;
294  map* tmp0=getMapFromMaps(*main_conf,"lenv","cwd");
295  char *ntmp=tmp0->value;
296  map* tmp=NULL;
297  int res=-1;
298  // Get the configuration id depending on service type and defined thresholds
299  // then, set the configId key in the lenv section
300  char *serviceType;
301  map* mServiceType=getMap(s->content,"serviceType");
302  if(mServiceType!=NULL)
303    serviceType=mServiceType->value;
304  else
305    serviceType="HPC";
306  map* tmpPath=getMapFromMaps(*main_conf,"main","tmpPath");
307  map* uuid=getMapFromMaps(*main_conf,"lenv","usid");
308  map* confMap=getMapFromMaps(*main_conf,serviceType,getConfiguration(main_conf,real_inputs,serviceType));
309  char * configurationId=confMap->value;
310  setMapInMaps(*main_conf,"lenv","configId",configurationId);
311  // Dump lenv maps again after having set the configId ...
312  char *flenv =
313    (char *)
314    malloc ((strlen (tmpPath->value) + 
315             strlen (uuid->value) + 12) * sizeof (char));
316  sprintf (flenv, "%s/%s_lenv.cfg", tmpPath->value, uuid->value);
317  maps* lenvMaps=getMaps(m,"lenv");
318  dumpMapsToFile(lenvMaps,flenv,0);
319  free(flenv);
320
321  map* targetPathMap=getMapFromMaps(*main_conf,configurationId,"remote_data_path");
322 
323  pthread_t threads_pool[50];
324  // Force the HPC services to be called asynchronously
325  map* isAsync=getMapFromMaps(*main_conf,"lenv","async");
326  if(isAsync==NULL){
327    errorException(*main_conf,_("The synchronous mode is not supported by this type of service"),"NoSuchMode",s->name);
328    return -1;
329  }
330
331  maps* input=*real_inputs;
332  char **parameters=NULL;
333  int parameters_cnt=0;
334  while(input!=NULL && input->content!=NULL){
335    map* isInRequest=getMap(input->content,"inRequest");
336    map* minNb=getMap(input->content,"minoccurs");
337    if(getMaps(*real_outputs,input->name)==NULL &&
338       ( (isInRequest!=NULL && strncasecmp(isInRequest->value,"true",4)==0)
339         || (minNb!=NULL && atoi(minNb->value)>0) ) ){
340      parameters_cnt+=1;
341      if(parameters_cnt==1)
342        parameters=(char**)malloc(parameters_cnt*sizeof(char*));
343      else
344        parameters=(char**)realloc(parameters,parameters_cnt*sizeof(char*));
345      if(getMap(input->content,"mimeType")!=NULL){
346        // Input is ComplexData
347        if(getMap(input->content,"cache_file")==NULL){
348          // Input data has been passed by value
349          // TODO: publish input through MapServer / use output publication
350          dumpMapsValuesToFiles(main_conf,&input);
351          addToMap(input->content,"toPublish","true");
352          //addToMap(input->content,"useMapserver","true");
353        }
354        if(getMap(input->content,"cache_file")!=NULL){
355          map* length=getMap(input->content,"length");
356          if(length==NULL){
357            addToMap(input->content,"length","1");
358            length=getMap(input->content,"length");
359          }
360          int len=atoi(length->value);
361          int i=0;
362          for(i=0;i<len;i++){
363            map* tmp=getMapArray(input->content,"cache_file",i);
364            char* targetName=strrchr(tmp->value,'/');
365            char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char));
366            sprintf(targetPath,"%s/%s",targetPathMap->value,targetName);
367            setMapArray(input->content,"targetPath",i,targetPath);
368            setMapArray(input->content,"localPath",i,tmp->value);
369            map* tmp1=getMapArray(input->content,"value",i);
370            if(tmp1!=NULL){
371              free(tmp1->value);
372              tmp1->value=strdup("empty");
373            }
374            if(i==0){
375              parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+3)*sizeof(char));
376              sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,targetPath);
377            }else{
378              fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
379              fflush(stderr);
380              char *tmpStr=zStrdup(parameters[parameters_cnt-1]);
381              parameters[parameters_cnt-1]=(char*)realloc(parameters[parameters_cnt-1],(strlen(tmpStr)+strlen(targetPath)+2)*sizeof(char));
382              sprintf(parameters[parameters_cnt-1],"%s %s",tmpStr,targetPath);
383              free(tmpStr);
384              fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
385              fflush(stderr);
386            }
387            free(targetPath);
388          }
389          addToUploadQueue(main_conf,input);
390        }else{
391          // ???
392          fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
393          fflush(stderr);
394        }
395      }else{
396        // LitteralData and BboxData
397        if(getMap(input->content,"dataType")!=NULL){
398          // For LitteralData, simply pass the value
399          map* val=getMap(input->content,"value");
400          parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(val->value)+3)*sizeof(char));
401          sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,val->value);
402        }
403      }
404    }
405    input=input->next;
406  }
407
408#ifdef HPC_DEBUG
409  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
410#endif
411  invokeCallback(m,inputs,NULL,1,1);
412  invokeCallback(m,inputs,NULL,2,0);
413  if(getMapFromMaps(m,"lenv","mapError")!=NULL){
414    invokeCallback(*main_conf,inputs,NULL,7,0);
415    return -1;
416  }
417#ifdef HPC_DEBUG
418  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
419  dumpMaps(inputs);
420#endif
421
422  // Upload data on HPC
423  if(runUpload(main_conf)==false){
424    errorException (*main_conf, _("Unable to lock the file for upload!"),
425                    "InternalError", NULL);
426#ifdef HPC_DEBUG
427    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
428#endif
429    invokeCallback(*main_conf,inputs,NULL,7,0);
430#ifdef HPC_DEBUG
431    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
432#endif
433    return -1;
434  }
435#ifdef HPC_DEBUG
436  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
437#endif
438  invokeCallback(m,inputs,NULL,2,1);
439#ifdef HPC_DEBUG
440  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
441#endif
442
443  // Add the filename to generate for every output to parameters
444  input=*real_outputs;
445#ifdef HPC_DEBUG
446  dumpMaps(input);
447#endif
448  while(input!=NULL){
449    // Parse all outputs including inner outputs if required.
450    if(input->child==NULL){
451      // Name every files that should be produced by the service execution
452      map* mime=getMap(input->content,"mimeType");
453      char* targetName;
454      if(mime!=NULL){
455        bool hasExt=false;
456        map* fileExt=getFileExtensionMap(mime->value,&hasExt);
457        targetName=(char*)malloc((strlen(s->name)+strlen(input->name)+strlen(uuid->value)+strlen(fileExt->value)+11)*sizeof(char));
458        sprintf(targetName,"output_%s_%s_%s.%s",s->name,input->name,uuid->value,fileExt->value);
459        freeMap(&fileExt);
460        free(fileExt);
461      }else{
462        targetName=(char*)malloc((strlen(s->name)+strlen(input->name)+strlen(uuid->value)+14)*sizeof(char));
463        sprintf(targetName,"output_%s_%s_%s.tif",s->name,input->name,uuid->value);
464      }
465      char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char));
466      sprintf(targetPath,"%s/%s",targetPathMap->value,targetName);
467      map *tmpUrl=getMapFromMaps(*main_conf,"main","tmpUrl");
468      char *targetUrl=(char*)malloc((strlen(tmpUrl->value)+strlen(targetName)+2)*sizeof(char));
469      sprintf(targetUrl,"%s/%s",tmpUrl->value,targetName);
470      free(targetName);
471      setMapInMaps(*real_outputs,input->name,"generated_file",targetPath);
472      addToMap(input->content,"generated_url",targetUrl);
473      free(targetUrl);
474      {
475        parameters_cnt+=1;
476        if(parameters_cnt==1)
477          parameters=(char**)malloc(parameters_cnt*sizeof(char*));
478        else
479          parameters=(char**)realloc(parameters,parameters_cnt*sizeof(char*));
480        // We should verify if any optional tag for output is required
481        // (i.e. -out output.tiff *int8*), meaning that we should search
482        // for a corresponding inputs name.
483        map* inValue=getMapFromMaps(*real_inputs,input->name,"value");
484        if(inValue!=NULL){
485          parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+strlen(inValue->value)+4)*sizeof(char));
486          sprintf(parameters[parameters_cnt-1],"-%s %s %s",input->name,targetPath,inValue->value);
487        }else{
488          parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+3)*sizeof(char));
489          sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,targetPath);
490        }
491      }
492      free(targetPath);
493    }// In other case it means we need to return the cache_file as generated_file
494    else{
495      // Name every files that should be produced by the service execution
496      map* mime=getMap(input->child->content,"mimeType");
497      char* targetName;
498      if(mime!=NULL){
499        bool hasExt=false;
500        map* fileExt=getFileExtensionMap(mime->value,&hasExt);
501        targetName=(char*)malloc((strlen(s->name)+strlen(input->name)+strlen(uuid->value)+strlen(fileExt->value)+11)*sizeof(char));
502        sprintf(targetName,"output_%s_%s_%s.%s",s->name,input->name,uuid->value,fileExt->value);
503        freeMap(&fileExt);
504        free(fileExt);
505      }else{
506        targetName=(char*)malloc((strlen(s->name)+strlen(input->name)+strlen(uuid->value)+14)*sizeof(char));
507        sprintf(targetName,"output_%s_%s_%s.tif",s->name,input->name,uuid->value);
508      }
509      char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char));
510      sprintf(targetPath,"%s/%s",targetPathMap->value,targetName);
511      map *tmpUrl=getMapFromMaps(*main_conf,"main","tmpUrl");
512      char *targetUrl=(char*)malloc((strlen(tmpUrl->value)+strlen(targetName)+2)*sizeof(char));
513      sprintf(targetUrl,"%s/%s",tmpUrl->value,targetName);
514      free(targetName);
515      addToMap(input->content,"generated_file",targetPath);
516      addToMap(input->content,"storage",targetPath);
517      addToMap(input->content,"generated_url",targetUrl);
518      free(targetUrl);
519      if(strcasecmp(input->name,"wms_link")!=0&&
520         strcasecmp(input->name,"wcs_link")!=0 &&
521         strcasecmp(input->name,"wfs_link")!=0){
522        parameters_cnt+=1;
523        if(parameters_cnt==1)
524          parameters=(char**)malloc(parameters_cnt*sizeof(char*));
525        else
526          parameters=(char**)realloc(parameters,parameters_cnt*sizeof(char*));
527        // We should verify if any optional tag for output is required
528        // (i.e. -out output.tiff *int8*), meaning that we should search
529        // for a corresponding inputs name.
530        map* inValue=getMapFromMaps(*real_inputs,input->name,"value");
531        if(inValue!=NULL){
532          parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+strlen(inValue->value)+4)*sizeof(char));
533          sprintf(parameters[parameters_cnt-1],"-%s %s %s",input->name,targetPath,inValue->value);
534        }else{
535          parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+3)*sizeof(char));
536          sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,targetPath);
537        }
538      }
539      free(targetPath);
540    }
541    input=input->next;
542  }
543  // Produce the SBATCH File locally
544  char *scriptPath=(char*)malloc((strlen(s->name)+strlen(tmpPath->value)+strlen(uuid->value)+10)*sizeof(char));
545  sprintf(scriptPath,"%s/zoo_%s_%s.sh",tmpPath->value,s->name,uuid->value);
546  setMapInMaps(*main_conf,"lenv","local_script",scriptPath);
547#ifdef HPC_DEBUG
548  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
549  fflush(stderr);
550#endif
551  invokeCallback(m,inputs,NULL,3,0);
552#ifdef HPC_DEBUG
553  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
554  fflush(stderr);
555#endif
556  FILE* scriptFile=fopen(scriptPath,"w+");
557  map* headerMap=getMapFromMaps(*main_conf,configurationId,"jobscript_header");
558  if(headerMap!=NULL){
559    // Use the header file if defined in the HPC section of the main.cfg file
560    struct stat f_status;
561    int s=stat(headerMap->value, &f_status);
562    if(s==0){
563      char* fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));
564      FILE* f=fopen(headerMap->value,"rb");
565      fread(fcontent,f_status.st_size,1,f);
566      int fsize=f_status.st_size;
567      fcontent[fsize]=0;
568      fclose(f);
569      fprintf(scriptFile,"%s\n### --- ZOO-Service HEADER end --- ###\n\n",fcontent);
570      free(fcontent);
571    }else
572      fprintf(scriptFile,"#!/bin/bash\n\n### *** Default ZOO-Service HEADER (no header found) *** ###\n\n");
573  }else
574    fprintf(scriptFile,"#!/bin/bash\n\n### *** Default ZOO-Service HEADER *** ###\n\n");
575  maps* hpc_opts=getMaps(*main_conf,configurationId);
576  if(hpc_opts!=NULL){
577    map* hpc_opts_content=hpc_opts->content;
578    while(hpc_opts_content!=NULL){
579      if(strncasecmp(hpc_opts_content->name,"sbatch_options_",15)==0)
580        fprintf(scriptFile,"#SBATCH --%s=%s\n",strstr(hpc_opts_content->name,"sbatch_options_")+15,hpc_opts_content->value);
581      hpc_opts_content=hpc_opts_content->next;
582    }
583  }
584  fprintf(scriptFile,"#SBATCH --job-name=ZOO-Project_%s_%s\n\n",uuid->value,s->name);
585  map* mods=getMap(s->content,"hpcModules");
586  if(mods!=NULL)
587    fprintf(scriptFile,"#SBATCH --export=MODULES=%s\n",mods->value);
588
589  map* bodyMap=getMapFromMaps(*main_conf,configurationId,"jobscript_body");
590  if(bodyMap!=NULL){
591    // Use the header file if defined in the HPC section of the main.cfg file
592    struct stat f_status;
593    int s=stat(bodyMap->value, &f_status);
594    if(s==0){
595      char* fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));
596      FILE* f=fopen(bodyMap->value,"rb");
597      fread(fcontent,f_status.st_size,1,f);
598      int fsize=f_status.st_size;
599      fcontent[fsize]=0;
600      fclose(f);
601      fprintf(scriptFile,"%s\n### --- ZOO-Service BODY end --- ###\n\n",fcontent);
602      free(fcontent);
603    }else
604      fprintf(scriptFile,"\n### *** Default ZOO-Service BODY (no body found) *** ###\n\n");
605  }else
606    fprintf(scriptFile,"\n### *** Default ZOO-Service BODY *** ###\n\n");
607
608  map* sp=getMap(s->content,"serviceProvider");
609 
610  // Require to produce the command line to be executed
611  fprintf(scriptFile,"\n\necho \"Job started at: $(date)\"\n");
612  fprintf(scriptFile,"echo \"Running service: [%s]\"\n",sp->value);
613  fprintf(scriptFile,"%s ",sp->value);
614  for(int i=0;i<parameters_cnt;i++){
615    fprintf(scriptFile," %s",parameters[i]);
616  }
617  for(int i=parameters_cnt-1;i>=0;i--){
618    free(parameters[i]);
619  }
620  free(parameters);
621  fprintf(scriptFile,"\n");
622  fprintf(scriptFile,"echo \"Job finished at: $(date)\"\n");
623  map* footerMap=getMapFromMaps(*main_conf,configurationId,"jobscript_footer");
624  if(footerMap!=NULL){
625    // Use the footer file if defined in the HPC section of the main.cfg file
626    struct stat f_status;
627    int s=stat(footerMap->value, &f_status);
628    if(s==0){
629      char* fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));
630      FILE* f=fopen(footerMap->value,"rb");
631      fread(fcontent,f_status.st_size,1,f);
632      int fsize=f_status.st_size;
633      fcontent[fsize]=0;
634      fclose(f);
635      char* ffcontent=(char*)malloc((strlen(fcontent)+(3*strlen(uuid->value))+1)*sizeof(char));
636      sprintf(ffcontent,fcontent,uuid->value,uuid->value,uuid->value);
637      fprintf(scriptFile,"%s\n### --- ZOO-Service FOOTER end --- ###\n\n",ffcontent);
638      free(fcontent);
639    }else
640      fprintf(scriptFile,"### *** Default ZOO-Service FOOTER (footer file failed to load) *** ###\n\n");
641  }else
642      fprintf(scriptFile,"### *** Default ZOO-Service FOOTER (no footer found) *** ###\n\n");
643  fflush(scriptFile);
644  fclose(scriptFile);
645#ifdef HPC_DEBUG
646  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
647#endif
648  invokeCallback(m,inputs,NULL,3,1);
649#ifdef HPC_DEBUG
650  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
651#endif
652
653  // Upload the SBATCH File to the remote host
654#ifdef HPC_DEBUG
655  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
656#endif
657  invokeCallback(m,inputs,NULL,4,0);
658#ifdef HPC_DEBUG
659  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
660#endif
661  targetPathMap=getMapFromMaps(*main_conf,configurationId,"remote_work_path");
662  if(targetPathMap==NULL){
663    setMapInMaps(*main_conf,"lenv","message",_("There is no remote_work_path defined in your section!"));
664    setMapInMaps(*main_conf,"lenv","status","failed");
665    errorException (*main_conf, _("There is no remote_work_path defined in your section!"),
666                    "InternalError", NULL);
667#ifdef HPC_DEBUG
668    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
669    fflush(stderr);
670#endif
671    invokeCallback(*main_conf,NULL,NULL,7,0);
672#ifdef HPC_DEBUG
673    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
674    fflush(stderr);
675#endif
676    return SERVICE_FAILED;
677  }
678  char* targetName=strrchr(scriptPath,'/');
679  char *targetPath=(char*)malloc((strlen(targetPathMap->value)+strlen(targetName)+2)*sizeof(char));
680  sprintf(targetPath,"%s/%s",targetPathMap->value,targetName);
681  setMapInMaps(*main_conf,"lenv","remote_script",targetPath);
682  SSHCON *test=ssh_connect(*main_conf);
683  int copy0=ssh_copy(*main_conf,scriptPath,targetPath,ssh_get_cnt(*main_conf));
684  unlink(scriptPath);
685  free(scriptPath);
686  if(copy0!=true){
687    setMapInMaps(*main_conf,"lenv","message",_("Unable to upload the script"));
688    invokeCallback(*main_conf,NULL,NULL,7,0);
689    errorException(*main_conf,_("Unable to upload the script"),"NoApplicableCode",NULL);
690    return -1;
691  }
692  // Execute the SBATCH script remotely
693  addReadLocks(main_conf);
694  map* subStr=getMapFromMaps(*main_conf,configurationId,"sbatch_substr");
695  char *command=(char*)malloc((strlen(targetPath)+strlen(targetPathMap->value)+strlen(subStr->value)+strlen(uuid->value)+137)*sizeof(char));
696  sprintf(command,"sbatch %s 2> %s/error_%s.log | sed \"s:%s::g\"",targetPath,targetPathMap->value,uuid->value,subStr->value);
697  if(ssh_exec(*main_conf,command,ssh_get_cnt(m))<=0){
698    // The sbatch command has failed!
699    // Download the error log file from the HPC server
700    char tmpS[1024];
701    free(command);
702    command=(char*)malloc((strlen(targetPathMap->value)+strlen(uuid->value)+11)*sizeof(char));
703    sprintf(command,"%s/error_%s.log",targetPathMap->value,uuid->value);
704    targetName=strrchr(command,'/');
705    free(targetPath);
706    targetPath=(char*)malloc((strlen(tmpPath->value)+strlen(targetName)+2)*sizeof(char));
707    sprintf(targetPath,"%s/%s",tmpPath->value,targetName);
708    if(ssh_fetch(*main_conf,targetPath,command,ssh_get_cnt(m))==0){
709      struct stat f_status;
710      int ts=stat(targetPath, &f_status);
711      if(ts==0) {
712        char* fcontent = NULL;
713        fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));
714        FILE* f=fopen(targetPath,"rb");
715        fread(fcontent,f_status.st_size,1,f);
716        int fsize=f_status.st_size;
717        fcontent[fsize]=0;
718        fclose(f);
719        setMapInMaps(*main_conf,"lenv","message",fcontent);
720        free(fcontent);
721      }else
722        setMapInMaps(*main_conf,"lenv","message",_("No message provided"));
723    }else
724      setMapInMaps(*main_conf,"lenv","message",_("Unable to fetch the remote error log file"));
725    tmpPath=getMapFromMaps(m,"lenv","message");
726#ifdef HPC_DEBUG
727    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
728    fflush(stderr);
729#endif
730    invokeCallback(*main_conf,NULL,NULL,7,0);
731#ifdef HPC_DEBUG
732    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
733    fflush(stderr);
734#endif
735    sprintf(tmpS, "Cannot execute the HPC ZOO-Service %s using %s: %s", s->name, configurationId, tmpPath->value);
736    errorException(*main_conf,tmpS,"NoApplicableCode",NULL);
737    free(command);
738    free(targetPath);
739    ssh_close(*main_conf);
740    removeReadLocks(main_conf);
741    return -1;
742  }
743  free(targetPath);
744#ifdef HPC_DEBUG
745  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
746  fflush(stderr);
747#endif
748  invokeCallback(m,NULL,NULL,4,1);
749#ifdef HPC_DEBUG
750  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
751  fflush(stderr);
752#endif
753  free(command);
754#ifdef HPC_DEBUG
755  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
756  fflush(stderr);
757#endif
758
759  struct sockaddr_un addr;
760  memset(&addr, 0, sizeof(addr));
761  addr.sun_family = AF_UNIX;
762  int rc, cl, fd = socket(AF_UNIX, SOCK_STREAM, 0);
763  char *sname=(char*)malloc((strlen(tmpPath->value)+strlen(uuid->value)+20));
764  sprintf(sname,"%s/.wait_socket_%s.sock",tmpPath->value,uuid->value);
765  strncpy(addr.sun_path, sname, sizeof(addr.sun_path)-1);
766 
767  if (bind(fd, (struct sockaddr*)&addr, sizeof(addr)) == -1) {
768    perror("bind error");
769    setMapInMaps(*main_conf,"lenv","message",_("Unable to bind socket!"));
770    errorException (*main_conf, _("Unable to bind socket!"),
771                    "InternalError", NULL);
772#ifdef HPC_DEBUG
773    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
774    fflush(stderr);
775#endif
776    invokeCallback(*main_conf,NULL,NULL,7,0);
777    removeReadLocks(main_conf);
778#ifdef HPC_DEBUG
779    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
780    fflush(stderr);
781#endif
782    return -1;
783  }
784#ifdef HPC_DEBUG
785  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
786  fflush(stderr);
787#endif
788  if (listen(fd, 5) == -1) {
789    setMapInMaps(*main_conf,"lenv","message",_("Listen error"));
790    errorException (*main_conf, _("Listen error"),
791                    "InternalError", NULL);
792#ifdef HPC_DEBUG
793    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
794    fflush(stderr);
795#endif
796    invokeCallback(*main_conf,NULL,NULL,7,0);
797    removeReadLocks(main_conf);
798#ifdef HPC_DEBUG
799    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
800    fflush(stderr);
801#endif
802    return -1;
803  }
804  if ( (cl = accept(fd, NULL, NULL)) == -1) {
805    setMapInMaps(*main_conf,"lenv","message",_("Accept error"));
806    errorException (*main_conf, _("Accept error"),
807                    "InternalError", NULL);
808#ifdef HPC_DEBUG
809    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
810    fflush(stderr);
811#endif
812    invokeCallback(*main_conf,NULL,NULL,7,0);
813    removeReadLocks(main_conf);
814#ifdef HPC_DEBUG
815    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
816    fflush(stderr);
817#endif
818    return -1;
819  }else{
820#ifdef HPC_DEBUG
821    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
822    fflush(stderr);
823#endif
824    int hasPassed=-1;
825    char buf[11];
826    memset(&buf,0,11);
827    while ( (rc=read(cl,buf,10)) ) {     
828      if(rc==0){
829        setMapInMaps(*main_conf,"lenv","message",_("Read closed"));
830        errorException (*main_conf, _("Read closed"),
831                        "InternalError", NULL);
832#ifdef HPC_DEBUG
833        fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
834        fflush(stderr);
835#endif
836        invokeCallback(*main_conf,NULL,NULL,7,0);
837        removeReadLocks(main_conf);
838#ifdef HPC_DEBUG
839        fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
840        fflush(stderr);
841#endif
842        return -1;
843      }else{
844        if(rc<0){
845          setMapInMaps(*main_conf,"lenv","message",_("Read error"));
846          errorException (*main_conf, _("Read error"),
847                          "InternalError", NULL);
848#ifdef HPC_DEBUG
849          fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
850          fflush(stderr);
851#endif
852          invokeCallback(*main_conf,NULL,NULL,7,0);
853          removeReadLocks(main_conf);
854#ifdef HPC_DEBUG
855          fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
856          fflush(stderr);
857#endif
858          return -1;
859        }
860      }
861      hasPassed=1;
862      res=atoi(buf);
863      unlink(sname);
864      free(sname);
865      removeReadLocks(main_conf);
866 
867      if(res==3){
868#ifdef HPC_DEBUG
869        fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
870        fflush(stderr);
871#endif
872        invokeCallback(m,NULL,outputs,5,0);
873#ifdef HPC_DEBUG
874        fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
875        fflush(stderr);
876#endif
877
878        // Read informations provided by FinalizeHPC as a configuration file
879        // then, remove the file.
880        map* jobid=getMapFromMaps(*main_conf,"lenv","usid");
881        map* tmpPath=getMapFromMaps(*main_conf,"main","tmpPath");
882        char *filePath=(char*)malloc((strlen(tmpPath->value)+strlen(jobid->value)+15)*sizeof(char));
883        sprintf(filePath,"%s/exec_status_%s",tmpPath->value,jobid->value);
884        maps* m = (maps *) malloc (MAPS_SIZE);
885        m->child=NULL;
886        m->next=NULL;
887        int saved_stdout = dup (fileno (stdout));
888        dup2 (fileno (stderr), fileno (stdout));
889        conf_read(filePath,m);
890        fflush(stdout);
891        dup2 (saved_stdout, fileno (stdout));
892        close(saved_stdout);
893        unlink(filePath);
894        free(filePath);
895        addMapsToMaps(main_conf,m);
896        freeMaps(&m);
897        free(m);
898
899        input=*real_outputs;
900        while(input!=NULL){
901          if(input->child==NULL){
902            map* generatedFile=getMap(input->content,"generated_file");
903            if(generatedFile!=NULL){
904              char* filename=strrchr(generatedFile->value,'/');
905              char* targetPath=(char*)malloc((strlen(tmpPath->value)+strlen(filename)+2)*sizeof(char));
906              sprintf(targetPath,"%s/%s",tmpPath->value,filename);
907              test=ssh_connect(*main_conf);
908              if(ssh_fetch(*main_conf,targetPath,generatedFile->value,ssh_get_cnt(m))==0){
909                setMapInMaps(*real_outputs,input->name,"generated_file",targetPath);
910                free(targetPath);
911              }else{
912                map* hpcStdErr=getMapFromMaps(*main_conf,"henv","StdErr");
913                if(hpcStdErr!=NULL && ssh_fetch(*main_conf,targetPath,hpcStdErr->value,ssh_get_cnt(m))==0){
914                  struct stat f_status;
915                  int ts=stat(targetPath, &f_status);
916                  if(ts==0) {
917                    char* fcontent = NULL;
918                    fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));
919                    FILE* f=fopen(targetPath,"rb");
920                    fread(fcontent,f_status.st_size,1,f);
921                    int fsize=f_status.st_size;
922                    fcontent[fsize]=0;
923                    fclose(f);
924                    setMapInMaps(*main_conf,"lenv","message",fcontent);
925                    free(fcontent);
926                  }else{
927                    char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char));
928                    sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename);
929                    setMapInMaps(*main_conf,"lenv","message",tmpStr);
930                    free(tmpStr);
931                  }
932                }else{
933                  char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char));
934                  sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename);
935                  setMapInMaps(*main_conf,"lenv","message",tmpStr);
936                  free(tmpStr);
937                }
938                invokeCallback(*main_conf,NULL,NULL,7,0);
939                return SERVICE_FAILED;
940              }
941            }       
942          }else{
943            map* generatedFile=getMap(input->content,"generated_file");
944            map* generatedUrl=getMap(input->content,"generated_url");
945            if(generatedFile!=NULL){
946              char* filename=strrchr(generatedFile->value,'/');
947              char* targetPath=(char*)malloc((strlen(tmpPath->value)+strlen(filename)+2)*sizeof(char));
948              sprintf(targetPath,"%s/%s",tmpPath->value,filename);
949              test=ssh_connect(*main_conf);
950              if(ssh_fetch(*main_conf,targetPath,generatedFile->value,ssh_get_cnt(m))==0){
951                maps* tmp=getMaps(*real_outputs,input->name);
952                char serviceName[9];
953                freeMap(&tmp->content);
954                free(tmp->content);
955                tmp->content=NULL;
956                maps* output=getMaps(*real_outputs,input->name);
957                setMapInMaps(output->child,"download_link","generated_file",targetPath);
958                setMapInMaps(output->child,"download_link","generated_url",generatedUrl->value);
959                setMapInMaps(output->child,"download_link","storage",targetPath);
960                setMapInMaps(output->child,"download_link","useMapserver","false");
961                setMapInMaps(output->child,"download_link","replicateStorageNext","true");
962                setMapInMaps(output->child,"download_link","asReference","true");
963                setMapInMaps(output->child,"download_link","inRequest","true");
964                setMapInMaps(output->child,"wms_link","generated_file",targetPath);
965                setMapInMaps(output->child,"wms_link","storage",targetPath);
966                setMapInMaps(output->child,"wms_link","useMapserver","true");
967                setMapInMaps(output->child,"wms_link","msOgc","WMS");
968                setMapInMaps(output->child,"wms_link","requestedMimeType","image/png");
969                setMapInMaps(output->child,"wms_link","asReference","true");
970                if(getMaps(output->child,"wcs_link")!=NULL){
971                  sprintf(serviceName,"wcs_link");
972                  setMapInMaps(output->child,"wcs_link","msOgc","WCS");
973                }else{
974                  sprintf(serviceName,"wfs_link");
975                  setMapInMaps(output->child,"wfs_link","msOgc","WFS");
976                }
977                setMapInMaps(output->child,serviceName,"storage",targetPath);
978                setMapInMaps(output->child,serviceName,"generated_file",targetPath);
979                setMapInMaps(output->child,serviceName,"useMapserver","true");
980                setMapInMaps(output->child,serviceName,"asReference","true");
981              }else{
982                map* hpcStdErr=getMapFromMaps(*main_conf,"henv","StdErr");
983                if(hpcStdErr!=NULL && ssh_fetch(*main_conf,targetPath,hpcStdErr->value,ssh_get_cnt(m))==0){
984                  struct stat f_status;
985                  int ts=stat(targetPath, &f_status);
986                  if(ts==0) {
987                    char* fcontent = NULL;
988                    fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1));
989                    FILE* f=fopen(targetPath,"rb");
990                    fread(fcontent,f_status.st_size,1,f);
991                    int fsize=f_status.st_size;
992                    fcontent[fsize]=0;
993                    fclose(f);
994                    setMapInMaps(*main_conf,"lenv","message",fcontent);
995                    free(fcontent);
996                  }else{
997                    char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char));
998                    sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename);
999                    setMapInMaps(*main_conf,"lenv","message",tmpStr);
1000                    free(tmpStr);
1001                  }
1002                }else{
1003                  char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char));
1004                  sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename);
1005                  setMapInMaps(*main_conf,"lenv","message",tmpStr);
1006                  free(tmpStr);
1007                }
1008                invokeCallback(*main_conf,NULL,NULL,7,0);
1009                return SERVICE_FAILED;
1010              }
1011              free(targetPath);
1012            }
1013          }
1014          input=input->next;
1015        }
1016
1017      }else{
1018        // Try to access remotely to the log file and return a more relevant error message
1019        setMapInMaps(*main_conf,"lenv","message",_("HPC Execution failed!"));
1020        errorException (*main_conf, _("HPC Execution failed!"),
1021                        "InternalError", NULL);
1022#ifdef HPC_DEBUG
1023        fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
1024        fflush(stderr);
1025#endif
1026        invokeCallback(*main_conf,NULL,NULL,7,0);
1027#ifdef HPC_DEBUG
1028        fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
1029        fflush(stderr);
1030#endif
1031      }
1032    }
1033    if(hasPassed<0){
1034      perror("Failed to read");
1035      setMapInMaps(*main_conf,"lenv","message",_("Unable to parse the value returned by remote execution"));
1036      errorException (*main_conf, _("Unable to parse the value returned by remote execution"),
1037                      "InternalError", NULL);
1038#ifdef HPC_DEBUG
1039      fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
1040      fflush(stderr);
1041#endif
1042      invokeCallback(*main_conf,NULL,NULL,7,0);
1043#ifdef HPC_DEBUG
1044      fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
1045      fflush(stderr);
1046#endif
1047      return SERVICE_FAILED;
1048    }
1049  }
1050#ifdef HPC_DEBUG
1051  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
1052  fflush(stderr);
1053#endif
1054  ssh_close(*main_conf);
1055#ifdef HPC_DEBUG
1056  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
1057  fflush(stderr);
1058#endif
1059  return res;
1060}
Note: See TracBrowser for help on using the repository browser.

Search

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png