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