Changeset 886 for branches/prototype-v0/zoo-project/zoo-kernel
- Timestamp:
- Oct 11, 2018, 4:30:46 PM (6 years ago)
- Location:
- branches/prototype-v0/zoo-project/zoo-kernel
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-kernel/caching.c
r880 r886 177 177 fwrite(md5fstr,sizeof(char),strlen(md5fstr),fo); 178 178 free(md5fstr); 179 free(storage); 179 180 fclose(fo); 180 181 return 0; -
branches/prototype-v0/zoo-project/zoo-kernel/meta_sql.c
r854 r886 42 42 #endif 43 43 #define META_SERVICES_LIST_ALL \ 44 "select id,identifier,title,abstract,service_type,service_provider "\44 "select id,identifier,title,abstract,service_type,service_provider,conf_id"\ 45 45 " from ows_process" 46 #define META_SERVICES_LIST_ALL_LENGTH 8346 #define META_SERVICES_LIST_ALL_LENGTH strlen(META_SERVICES_LIST_ALL) 47 47 48 48 #define META_SERVICES_KEYWORDS_FROM_PROCESS \ … … 50 50 " (SELECT keywords_id FROM CollectionDB.DescriptionsKeywordsAssignment"\ 51 51 " where descriptions_id=%s) " 52 #define META_SERVICES_KEYWORDS_FROM_PROCESS_LENGTH 16252 #define META_SERVICES_KEYWORDS_FROM_PROCESS_LENGTH strlen(META_SERVICES_KEYWORDS_FROM_PROCESS) 53 53 54 54 #define META_SERVICES_META_FROM_ANYTHING \ … … 56 56 " (SELECT metadata_id FROM CollectionDB.DescriptionsMetadataAssignment"\ 57 57 " where descriptions_id=%s) " 58 #define META_SERVICES_META_FROM_ANYTHING_LENGTH 16258 #define META_SERVICES_META_FROM_ANYTHING_LENGTH strlen(META_SERVICES_META_FROM_ANYTHING) 59 59 60 60 #define META_SERVICES_AP_FROM_ANYTHING \ … … 62 62 " (SELECT additional_parameters_id FROM CollectionDB.DescriptionsAdditionalParametersAssignment"\ 63 63 " where descriptions_id=%s) " 64 #define META_SERVICES_AP_FROM_ANYTHING_LENGTH 19964 #define META_SERVICES_AP_FROM_ANYTHING_LENGTH strlen(META_SERVICES_AP_FROM_ANYTHING) 65 65 66 66 #define META_SERVICES_AP_FROM_AP \ 67 67 "SELECT key,value FROM CollectionDB.ows_AdditionalParameter where additional_parameters_id =$q$%s$q$" 68 #define META_SERVICES_AP_FROM_AP_LENGTH 10068 #define META_SERVICES_AP_FROM_AP_LENGTH strlen(META_SERVICES_AP_FROM_AP) 69 69 70 70 #define META_SERVICES_LIST_INPUTS_FROM_PROCESS \ 71 71 "select id, identifier,title,abstract,min_occurs,max_occurs from CollectionDB.ows_Input where id in (SELECT input_id from CollectionDB.ProcessInputAssignment where process_id=%s) order by id" 72 #define META_SERVICES_LIST_INPUTS_FROM_PROCESS_LENGTH 19072 #define META_SERVICES_LIST_INPUTS_FROM_PROCESS_LENGTH strlen(META_SERVICES_LIST_INPUTS_FROM_PROCESS) 73 73 74 74 #define META_SERVICES_LIST_INPUTS_FROM_INPUT \ 75 75 "select id, identifier,title,abstract,min_occurs,max_occurs from CollectionDB.ows_Input where id in (SELECT child_input from CollectionDB.InputInputAssignment where parent_input=%s) order by id" 76 #define META_SERVICES_LIST_INPUTS_FROM_INPUT_LENGTH 19376 #define META_SERVICES_LIST_INPUTS_FROM_INPUT_LENGTH strlen(META_SERVICES_LIST_INPUTS_FROM_INPUT) 77 77 78 78 #define META_SERVICES_LIST_OUTPUTS_FROM_PROCESS \ 79 79 "select id, identifier,title,abstract from CollectionDB.ows_Output where id in (SELECT output_id from CollectionDB.ProcessOutputAssignment where process_id=%s) order by id" 80 #define META_SERVICES_LIST_OUTPUTS_FROM_PROCESS_LENGTH 17180 #define META_SERVICES_LIST_OUTPUTS_FROM_PROCESS_LENGTH strlen(META_SERVICES_LIST_OUTPUTS_FROM_PROCESS) 81 81 82 82 #define META_SERVICES_LIST_OUTPUTS_FROM_OUTPUT \ 83 83 "select id, identifier,title,abstract from CollectionDB.ows_Output where id in (SELECT child_output from CollectionDB.OutputOutputAssignment where parent_output=%s) order by id" 84 #define META_SERVICES_LIST_OUTPUTS_FROM_OUTPUT_LENGTH 17684 #define META_SERVICES_LIST_OUTPUTS_FROM_OUTPUT_LENGTH strlen(META_SERVICES_LIST_OUTPUTS_FROM_OUTPUT) 85 85 86 86 #define META_SERVICES_LIST_LITERAL_FROM_IO \ 87 87 "select (SELECT name as type FROM CollectionDB.PrimitiveDatatypes where CollectionDB.PrimitiveDatatypes.id=data_type_id),default_value,(SELECT uom from CollectionDB.PrimitiveUOM where id=CollectionDB.LiteralDataDomain.uom),translate(translate(ARRAY((SELECT allowed_Value from CollectionDB.AllowedValues where id in (SELECT allowed_value_id from CollectionDB.AllowedValuesAssignment where literal_data_domain_id=CollectionDB.LiteralDataDomain.id)))::varchar,'{',''),'}',''),def as allowedvalues from CollectionDB.LiteralDataDomain where id in (SELECT data_description_id from CollectionDB.%sDataDescriptionAssignment where %s_id = %s);" 88 #define META_SERVICES_LIST_LITERAL_FROM_IO_LENGTH 63488 #define META_SERVICES_LIST_LITERAL_FROM_IO_LENGTH strlen(META_SERVICES_LIST_LITERAL_FROM_IO) 89 89 90 90 #define META_SERVICES_LIST_FORMATS_FROM_IO \ 91 91 "select mime_type,encoding,schema,maximum_megabytes,CASE WHEN use_mapserver THEN 'true' ELSE 'false' END, ms_styles, def from CollectionDB.ows_Format,CollectionDB.PrimitiveFormats where CollectionDB.ows_Format.primitive_format_id=CollectionDB.PrimitiveFormats.id and CollectionDB.ows_Format.id in (SELECT format_id from collectiondb.ows_datadescription where id in ( SELECT data_description_id from CollectionDB.%sDataDescriptionAssignment where %s_id = %s))" 92 #define META_SERVICES_LIST_FORMATS_FROM_IO_LENGTH 45892 #define META_SERVICES_LIST_FORMATS_FROM_IO_LENGTH strlen(META_SERVICES_LIST_FORMATS_FROM_IO) 93 93 94 94 /** … … 387 387 addToMap(s->content,"serviceType",poFeature->GetFieldAsString( 4 )); 388 388 addToMap(s->content,"serviceProvider",poFeature->GetFieldAsString( 5 )); 389 addToMap(s->content,"confId",poFeature->GetFieldAsString( 6 )); 389 390 addToMap(s->content,"fromDb","true"); 390 391 s->metadata=NULL; -
branches/prototype-v0/zoo-project/zoo-kernel/service_callback.c
r877 r886 769 769 char *keys[6][2]={ 770 770 { 771 "SubmitTime", 771 //"SubmitTime", 772 "Submit", 772 773 "hpc_submission_date" 773 774 }, … … 781 782 }, 782 783 { 783 "StartTime", 784 //"StartTime", 785 "Start", 784 786 "hpc_start_date" 785 787 }, 786 788 { 787 "EndTime", 789 //"EndTime", 790 "End", 788 791 "hpc_end_date" 789 792 }, 790 793 { 791 "JobState", 794 //"JobState", 795 "State", 792 796 "hpc_status" 793 797 } -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_hpc.c
r877 r886 299 299 // then, set the configId key in the lenv section 300 300 char *serviceType; 301 map* mServiceType=getMap(s->content," serviceType");301 map* mServiceType=getMap(s->content,"confId"); 302 302 if(mServiceType!=NULL) 303 303 serviceType=mServiceType->value; … … 334 334 while(input!=NULL && input->content!=NULL){ 335 335 map* isInRequest=getMap(input->content,"inRequest"); 336 map* minNb=getMap(input->content,"min occurs");336 map* minNb=getMap(input->content,"minOccurs"); 337 337 if(getMaps(*real_outputs,input->name)==NULL && 338 338 ( (isInRequest!=NULL && strncasecmp(isInRequest->value,"true",4)==0) … … 397 397 if(getMap(input->content,"dataType")!=NULL){ 398 398 // For LitteralData, simply pass the value 399 map* val=getMap(input->content,"value"); 400 parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(val->value)+3)*sizeof(char)); 401 sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,val->value); 399 map* length=getMap(input->content,"length"); 400 if(length!=NULL){ 401 char* value=NULL; 402 int len=atoi(length->value); 403 int i=0; 404 for(i=0;i<len;i++){ 405 map* val=getMapArray(input->content,"value",i); 406 if(val!=NULL){ 407 if(value==NULL){ 408 value=(char*)malloc((strlen(val->value)+3)*sizeof(char)); 409 sprintf(value,"\"%s\"",val->value); 410 } 411 else{ 412 value=(char*)realloc(value,(strlen(value)+strlen(val->value)+4)*sizeof(char)); 413 sprintf(value,"%s \"%s\"",value,val->value); 414 } 415 } 416 } 417 if(value!=NULL){ 418 parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(value)+3)*sizeof(char)); 419 sprintf(parameters[parameters_cnt-1],"-%s %s",input->name,value); 420 } 421 }else{ 422 map* val=getMap(input->content,"value"); 423 parameters[parameters_cnt-1]=(char*)malloc((strlen(input->name)+strlen(val->value)+5)*sizeof(char)); 424 sprintf(parameters[parameters_cnt-1],"-%s \"%s\"",input->name,val->value); 425 } 402 426 } 403 427 } … … 888 912 dup2 (fileno (stderr), fileno (stdout)); 889 913 conf_read(filePath,m); 914 //dumpMaps(m); 890 915 fflush(stdout); 891 916 dup2 (saved_stdout, fileno (stdout)); … … 910 935 free(targetPath); 911 936 }else{ 912 map* hpcStdErr=getMapFromMaps(*main_conf,"henv","StdErr"); 913 if(hpcStdErr!=NULL && ssh_fetch(*main_conf,targetPath,hpcStdErr->value,ssh_get_cnt(m))==0){ 937 map* hpcStdErr=getMapFromMaps(*main_conf,"henv","StdErr"); 938 // Added for using sacct in place of scontrol 939 char *sourcePath=NULL; 940 if(hpcStdErr!=NULL){ 941 sourcePath=(char*)malloc((strlen(targetPathMap->value)+strlen(hpcStdErr->value)+2)*sizeof(char)); 942 sprintf(sourcePath,"%s/%s",targetPathMap->value,hpcStdErr->value); 943 } 944 if(hpcStdErr!=NULL && sourcePath!=NULL && ssh_fetch(*main_conf,targetPath,sourcePath,ssh_get_cnt(m))==0){ 945 free(sourcePath); 914 946 struct stat f_status; 915 947 int ts=stat(targetPath, &f_status); … … 925 957 free(fcontent); 926 958 }else{ 927 char *tmpStr=(char*)malloc((strlen( filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char));928 sprintf(tmpStr,_("Unable to fetch the remote file for %s"), filename);959 char *tmpStr=(char*)malloc((strlen(targetPath)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char)); 960 sprintf(tmpStr,_("Unable to fetch the remote file for %s"),targetPath); 929 961 setMapInMaps(*main_conf,"lenv","message",tmpStr); 930 962 free(tmpStr); … … 939 971 return SERVICE_FAILED; 940 972 } 941 } 973 } 942 974 }else{ 943 975 map* generatedFile=getMap(input->content,"generated_file"); … … 981 1013 }else{ 982 1014 map* hpcStdErr=getMapFromMaps(*main_conf,"henv","StdErr"); 983 if(hpcStdErr!=NULL && ssh_fetch(*main_conf,targetPath,hpcStdErr->value,ssh_get_cnt(m))==0){ 1015 char *sourcePath=NULL; 1016 if(hpcStdErr!=NULL){ 1017 dumpMap(hpcStdErr); 1018 sourcePath=(char*)malloc((strlen(targetPathMap->value)+strlen(hpcStdErr->value)+2)*sizeof(char)); 1019 sprintf(sourcePath,"%s/%s",targetPathMap->value,hpcStdErr->value); 1020 } 1021 if(hpcStdErr!=NULL && sourcePath!=NULL && ssh_fetch(*main_conf,targetPath,sourcePath,ssh_get_cnt(m))==0){ 1022 free(sourcePath); 984 1023 struct stat f_status; 985 1024 int ts=stat(targetPath, &f_status); … … 995 1034 free(fcontent); 996 1035 }else{ 997 char *tmpStr=(char*)malloc((strlen( filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char));998 sprintf(tmpStr,_("Unable to fetch the remote file for %s"), filename);1036 char *tmpStr=(char*)malloc((strlen(targetPath)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char)); 1037 sprintf(tmpStr,_("Unable to fetch the remote file for %s"),targetPath); 999 1038 setMapInMaps(*main_conf,"lenv","message",tmpStr); 1000 1039 free(tmpStr); 1001 1040 } 1002 1041 }else{ 1003 char *tmpStr=(char*)malloc((strlen( filename)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char));1004 sprintf(tmpStr,_("Unable to fetch the remote file for %s"), filename);1042 char *tmpStr=(char*)malloc((strlen(sourcePath)+strlen(_("Unable to fetch the remote file for %s"))+1)*sizeof(char)); 1043 sprintf(tmpStr,_("Unable to fetch the remote file for %s"),sourcePath); 1005 1044 setMapInMaps(*main_conf,"lenv","message",tmpStr); 1006 1045 free(tmpStr); -
branches/prototype-v0/zoo-project/zoo-kernel/service_internal_ms.c
r880 r886 542 542 int imyIndex=getPublishedId(output); 543 543 msMapSetExtent(m,minX,minY,maxX,maxY); 544 m->maxsize=4096;544 //m->maxsize=4096; 545 545 #ifdef DEBUGMS 546 546 fprintf(stderr,"Extent %.15f %.15f %.15f %.15f\n",minX,minY,maxX,maxY); … … 951 951 */ 952 952 GDALAllRegister(); 953 hDataset = GDALOpen( pszFilename, GA_Update ); 953 hDataset = GDALOpen( pszFilename, GA_Update ); /*GA_ReadOnly*/ 954 954 if( hDataset == NULL ){ 955 955 #ifdef DEBUGMS … … 1039 1039 setSrsInformations(output,m,myLayer,pszProjection); 1040 1040 }else{ 1041 fprintf(stderr,"NO SRS FOUND ! %s\n",GDALGetProjectionRef( hDataset )); 1041 fprintf(stderr,"NO SRS FOUND %s %d ! %s\n",__FILE__,__LINE__,GDALGetProjectionRef( hDataset )); 1042 fflush(stderr); 1042 1043 CPLErr sp=GDALSetProjection( hDataset , "+init=epsg:4326" ); 1043 1044 if(sp!=CE_None){ 1044 fprintf(stderr,"NO SRS FOUND! %s\n",CPLGetLastErrorMsg());1045 fprintf(stderr,"NO SRS SET ! %s\n",CPLGetLastErrorMsg()); 1045 1046 } 1046 1047 } … … 1133 1134 1134 1135 CPLErrorReset(); 1135 GDALComputeRasterStatistics( hBand, TRUE, &pdfMin, &pdfMax, &pdfMean, &pdfStdDev, NULL,NULL); 1136 GDALGetRasterStatistics( hBand, TRUE, TRUE, &pdfMin, &pdfMax, &pdfMean, &pdfStdDev); 1137 //GDALComputeRasterStatistics( hBand, TRUE, &pdfMin, &pdfMax, &pdfMean, &pdfStdDev, NULL,NULL); 1136 1138 char tmpN[21]; 1137 1139 sprintf(tmpN,"Band%d",iBand+1); … … 1143 1145 sprintf(tmpI,"%s_interval",tmpN); 1144 1146 msInsertHashTable(&(myLayer->metadata), tmpI, tmpMm); 1145 if(pdfMax>255)1146 1147 //if(pdfMax>255) 1148 msLayerAddProcessing(myLayer,tmpMp); 1147 1149 map* test=getMap(output->content,"msClassify"); 1148 1150 if(test!=NULL && strncasecmp(test->value,"true",4)==0){ … … 1498 1500 fprintf(myMaps,"%s\n",mapfile); 1499 1501 fclose(myMaps); 1500 } 1502 } 1503 free(mapName); 1504 free(tmp); 1501 1505 } -
branches/prototype-v0/zoo-project/zoo-kernel/sshapi.c
r877 r886 438 438 } 439 439 if(!sessions[cnt]->sftp_session) 440 zSleep(1 0);440 zSleep(1); 441 441 } while (!sessions[cnt]->sftp_session); 442 442 do { … … 453 453 } 454 454 if(!sftp_handle) 455 zSleep(1 00);455 zSleep(1); 456 456 } while (!sftp_handle); 457 457 … … 530 530 char *logPath=(char*)malloc((strlen(tmpPath->value)+strlen(uuid->value)+11)*sizeof(char)); 531 531 sprintf(logPath,"%s/exec_out_%s",tmpPath->value,uuid->value); 532 532 533 FILE* logFile=fopen(logPath,"wb"); 533 534 free(logPath); … … 542 543 bytecount += rc; 543 544 buffer[rc]=0; 545 544 546 fprintf(logFile,"%s",buffer); 545 547 fflush(logFile); … … 649 651 } 650 652 653 int fileMd5Check(maps** conf,const char* localPath,const char* targetPath){ 654 if(strstr(localPath,".zca")!=NULL){ 655 char *logPath=NULL; 656 char *command=(char*)malloc((strlen(targetPath)+27)*sizeof(char)); 657 sprintf(command,"md5sum %s | awk {'print $1'}",targetPath); 658 if(ssh_exec(*conf,command,ssh_get_cnt(*conf))<=0){ 659 return -1; 660 }else{ 661 struct stat f_status={}; 662 map* usid=getMapFromMaps(*conf,"lenv","usid"); 663 map* tmpMap=getMapFromMaps(*conf,"main","tmpPath"); 664 char* tmpPath=zStrdup(localPath); 665 tmpPath[strlen(tmpPath)-2]='m'; 666 tmpPath[strlen(tmpPath)-1]='d'; 667 free(command); 668 logPath=(char*)malloc((strlen(tmpMap->value)+strlen(usid->value)+11)*sizeof(char)); 669 sprintf(logPath,"%s/exec_out_%s",tmpMap->value,usid->value); 670 int ts=stat(logPath, &f_status); 671 if(ts==0) { 672 char* fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 673 FILE* f=fopen(logPath,"rb"); 674 fread(fcontent,f_status.st_size,1,f); 675 fcontent[f_status.st_size-1]=0; 676 fclose(f); 677 free(logPath); 678 struct stat f_status1={}; 679 int ts1=stat(tmpPath, &f_status1); 680 if(ts1==0) { 681 char* fcontent1=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 682 FILE* f1=fopen(tmpPath,"rb"); 683 fread(fcontent1,f_status1.st_size,1,f1); 684 fcontent1[f_status1.st_size]=0; 685 fclose(f1); 686 free(tmpPath); 687 if(strcmp(fcontent,fcontent1)==0){ 688 free(fcontent); 689 free(fcontent1); 690 return 0; 691 }else{ 692 free(fcontent); 693 free(fcontent1); 694 return -1; 695 } 696 }else{ 697 free(tmpPath); 698 free(fcontent); 699 return -1; 700 } 701 } 702 free(logPath); 703 free(tmpPath); 704 } 705 } 706 return -1; 707 } 708 651 709 bool runUpload(maps** conf){ 652 710 SSHCON *test=ssh_connect(*conf); … … 665 723 getMapArray(queueMaps->content,"targetPath",i) 666 724 }; 667 /**/zooLock* lck; 668 if((lck=lockFile(*conf,argv[1]->value,'w'))!=NULL){/**/ 669 if(ssh_copy(*conf,argv[1]->value,argv[2]->value,ssh_get_cnt(*conf))!=true){ 670 char* templateStr=_("Unable to copy over SSH the file requested for setting the value of %s."); 671 char *tmpMessage=(char*)malloc((strlen(templateStr)+strlen(argv[0]->value)+1)*sizeof(char)); 672 sprintf(tmpMessage,templateStr,argv[0]->value); 673 setMapInMaps(*conf,"lenv","message",tmpMessage); 674 free(tmpMessage); 675 unlockFile(*conf,lck); 725 if(fileMd5Check(conf,argv[1]->value,argv[2]->value)<0){ 726 /**/zooLock* lck; 727 if((lck=lockFile(*conf,argv[1]->value,'w'))!=NULL){/**/ 728 if(ssh_copy(*conf,argv[1]->value,argv[2]->value,ssh_get_cnt(*conf))!=true){ 729 char* templateStr=_("Unable to copy over SSH the file requested for setting the value of %s."); 730 char *tmpMessage=(char*)malloc((strlen(templateStr)+strlen(argv[0]->value)+1)*sizeof(char)); 731 sprintf(tmpMessage,templateStr,argv[0]->value); 732 setMapInMaps(*conf,"lenv","message",tmpMessage); 733 free(tmpMessage); 734 unlockFile(*conf,lck); 735 return false; 736 } 737 /**/unlockFile(*conf,lck); 738 }else{ 739 setMapInMaps(*conf,"lenv","message",_("Unable to lock the file for upload!")); 676 740 return false; 677 } 678 /**/unlockFile(*conf,lck); 679 }else{ 680 setMapInMaps(*conf,"lenv","message",_("Unable to lock the file for upload!")); 681 return false; 682 }/**/ 741 }/**/ 742 } 683 743 } 684 744 }
Note: See TracChangeset
for help on using the changeset viewer.