Ignore:
Timestamp:
Dec 12, 2017, 4:09:47 PM (6 years ago)
Author:
djay
Message:

Add status_code key to the lenv section to support returning a specific HTTP error code from the service code. Fix callback invocation to support inputs arrays at step 1 and 2. Fix issue with cpu usage. Fix issue with mapserver publication when an input is optional. Fix callback invocation at step 7 in case the service has failed on the HPC side.

File:
1 edited

Legend:

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

    r857 r860  
    142142           ( cStep!=arg->step || (arg->state!=0 && steps[arg->step][0]==false) )
    143143           ){
    144       struct timespec tv;
    145       tv.tv_sec = 0;
    146       tv.tv_nsec = (long) 5*1e+9;
    147       nanosleep(&tv, &tv);
    148       //sleep(1);
     144      zSleep(100);
    149145    }
    150146    isOngoing=1;
     
    307303     
    308304    case 1: {
    309       // Fetching data inputs
    310       maps* curs=inputs;
    311       dumpMaps(curs);
    312       char *keys[10][2]={
    313         {
    314           "href",
    315           "ref"
    316         },
    317         {
    318           "cache_file",
    319           "cachefile"
    320         },
    321         {
    322           "fmimeType",
    323           "mimetype"
    324         },
    325         {
    326           "size",
    327           "size"
    328         },
    329         {
    330           "ref_wms_link",
    331           "ref_wms_link"
    332         },
    333         {
    334           "ref_wcs_link",
    335           "ref_wcs_link"
    336         },
    337         {
    338           "ref_wcs_link",
    339           "ref_wcs_link"
    340         },
    341         {
    342           "ref_wcs_preview_link",
    343           "ref_wcs_preview_link"
    344         },
    345         {
    346           "geodatatype",
    347           "datatype"
    348         },
    349         {
    350           "wcs_extent",
    351           "boundingbox"
    352         }       
    353       };
    354       json_object *res1=json_object_new_object();
    355       while(curs!=NULL){
    356         map* tmpMap=getMap(curs->content,"cache_file");
    357         sid=getMap(curs->content,"ref_wms_link");
    358         json_object *res2=json_object_new_object();
    359         if(tmpMap!=NULL){
    360           if(sid==NULL){
    361             addToMap(curs->content,"generated_file",tmpMap->value);
    362             addToMap(curs->content,"storage",tmpMap->value);
    363           }
    364           fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
    365           dumpMap(curs->content);
    366           struct stat buf;
    367           char timeStr[ 100 ] = "";
    368           if (stat(tmpMap->value, &buf)==0){
    369             strftime(timeStr, 100, "%d-%m-%Y %H:%M:%S", localtime( &buf.st_mtime));
    370             json_object *jsStr=json_object_new_string(timeStr);
    371             json_object_object_add(res2,"creation_date",jsStr);
    372           }
    373           tmpMap=getMap(curs->content,"fmimeType");
    374           if(tmpMap!=NULL){
    375             addToMap(curs->content,"mimeType",tmpMap->value);
    376           }
    377           setReferenceUrl(conf,curs);
    378         }
    379         int i=0;
    380         int hasRef=-1;
    381         for(;i<10;i++){
    382           sid=getMap(curs->content,keys[i][0]);
    383           if(sid!=NULL){
    384             json_object *jsStr=json_object_new_string(sid->value);
    385             json_object_object_add(res2,keys[i][1],jsStr);
    386             if(i==0){
    387               hasRef=1;
    388               json_object *jsStr1=json_object_new_string(getProvenance(conf,url->value));
    389               json_object_object_add(res2,"dataOrigin",jsStr1);
    390             }
    391           }
    392         }
    393         if(hasRef<0)
    394           json_object_put(res2);
    395         else
    396           json_object_object_add(res1,curs->name,res2);
    397         curs=curs->next;
    398       }
    399       json_object_object_add(res,"inputs",res1);
    400       break;
    401     }
    402      
    403     case 2: {
    404       // Update the execute request stored on disk at step 1,1 to modify the references used.
    405       if(state==0){
     305      // Update the execute request stored on disk at step 0,0 to modify the references used.
     306      if(state==1){
    406307        fprintf(stderr,"%s %d \n",__FILE__,__LINE__);
    407308        fflush(stderr);
     
    424325          //if(bvMap!=NULL && strncasecmp(bvMap->value,"true",4)==0){
    425326          if(getMap(curs->content,"href")==NULL && getMap(curs->content,"mimeType")!=NULL){
    426             map* tmpMap=getMap(curs->content,"cache_file");
     327            map* tmpMap=getMap(curs->content,"value");
     328            char tmpStr[100];
     329            sprintf(tmpStr,"%d",strlen(tmpMap->value));
     330            addToMap(curs->content,"size",tmpStr);
     331            tmpMap=getMap(curs->content,"mimeType");
     332            addToMap(curs->content,"fmimeType",tmpMap->value);
     333            tmpMap=getMap(curs->content,"cache_file");
    427334            addToMap(curs->content,"generated_file",tmpMap->value);
    428335            addToMap(curs->content,"storage",tmpMap->value);
     
    459366            char *tmpParam=(char*)malloc((strlen(curs->name)+11)*sizeof(char));
    460367            char *tmpParam1=(char*)malloc((strlen(filePath->value)+11)*sizeof(char));
    461             sprintf(tmpParam,"string(\"%s\")",curs->name);         
    462             sprintf(tmpParam1,"string(\"%s\")",filePath->value);           
     368            addToMap(curs->content,"href",filePath->value);
     369            addToMap(curs->content,"xlink:href",filePath->value);
     370            sprintf(tmpParam,"string(\"%s\")",curs->name);
     371            sprintf(tmpParam1,"string(\"%s\")",filePath->value);
    463372            params[0]="attr";
    464373            params[1]=tmpParam;
     
    538447      }
    539448
     449      // Fetching data inputs
     450      maps* curs=inputs;
     451      dumpMaps(curs);
     452      char *keys[11][2]={
     453        {
     454          "xlink:href",
     455          "ref"
     456        },
     457        {
     458          "cache_file",
     459          "cachefile"
     460        },
     461        {
     462          "fmimeType",
     463          "mimetype"
     464        },
     465        {
     466          "size",
     467          "size"
     468        },
     469        {
     470          "ref_wms_link",
     471          "ref_wms_link"
     472        },
     473        {
     474          "ref_wfs_link",
     475          "ref_wfs_link"
     476        },
     477        {
     478          "ref_wcs_link",
     479          "ref_wcs_link"
     480        },
     481        {
     482          "ref_wcs_link",
     483          "ref_wcs_link"
     484        },
     485        {
     486          "ref_wcs_preview_link",
     487          "ref_wcs_preview_link"
     488        },
     489        {
     490          "geodatatype",
     491          "datatype"
     492        },
     493        {
     494          "wgs84_extent",
     495          "boundingbox"
     496        }       
     497      };
     498      json_object *res1=json_object_new_object();
     499      while(curs!=NULL){
     500        if(getMap(curs->content,"length")==NULL){
     501          addToMap(curs->content,"length","1");
     502        }
     503        map* length=getMap(curs->content,"length");
     504        int len=atoi(length->value);
     505        json_object *res3;
     506        int hasRef=-1;
     507        for(int ii=0;ii<len;ii++){
     508          map* tmpMap=getMapArray(curs->content,"cache_file",ii);
     509          sid=getMapArray(curs->content,"ref_wms_link",ii);
     510          json_object *res2=json_object_new_object();
     511          if(tmpMap!=NULL){
     512            if(sid==NULL){
     513              setMapArray(curs->content,"generated_file",ii,tmpMap->value);
     514              setMapArray(curs->content,"storage",ii,tmpMap->value);
     515            }
     516            fprintf(stderr,"%s %d\n",__FILE__,__LINE__);
     517            dumpMap(curs->content);
     518            struct stat buf;
     519            char timeStr[ 100 ] = "";
     520            if (stat(tmpMap->value, &buf)==0){
     521              strftime(timeStr, 100, "%d-%m-%Y %H:%M:%S", localtime( &buf.st_mtime));
     522              json_object *jsStr=json_object_new_string(timeStr);
     523              json_object_object_add(res2,"creation_date",jsStr);
     524            }
     525            tmpMap=getMapArray(curs->content,"fmimeType",ii);
     526            if(tmpMap!=NULL){
     527              setMapArray(curs->content,"mimeType",ii,tmpMap->value);
     528            }
     529            setReferenceUrl(conf,curs);
     530          }else{         
     531          }
     532          addIntToMap(curs->content,"published_id",ii+1);
     533          int i=0;
     534          for(;i<11;i++){
     535            sid=getMapArray(curs->content,keys[i][0],ii);
     536            if(sid!=NULL){
     537              json_object *jsStr=json_object_new_string(sid->value);
     538              json_object_object_add(res2,keys[i][1],jsStr);
     539              if(i==0){
     540                hasRef=1;
     541                json_object *jsStr1=json_object_new_string(getProvenance(conf,sid->value));
     542                json_object_object_add(res2,"dataOrigin",jsStr1);
     543              }
     544            }
     545          }
     546          if(len>1){
     547            if(ii==0)
     548              res3=json_object_new_array();
     549            json_object_array_add(res3,res2);
     550          }else
     551            res3=res2;
     552        }
     553        if(hasRef<0)
     554          json_object_put(res3);
     555        else
     556          json_object_object_add(res1,curs->name,res3);
     557        addIntToMap(curs->content,"published_id",0);
     558        curs=curs->next;
     559      }
     560      json_object_object_add(res,"inputs",res1);
     561      break;
     562    }
     563     
     564    case 2: {
    540565      // Uploading data input to cluster
    541566      maps* in=getMaps(conf,"uploadQueue");
     
    545570        if(length!=NULL){
    546571          json_object *res1=json_object_new_object();
    547           json_object *res2=json_object_new_object();
     572          json_object *res3=json_object_new_array();
    548573          int limit=atoi(length->value);
    549574          int i=0;
     
    555580            map* tmp2=getMapArray(tmp,"targetPath",i);
    556581            if(tmp0!=NULL && tmp1!=NULL && tmp2!=NULL){
     582              json_object *res2=json_object_new_object();
    557583              json_object *jsStr=json_object_new_string(tmp1->value);
    558584              json_object_object_add(res2,"local_path",jsStr);
    559585              jsStr=json_object_new_string(tmp2->value);
    560586              json_object_object_add(res2,"target_path",jsStr);
    561               json_object_object_add(res1,tmp0->value,res2);
     587              json_object *res4=json_object_object_get(res1,tmp0->value);
     588              if(json_object_is_type(res4,json_type_null)){
     589                json_object_object_add(res1,tmp0->value,res2);
     590              }else{
     591                if(json_object_is_type(res4,json_type_object)){
     592                  json_object_array_add(res3,res4);
     593                }
     594                json_object_array_add(res3,res2);
     595                if(json_object_is_type(res4,json_type_object)){
     596                  json_object_object_del(res1,tmp0->value);
     597                  json_object_object_add(res1,tmp0->value,res3);
     598                }
     599              }
    562600            }
    563601          }
     602          if(json_object_array_length(res3)==0)
     603            json_object_put(res3);
    564604          json_object_object_add(res,"inputs",res1);
    565605        }
     
    616656        },
    617657        {
    618           "wcs_extent",
     658          "wgs84_extent",
    619659          "boundingbox"
    620660        },
     
    684724              int i0=0;
    685725              for(;i0<6;i0++){
    686                 sid=getMap(specificMaps->content,keys[i0][0]);
     726                if(i0==0)
     727                  sid=getMap(specificMaps->content,specifics[i][1]);
     728                else
     729                  sid=getMap(specificMaps->content,keys[i0][0]);
    687730                if(sid!=NULL){
    688731                  json_object *jsStr=json_object_new_string(sid->value);
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