- Timestamp:
- Nov 21, 2017, 10:24:14 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_hpc.c
r851 r854 144 144 if(cur->defaults!=NULL){ 145 145 freeIOType(&cur->defaults); 146 free(cur->defaults); 146 147 cur->defaults=NULL; 147 148 } 148 149 if(cur->supported!=NULL){ 149 150 freeIOType(&cur->supported); 151 free(cur->supported); 150 152 cur->supported=NULL; 151 153 } … … 162 164 } 163 165 //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 */ 173 int 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 */ 213 int 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 */ 252 char* 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"; 164 277 } 165 278 … … 181 294 map* tmp=NULL; 182 295 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 183 298 char *serviceType; 184 299 map* mServiceType=getMap(s->content,"serviceType"); … … 187 302 else 188 303 serviceType="HPC"; 189 map* targetPathMap=getMapFromMaps(*main_conf,serviceType,"storagePath");190 304 map* tmpPath=getMapFromMaps(*main_conf,"main","tmpPath"); 191 305 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 192 321 pthread_t threads_pool[50]; 193 322 // Force the HPC services to be called asynchronously … … 215 344 dumpMapsValuesToFiles(main_conf,&input); 216 345 addToMap(input->content,"toPublish","true"); 346 addToMap(input->content,"useMapserver","true"); 217 347 } 218 348 if(getMap(input->content,"cache_file")!=NULL){ … … 264 394 invokeCallback(m,inputs,NULL,2,0); 265 395 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 } 266 401 267 402 // 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 } 270 411 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 271 412 invokeCallback(m,inputs,NULL,2,1); 272 413 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 273 414 274 // Add the filename to generate for every output to theparameters415 // Add the filename to generate for every output to parameters 275 416 input=*real_outputs; 276 417 // TODO: fix appendOutputParameters 277 418 //appendOutputParameters(input,parameters,¶meters_cnt,s,uuid,targetPathMap); 419 dumpMaps(input); 278 420 while(input!=NULL){ 279 421 // TODO: parse all outputs including inner outputs if required. 280 422 if(input->child==NULL){ 281 parameters_cnt+=1;282 if(parameters_cnt==1)283 parameters=(char**)malloc(parameters_cnt*sizeof(char*));284 else285 parameters=(char**)realloc(parameters,parameters_cnt*sizeof(char*));286 423 // Name every files that should be produced by the service execution 287 424 map* mime=getMap(input->content,"mimeType"); … … 302 439 free(targetName); 303 440 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 } 314 460 } 315 461 free(targetPath); 316 462 }// In other case it means we need to return the cache_file as generated_file 317 463 else{ 318 parameters_cnt+=1;319 if(parameters_cnt==1)320 parameters=(char**)malloc(parameters_cnt*sizeof(char*));321 else322 parameters=(char**)realloc(parameters,parameters_cnt*sizeof(char*));323 464 // Name every files that should be produced by the service execution 324 465 map* mime=getMap(input->child->content,"mimeType"); … … 339 480 free(targetName); 340 481 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 } 351 502 } 352 503 free(targetPath); … … 354 505 input=input->next; 355 506 } 356 357 507 // Produce the SBATCH File locally 358 508 char *scriptPath=(char*)malloc((strlen(s->name)+strlen(tmpPath->value)+strlen(uuid->value)+10)*sizeof(char)); … … 365 515 fflush(stderr); 366 516 FILE* scriptFile=fopen(scriptPath,"w+"); 367 map* headerMap=getMapFromMaps(*main_conf, serviceType,"header");517 map* headerMap=getMapFromMaps(*main_conf,configurationId,"jobscript_header"); 368 518 if(headerMap!=NULL){ 369 519 // Use the header file if defined in the HPC section of the main.cfg file … … 383 533 }else 384 534 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); 386 536 if(hpc_opts!=NULL){ 387 537 map* hpc_opts_content=hpc_opts->content; 388 538 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); 390 541 hpc_opts_content=hpc_opts_content->next; 391 542 } … … 396 547 fprintf(scriptFile,"#SBATCH --export=MODULES=%s\n",mods->value); 397 548 398 map* bodyMap=getMapFromMaps(*main_conf, serviceType,"body");549 map* bodyMap=getMapFromMaps(*main_conf,configurationId,"jobscript_body"); 399 550 if(bodyMap!=NULL){ 400 551 // Use the header file if defined in the HPC section of the main.cfg file … … 415 566 fprintf(scriptFile,"#!/bin/bash\n\n### *** Default ZOO-Service BODY *** ###\n\n"); 416 567 417 418 568 map* sp=getMap(s->content,"serviceProvider"); 419 569 … … 433 583 fflush(scriptFile); 434 584 fclose(scriptFile); 435 436 585 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 437 586 invokeCallback(m,inputs,NULL,3,1); … … 442 591 invokeCallback(m,inputs,NULL,4,0); 443 592 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 444 targetPathMap=getMapFromMaps(*main_conf, serviceType,"executePath");593 targetPathMap=getMapFromMaps(*main_conf,configurationId,"remote_work_path"); 445 594 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); 447 604 return SERVICE_FAILED; 448 605 } … … 453 610 SSHCON *test=ssh_connect(*main_conf); 454 611 ssh_copy(*main_conf,scriptPath,targetPath,ssh_get_cnt(*main_conf)); 455 612 unlink(scriptPath); 613 free(scriptPath); 456 614 // 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"); 458 617 char *command=(char*)malloc((strlen(targetPath)+strlen(targetPathMap->value)+strlen(subStr->value)+strlen(uuid->value)+137)*sizeof(char)); 459 618 sprintf(command,"sbatch %s 2> %s/error_%s.log | sed \"s:%s::g\"",targetPath,targetPathMap->value,uuid->value,subStr->value); … … 489 648 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 490 649 fflush(stderr); 491 invokeCallback(m,NULL,NULL,7, 1);650 invokeCallback(m,NULL,NULL,7,0); 492 651 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 493 652 fflush(stderr); … … 497 656 free(targetPath); 498 657 ssh_close(*main_conf); 499 sleep(1 20);658 sleep(1); 500 659 return -1; 501 660 } … … 507 666 fflush(stderr); 508 667 free(command); 668 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 669 fflush(stderr); 509 670 510 671 struct sockaddr_un addr; 672 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 673 fflush(stderr); 511 674 memset(&addr, 0, sizeof(addr)); 675 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 676 fflush(stderr); 512 677 addr.sun_family = AF_UNIX; 678 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 679 fflush(stderr); 513 680 int rc, cl, fd = socket(AF_UNIX, SOCK_STREAM, 0); 681 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 682 fflush(stderr); 514 683 char *sname=(char*)malloc((strlen(tmpPath->value)+strlen(uuid->value)+20)); 684 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 685 fflush(stderr); 515 686 sprintf(sname,"%s/.wait_socket_%s.sock",tmpPath->value,uuid->value); 687 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 688 fflush(stderr); 516 689 strncpy(addr.sun_path, sname, sizeof(addr.sun_path)-1); 690 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 691 fflush(stderr); 517 692 518 693 if (bind(fd, (struct sockaddr*)&addr, sizeof(addr)) == -1) { 519 694 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); 520 703 sleep(120); 521 704 return -1; 522 705 } 706 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 707 fflush(stderr); 523 708 if (listen(fd, 5) == -1) { 524 709 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); 525 717 return -1; 526 718 } 719 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 720 fflush(stderr); 527 721 if ( (cl = accept(fd, NULL, NULL)) == -1) { 528 722 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); 529 730 return -1; 530 731 }else{ 732 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 733 fflush(stderr); 531 734 int hasPassed=-1; 532 735 char buf[11]; … … 536 739 sleep(1); 537 740 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); 539 748 return -1; 540 749 }else{ 541 750 if(rc<0){ 542 751 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); 544 759 return -1; 545 760 } 546 761 } 547 762 hasPassed=1; 763 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 764 fflush(stderr); 548 765 res=atoi(buf); 766 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); 767 fflush(stderr); 549 768 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 552 778 if(res==3){ 553 779 fprintf(stderr,"************************* %s %d \n\n",__FILE__,__LINE__); … … 573 799 setMapInMaps(*main_conf,"lenv","message",tmpStr); 574 800 free(tmpStr); 801 invokeCallback(m,NULL,NULL,7,0); 575 802 return SERVICE_FAILED; 576 803 } … … 587 814 if(ssh_fetch(*main_conf,targetPath,generatedFile->value,ssh_get_cnt(m))==0){ 588 815 maps* tmp=getMaps(*real_outputs,input->name); 816 char serviceName[9]; 589 817 freeMap(&tmp->content); 590 818 free(tmp->content); … … 592 820 maps* output=getMaps(*real_outputs,input->name); 593 821 setMapInMaps(output->child,"download_link","generated_file",targetPath); 822 setMapInMaps(output->child,"download_link","storage",targetPath); 594 823 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"); 595 827 setMapInMaps(output->child,"wms_link","generated_file",targetPath); 828 setMapInMaps(output->child,"wms_link","storage",targetPath); 596 829 setMapInMaps(output->child,"wms_link","useMapserver","true"); 597 830 setMapInMaps(output->child,"wms_link","msOgc","WMS"); 598 831 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; 601 852 } 602 853 free(targetPath); … … 605 856 input=input->next; 606 857 } 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); 607 889 } 608 890 //free(buf); … … 611 893 perror("Failed to read"); 612 894 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); 613 902 sleep(120); 614 903 return SERVICE_FAILED; … … 622 911 return res; 623 912 } 624 625
Note: See TracChangeset
for help on using the changeset viewer.