Ignore:
Timestamp:
Nov 21, 2017, 10:24:14 AM (6 years ago)
Author:
djay
Message:

HPC support update. Add inputs for create options in Gdal_Dem.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal_hpc.c

    r851 r854  
    144144        if(cur->defaults!=NULL){
    145145          freeIOType(&cur->defaults);
     146          free(cur->defaults);
    146147          cur->defaults=NULL;
    147148        }
    148149        if(cur->supported!=NULL){
    149150          freeIOType(&cur->supported);
     151          free(cur->supported);
    150152          cur->supported=NULL;
    151153        }
     
    162164  }
    163165  //dumpElements((*s)->outputs);
     166}
     167
     168/**
     169 * Acquire a read lock on every files used as input for executing a service.
     170 * @param conf the main configuration file map
     171 * @return 0 if every file can be locked, -1 if one lock has failed.
     172 */
     173int addReadLocks(maps** conf){
     174  map* queueLengthMap=getMapFromMaps(*conf,"uploadQueue","length");
     175  maps* queueMaps=getMaps(*conf,"uploadQueue");
     176  if(queueLengthMap!=NULL){
     177    int cnt=atoi(queueLengthMap->value);
     178    int i=0;
     179    for(i=0;i<cnt;i++){
     180      map* argv[2]={
     181        getMapArray(queueMaps->content,"input",i),
     182        getMapArray(queueMaps->content,"localPath",i)
     183      };
     184      zooLock* lck;
     185      if((lck=lockFile(*conf,argv[1]->value,'r'))==NULL){
     186        char* templateStr=_("Unable to lock the file for %s in read mode.");
     187        char *tmpMessage=(char*)malloc((strlen(templateStr)+strlen(argv[0]->value)+1)*sizeof(char));
     188        sprintf(tmpMessage,templateStr,argv[0]->value);
     189        setMapInMaps(*conf,"lenv","message",tmpMessage);
     190        free(tmpMessage);
     191        return -1;
     192      }else{
     193        if(zoo_file_locks_cnt==0){
     194          zoo_file_locks=(zooLock**)malloc(sizeof(zooLock*));
     195        }
     196        else{
     197          zoo_file_locks=(zooLock**)realloc(zoo_file_locks,(zoo_file_locks_cnt+1)*sizeof(zooLock*));
     198        }
     199        zoo_file_locks[zoo_file_locks_cnt]=lck;
     200        zoo_file_locks_cnt++;
     201      }
     202    }
     203  }
     204  return 0;
     205}
     206
     207/**
     208 * Remove all read locks set for files used as input for executing the service.
     209 * @param conf the main configuration maps pointer
     210 * @return 0 in case of success, -1 if any error occured. In case of error, one
     211 * can refer to the message map array from the lenv section.
     212 */
     213int removeReadLocks(maps** conf){
     214  int res=0;
     215  int nberr=0;
     216  map* queueLengthMap=getMapFromMaps(*conf,"uploadQueue","length");
     217  maps* queueMaps=getMaps(*conf,"uploadQueue");
     218  if(queueLengthMap!=NULL){
     219    int cnt=atoi(queueLengthMap->value);
     220    int i=0;
     221    for(i=0;i<cnt;i++){
     222      if(unlockFile(*conf,zoo_file_locks[i])<1){
     223        map* argv=getMapArray(queueMaps->content,"input",i);
     224        char* templateStr=_("Unable to unlock the file for %s after execution.");
     225        char *tmpMessage=(char*)malloc((strlen(templateStr)+strlen(argv->value)+1)*sizeof(char));
     226        sprintf(tmpMessage,templateStr,argv->value);
     227        maps* lenv=getMaps(*conf,"lenv");
     228        setMapArray(lenv->content,"message",nberr,tmpMessage);
     229        free(tmpMessage);
     230        res=-1;
     231        nberr++;
     232      }
     233    }
     234  }
     235  free(zoo_file_locks);
     236  return res;
     237}
     238
     239/**
     240 * Get the section name depending on number of features and/or pixels of each
     241 * inputs and the threshold defined in a section.
     242 * It supposes that your inputs has been published using MapServer support,
     243 * implying that the number of features (nb_features), respectively pixels
     244 * (nb_pixels), are defined. The section, identified by confId, should contain
     245 * preview_max_features and preview_max_pixels defining the threshold values.
     246 * @param conf the main configuration file maps pointer
     247 * @param inputs the inputs maps pointer
     248 * @param confId the section identifier
     249 * @return "preview_conf" in case the numbers are lower than the threshold,
     250 * "fullres_conf" in other cases.
     251 */
     252char* getConfiguration(maps** conf,maps** inputs,const char* confId){
     253  maps* input=*inputs;
     254  map* max_pixels=getMapFromMaps(*conf,confId,"preview_max_pixels");
     255  map* max_features=getMapFromMaps(*conf,confId,"preview_max_features");
     256  int i_max_pixels=atoi(max_pixels->value);
     257  int i_max_features=atoi(max_features->value);
     258  while(input!=NULL && input->content!=NULL){
     259    map* tmpMap=getMap(input->content,"geodatatype");
     260    if(tmpMap!=NULL){
     261      map* currentNb;
     262      if(strcasecmp(tmpMap->value,"raster")==0 ){
     263        currentNb=getMap(input->content,"nb_pixels");
     264        if(atoi(currentNb->value)>i_max_pixels)
     265          return "fullres_conf";
     266      }else{
     267        if(strcasecmp(tmpMap->value,"vector")==0 ){
     268          currentNb=getMap(input->content,"nb_features");
     269          if(atoi(currentNb->value)>i_max_features)
     270            return "fullres_conf";
     271        }
     272      }
     273    }
     274    input=input->next;
     275  }
     276  return "preview_conf";
    164277}
    165278
     
    181294  map* tmp=NULL;
    182295  int res=-1;
     296  // Get the configuration id depending on service type and defined thresholds
     297  // then, set the configId key in the lenv section
    183298  char *serviceType;
    184299  map* mServiceType=getMap(s->content,"serviceType");
     
    187302  else
    188303    serviceType="HPC";
    189   map* targetPathMap=getMapFromMaps(*main_conf,serviceType,"storagePath");
    190304  map* tmpPath=getMapFromMaps(*main_conf,"main","tmpPath");
    191305  map* uuid=getMapFromMaps(*main_conf,"lenv","usid");
     306  map* confMap=getMapFromMaps(*main_conf,serviceType,getConfiguration(main_conf,real_inputs,serviceType));
     307  char * configurationId=confMap->value;
     308  setMapInMaps(*main_conf,"lenv","configId",configurationId);
     309  // Dump lenv maps again after having set the configId ...
     310  char *flenv =
     311    (char *)
     312    malloc ((strlen (tmpPath->value) +
     313             strlen (uuid->value) + 12) * sizeof (char));
     314  sprintf (flenv, "%s/%s_lenv.cfg", tmpPath->value, uuid->value);
     315  maps* lenvMaps=getMaps(m,"lenv");
     316  dumpMapsToFile(lenvMaps,flenv,0);
     317  free(flenv);
     318
     319  map* targetPathMap=getMapFromMaps(*main_conf,configurationId,"remote_data_path");
     320 
    192321  pthread_t threads_pool[50];
    193322  // Force the HPC services to be called asynchronously
     
    215344          dumpMapsValuesToFiles(main_conf,&input);
    216345          addToMap(input->content,"toPublish","true");
     346          addToMap(input->content,"useMapserver","true");
    217347        }
    218348        if(getMap(input->content,"cache_file")!=NULL){
     
    264394  invokeCallback(m,inputs,NULL,2,0);
    265395  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     396  dumpMaps(inputs);
     397  if(getMapFromMaps(m,"lenv","mapError")!=NULL){
     398    invokeCallback(m,inputs,NULL,7,0);
     399    return -1;
     400  }
    266401
    267402  // Upload data on HPC
    268   runUpload(main_conf);
    269  
     403  if(runUpload(main_conf)==false){
     404    errorException (m, _("Unable to lock the file for upload!"),
     405                    "InternalError", NULL);
     406    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     407    invokeCallback(m,inputs,NULL,7,0);
     408    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     409    return -1;
     410  }
    270411  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    271412  invokeCallback(m,inputs,NULL,2,1);
    272413  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    273414
    274   // Add the filename to generate for every output to the parameters
     415  // Add the filename to generate for every output to parameters
    275416  input=*real_outputs;
    276417  // TODO: fix appendOutputParameters
    277418  //appendOutputParameters(input,parameters,&parameters_cnt,s,uuid,targetPathMap);
     419  dumpMaps(input);
    278420  while(input!=NULL){
    279421    // TODO: parse all outputs including inner outputs if required.
    280422    if(input->child==NULL){
    281       parameters_cnt+=1;
    282       if(parameters_cnt==1)
    283         parameters=(char**)malloc(parameters_cnt*sizeof(char*));
    284       else
    285         parameters=(char**)realloc(parameters,parameters_cnt*sizeof(char*));
    286423      // Name every files that should be produced by the service execution
    287424      map* mime=getMap(input->content,"mimeType");
     
    302439      free(targetName);
    303440      setMapInMaps(*real_outputs,input->name,"generated_file",targetPath);
    304       // We should verify if any optional tag for output is required
    305       // (i.e. -out output.tiff *int8*), meaning that we should search
    306       // for a corresponding inputs name.
    307       map* inValue=getMapFromMaps(*real_inputs,input->name,"value");
    308       if(inValue!=NULL){
    309         parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+strlen(inValue->value)+4)*sizeof(char));
    310         sprintf(parameters[parameters_cnt-1],"-%s %s %s",input->name,targetPath,inValue->value);
    311       }else{
    312         parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+3)*sizeof(char));
    313         sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,targetPath);
     441      if(strcasecmp(input->name,"wms_link")!=0&&
     442         strcasecmp(input->name,"wcs_link")!=0 &&
     443         strcasecmp(input->name,"wfs_link")!=0){
     444        parameters_cnt+=1;
     445        if(parameters_cnt==1)
     446          parameters=(char**)malloc(parameters_cnt*sizeof(char*));
     447        else
     448          parameters=(char**)realloc(parameters,parameters_cnt*sizeof(char*));
     449        // We should verify if any optional tag for output is required
     450        // (i.e. -out output.tiff *int8*), meaning that we should search
     451        // for a corresponding inputs name.
     452        map* inValue=getMapFromMaps(*real_inputs,input->name,"value");
     453        if(inValue!=NULL){
     454          parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+strlen(inValue->value)+4)*sizeof(char));
     455          sprintf(parameters[parameters_cnt-1],"-%s %s %s",input->name,targetPath,inValue->value);
     456        }else{
     457          parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+3)*sizeof(char));
     458          sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,targetPath);
     459        }
    314460      }
    315461      free(targetPath);
    316462    }// In other case it means we need to return the cache_file as generated_file
    317463    else{
    318       parameters_cnt+=1;
    319       if(parameters_cnt==1)
    320         parameters=(char**)malloc(parameters_cnt*sizeof(char*));
    321       else
    322         parameters=(char**)realloc(parameters,parameters_cnt*sizeof(char*));
    323464      // Name every files that should be produced by the service execution
    324465      map* mime=getMap(input->child->content,"mimeType");
     
    339480      free(targetName);
    340481      addToMap(input->content,"generated_file",targetPath);
    341       // We should verify if any optional tag for output is required
    342       // (i.e. -out output.tiff *int8*), meaning that we should search
    343       // for a corresponding inputs name.
    344       map* inValue=getMapFromMaps(*real_inputs,input->name,"value");
    345       if(inValue!=NULL){
    346         parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+strlen(inValue->value)+4)*sizeof(char));
    347         sprintf(parameters[parameters_cnt-1],"-%s %s %s",input->name,targetPath,inValue->value);
    348       }else{
    349         parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+3)*sizeof(char));
    350         sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,targetPath);
     482      addToMap(input->content,"storage",targetPath);
     483      if(strcasecmp(input->name,"wms_link")!=0&&
     484         strcasecmp(input->name,"wcs_link")!=0 &&
     485         strcasecmp(input->name,"wfs_link")!=0){
     486        parameters_cnt+=1;
     487        if(parameters_cnt==1)
     488          parameters=(char**)malloc(parameters_cnt*sizeof(char*));
     489        else
     490          parameters=(char**)realloc(parameters,parameters_cnt*sizeof(char*));
     491        // We should verify if any optional tag for output is required
     492        // (i.e. -out output.tiff *int8*), meaning that we should search
     493        // for a corresponding inputs name.
     494        map* inValue=getMapFromMaps(*real_inputs,input->name,"value");
     495        if(inValue!=NULL){
     496          parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+strlen(inValue->value)+4)*sizeof(char));
     497          sprintf(parameters[parameters_cnt-1],"-%s %s %s",input->name,targetPath,inValue->value);
     498        }else{
     499          parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(targetPath)+3)*sizeof(char));
     500          sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,targetPath);
     501        }
    351502      }
    352503      free(targetPath);
     
    354505    input=input->next;
    355506  }
    356  
    357507  // Produce the SBATCH File locally
    358508  char *scriptPath=(char*)malloc((strlen(s->name)+strlen(tmpPath->value)+strlen(uuid->value)+10)*sizeof(char));
     
    365515  fflush(stderr);
    366516  FILE* scriptFile=fopen(scriptPath,"w+");
    367   map* headerMap=getMapFromMaps(*main_conf,serviceType,"header");
     517  map* headerMap=getMapFromMaps(*main_conf,configurationId,"jobscript_header");
    368518  if(headerMap!=NULL){
    369519    // Use the header file if defined in the HPC section of the main.cfg file
     
    383533  }else
    384534    fprintf(scriptFile,"#!/bin/bash\n\n### *** Default ZOO-Service HEADER *** ###\n\n");
    385   maps* hpc_opts=getMaps(*main_conf,"sbatch_options");
     535  maps* hpc_opts=getMaps(*main_conf,configurationId);
    386536  if(hpc_opts!=NULL){
    387537    map* hpc_opts_content=hpc_opts->content;
    388538    while(hpc_opts_content!=NULL){
    389       fprintf(scriptFile,"#SBATCH --%s=%s\n",hpc_opts_content->name,hpc_opts_content->value);
     539      if(strncasecmp(hpc_opts_content->name,"sbatch_options_",15)==0)
     540        fprintf(scriptFile,"#SBATCH --%s=%s\n",strstr(hpc_opts_content->name,"sbatch_options_")+15,hpc_opts_content->value);
    390541      hpc_opts_content=hpc_opts_content->next;
    391542    }
     
    396547    fprintf(scriptFile,"#SBATCH --export=MODULES=%s\n",mods->value);
    397548
    398   map* bodyMap=getMapFromMaps(*main_conf,serviceType,"body");
     549  map* bodyMap=getMapFromMaps(*main_conf,configurationId,"jobscript_body");
    399550  if(bodyMap!=NULL){
    400551    // Use the header file if defined in the HPC section of the main.cfg file
     
    415566    fprintf(scriptFile,"#!/bin/bash\n\n### *** Default ZOO-Service BODY *** ###\n\n");
    416567
    417  
    418568  map* sp=getMap(s->content,"serviceProvider");
    419569 
     
    433583  fflush(scriptFile);
    434584  fclose(scriptFile);
    435  
    436585  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    437586  invokeCallback(m,inputs,NULL,3,1);
     
    442591  invokeCallback(m,inputs,NULL,4,0);
    443592  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    444   targetPathMap=getMapFromMaps(*main_conf,serviceType,"executePath");
     593  targetPathMap=getMapFromMaps(*main_conf,configurationId,"remote_work_path");
    445594  if(targetPathMap==NULL){
    446     setMapInMaps(*main_conf,"lenv","message",_("There is no executePath defined in you HPC section!"));
     595    setMapInMaps(*main_conf,"lenv","message",_("There is no remote_work_path defined in your section!"));
     596    setMapInMaps(*main_conf,"lenv","status","failed");
     597    errorException (m, _("There is no remote_work_path defined in your section!"),
     598                    "InternalError", NULL);
     599    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     600    fflush(stderr);
     601    invokeCallback(m,NULL,NULL,7,0);
     602    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     603    fflush(stderr);
    447604    return SERVICE_FAILED;
    448605  }
     
    453610  SSHCON *test=ssh_connect(*main_conf);
    454611  ssh_copy(*main_conf,scriptPath,targetPath,ssh_get_cnt(*main_conf));
    455  
     612  unlink(scriptPath);
     613  free(scriptPath);
    456614  // Execute the SBATCH script remotely
    457   map* subStr=getMapFromMaps(*main_conf,"HPC","subStr");
     615  addReadLocks(main_conf);
     616  map* subStr=getMapFromMaps(*main_conf,configurationId,"sbatch_substr");
    458617  char *command=(char*)malloc((strlen(targetPath)+strlen(targetPathMap->value)+strlen(subStr->value)+strlen(uuid->value)+137)*sizeof(char));
    459618  sprintf(command,"sbatch %s 2> %s/error_%s.log | sed \"s:%s::g\"",targetPath,targetPathMap->value,uuid->value,subStr->value);
     
    489648    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    490649    fflush(stderr);
    491     invokeCallback(m,NULL,NULL,7,1);
     650    invokeCallback(m,NULL,NULL,7,0);
    492651    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
    493652    fflush(stderr);
     
    497656    free(targetPath);
    498657    ssh_close(*main_conf);
    499     sleep(120);
     658    sleep(1);
    500659    return -1;
    501660  }
     
    507666  fflush(stderr);
    508667  free(command);
     668  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     669  fflush(stderr);
    509670
    510671  struct sockaddr_un addr;
     672  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     673  fflush(stderr);
    511674  memset(&addr, 0, sizeof(addr));
     675  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     676  fflush(stderr);
    512677  addr.sun_family = AF_UNIX;
     678  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     679  fflush(stderr);
    513680  int rc, cl, fd = socket(AF_UNIX, SOCK_STREAM, 0);
     681  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     682  fflush(stderr);
    514683  char *sname=(char*)malloc((strlen(tmpPath->value)+strlen(uuid->value)+20));
     684  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     685  fflush(stderr);
    515686  sprintf(sname,"%s/.wait_socket_%s.sock",tmpPath->value,uuid->value);
     687  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     688  fflush(stderr);
    516689  strncpy(addr.sun_path, sname, sizeof(addr.sun_path)-1);
     690  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     691  fflush(stderr);
    517692 
    518693  if (bind(fd, (struct sockaddr*)&addr, sizeof(addr)) == -1) {
    519694    perror("bind error");
     695    setMapInMaps(m,"lenv","message",_("Unable to bind socket!"));
     696    errorException (m, _("Unable to bind socket!"),
     697                    "InternalError", NULL);
     698    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     699    fflush(stderr);
     700    invokeCallback(m,NULL,NULL,7,0);
     701    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     702    fflush(stderr);
    520703    sleep(120);
    521704    return -1;
    522705  }
     706  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     707  fflush(stderr);
    523708  if (listen(fd, 5) == -1) {
    524709    setMapInMaps(*main_conf,"lenv","message",_("Listen error"));
     710    errorException (m, _("Listen error"),
     711                    "InternalError", NULL);
     712    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     713    fflush(stderr);
     714    invokeCallback(m,NULL,NULL,7,0);
     715    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     716    fflush(stderr);
    525717    return -1;
    526718  }
     719  fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     720  fflush(stderr);
    527721  if ( (cl = accept(fd, NULL, NULL)) == -1) {
    528722    setMapInMaps(*main_conf,"lenv","message",_("Accept error"));
     723    errorException (m, _("Accept error"),
     724                    "InternalError", NULL);
     725    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     726    fflush(stderr);
     727    invokeCallback(m,NULL,NULL,7,0);
     728    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     729    fflush(stderr);
    529730    return -1;
    530731  }else{
     732    fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     733    fflush(stderr);
    531734    int hasPassed=-1;
    532735    char buf[11];
     
    536739        sleep(1);
    537740        setMapInMaps(*main_conf,"lenv","message",_("Read closed"));
    538         invokeCallback(m,NULL,NULL,7,1);
     741        errorException (m, _("Read closed"),
     742                        "InternalError", NULL);
     743        fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     744        fflush(stderr);
     745        invokeCallback(m,NULL,NULL,7,0);
     746        fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     747        fflush(stderr);
    539748        return -1;
    540749      }else{
    541750        if(rc<0){
    542751          setMapInMaps(*main_conf,"lenv","message",_("Read error"));
    543           invokeCallback(m,NULL,NULL,7,1);
     752          errorException (m, _("Read error"),
     753                          "InternalError", NULL);
     754          fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     755          fflush(stderr);
     756          invokeCallback(m,NULL,NULL,7,0);
     757          fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     758          fflush(stderr);
    544759          return -1;
    545760        }
    546761      }
    547762      hasPassed=1;
     763      fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     764      fflush(stderr);
    548765      res=atoi(buf);
     766      fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     767      fflush(stderr);
    549768      unlink(sname);
    550       //free(sname);
    551 
     769      fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     770      fflush(stderr);
     771      free(sname);
     772      fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     773      fflush(stderr);
     774      removeReadLocks(main_conf);
     775      fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     776      fflush(stderr);
     777 
    552778      if(res==3){
    553779        fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     
    573799                setMapInMaps(*main_conf,"lenv","message",tmpStr);
    574800                free(tmpStr);
     801                invokeCallback(m,NULL,NULL,7,0);
    575802                return SERVICE_FAILED;
    576803              }
     
    587814              if(ssh_fetch(*main_conf,targetPath,generatedFile->value,ssh_get_cnt(m))==0){
    588815                maps* tmp=getMaps(*real_outputs,input->name);
     816                char serviceName[9];
    589817                freeMap(&tmp->content);
    590818                free(tmp->content);
     
    592820                maps* output=getMaps(*real_outputs,input->name);
    593821                setMapInMaps(output->child,"download_link","generated_file",targetPath);
     822                setMapInMaps(output->child,"download_link","storage",targetPath);
    594823                setMapInMaps(output->child,"download_link","useMapserver","false");
     824                setMapInMaps(output->child,"download_link","replicateStorageNext","true");
     825                setMapInMaps(output->child,"download_link","asReference","true");
     826                setMapInMaps(output->child,"download_link","inRequest","true");
    595827                setMapInMaps(output->child,"wms_link","generated_file",targetPath);
     828                setMapInMaps(output->child,"wms_link","storage",targetPath);
    596829                setMapInMaps(output->child,"wms_link","useMapserver","true");
    597830                setMapInMaps(output->child,"wms_link","msOgc","WMS");
    598831                setMapInMaps(output->child,"wms_link","requestedMimeType","image/png");
    599                 setMapInMaps(output->child,"wcs_link","generated_file",targetPath);
    600                 setMapInMaps(output->child,"wcs_link","useMapserver","true");
     832                setMapInMaps(output->child,"wms_link","asReference","true");
     833                if(getMaps(output->child,"wcs_link")!=NULL){
     834                  sprintf(serviceName,"wcs_link");
     835                  setMapInMaps(output->child,serviceName,"msOgc","WCS");
     836                }
     837                else{
     838                  sprintf(serviceName,"wfs_link");
     839                  setMapInMaps(output->child,serviceName,"msOgc","WFS");
     840                }
     841                setMapInMaps(output->child,serviceName,"storage",targetPath);
     842                setMapInMaps(output->child,serviceName,"generated_file",targetPath);
     843                setMapInMaps(output->child,serviceName,"useMapserver","true");
     844                setMapInMaps(output->child,serviceName,"asReference","true");
     845              }else{
     846                char *tmpStr=(char*)malloc((strlen(filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char));
     847                sprintf(tmpStr,_("Unable to fetch the remote file for %s"),filename);
     848                setMapInMaps(*main_conf,"lenv","message",tmpStr);
     849                free(tmpStr);
     850                invokeCallback(m,NULL,NULL,7,0);
     851                return SERVICE_FAILED;
    601852              }
    602853              free(targetPath);
     
    605856          input=input->next;
    606857        }
     858
     859        // Read informations provided by FinalizeHPC as a configuration file
     860        // then, remove the file.
     861        map* jobid=getMapFromMaps(*main_conf,"lenv","usid");
     862        map* tmpPath=getMapFromMaps(*main_conf,"main","tmpPath");
     863        char *filePath=(char*)malloc((strlen(tmpPath->value)+strlen(jobid->value)+15)*sizeof(char));
     864        sprintf(filePath,"%s/exec_status_%s",tmpPath->value,jobid->value);
     865        maps* m = (maps *) malloc (MAPS_SIZE);
     866        m->child=NULL;
     867        m->next=NULL;
     868        int saved_stdout = dup (fileno (stdout));
     869        dup2 (fileno (stderr), fileno (stdout));
     870        conf_read(filePath,m);
     871        fflush(stdout);
     872        dup2 (saved_stdout, fileno (stdout));
     873        close(saved_stdout);
     874        unlink(filePath);
     875        free(filePath);
     876        addMapsToMaps(main_conf,m);
     877        freeMaps(&m);
     878        free(m);
     879      }else{
     880        // Try to access remotely to the log file and return a more relevant error message
     881        setMapInMaps(m,"lenv","message",_("HPC Execution failed!"));
     882        errorException (m, _("HPC Execution failed!"),
     883                        "InternalError", NULL);
     884        fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     885        fflush(stderr);
     886        invokeCallback(m,NULL,NULL,7,0);
     887        fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     888        fflush(stderr);
    607889      }
    608890      //free(buf);
     
    611893      perror("Failed to read");
    612894      setMapInMaps(*main_conf,"lenv","message",_("Unable to parse the value returned by remote execution"));
     895      errorException (m, _("Unable to parse the value returned by remote execution"),
     896                      "InternalError", NULL);
     897      fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     898      fflush(stderr);
     899      invokeCallback(m,NULL,NULL,7,0);
     900      fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__);
     901      fflush(stderr);
    613902      sleep(120);
    614903      return SERVICE_FAILED;
     
    622911  return res;
    623912}
    624 
    625    
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

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