Ignore:
Timestamp:
Oct 11, 2018, 4:30:46 PM (6 years ago)
Author:
djay
Message:

Check for md5sum of any file in the cache to avoid sending the same file on HPC server twice. Add the multiple LiteralData? inputs support for HPC services. Remove condition for defining SCALE for every band in the outputed MapServer? mapfile.

File:
1 edited

Legend:

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

    r877 r886  
    438438    }
    439439    if(!sessions[cnt]->sftp_session)
    440       zSleep(10);
     440      zSleep(1);
    441441  } while (!sessions[cnt]->sftp_session);
    442442  do {
     
    453453    }
    454454    if(!sftp_handle)
    455       zSleep(100);
     455      zSleep(1);
    456456  } while (!sftp_handle);
    457457 
     
    530530  char *logPath=(char*)malloc((strlen(tmpPath->value)+strlen(uuid->value)+11)*sizeof(char));
    531531  sprintf(logPath,"%s/exec_out_%s",tmpPath->value,uuid->value);
     532 
    532533  FILE* logFile=fopen(logPath,"wb");
    533534  free(logPath);
     
    542543        bytecount += rc;
    543544        buffer[rc]=0;
     545       
    544546        fprintf(logFile,"%s",buffer);
    545547        fflush(logFile);
     
    649651}
    650652
     653int 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
    651709bool runUpload(maps** conf){
    652710  SSHCON *test=ssh_connect(*conf);
     
    665723        getMapArray(queueMaps->content,"targetPath",i)
    666724      };
    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!"));
    676740          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      }
    683743    }   
    684744  }
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

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

Become a sponsor !

Knowledge partners

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

Become a knowledge partner

Related links

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