Back to index

nordugrid-arc-nox  1.1.0~rc6
tools.cpp
Go to the documentation of this file.
00001 #include "tools.h"
00002 
00003 namespace ARex {
00004 
00005   void convertActivityStatus(const std::string& gm_state,std::string& bes_state,std::string& arex_state,bool failed,bool pending) {
00006     if(gm_state == "ACCEPTED") {
00007       bes_state="Pending"; arex_state="Accepted";
00008     } else if(gm_state == "PREPARING") {
00009       bes_state="Running"; arex_state=(!pending)?"Preparing":"Prepared";
00010     } else if(gm_state == "SUBMIT") {
00011       bes_state="Running"; arex_state="Submitting";
00012     } else if(gm_state == "INLRMS") {
00013       bes_state="Running"; arex_state=(!pending)?"Executing":"Executed";
00014     } else if(gm_state == "FINISHING") {
00015       bes_state="Running"; arex_state="Finishing";
00016     } else if(gm_state == "FINISHED") {
00017       if(!failed) {
00018         bes_state="Finished"; arex_state="Finished";
00019       } else {
00020         bes_state="Failed"; arex_state="Failed";
00021       };
00022     } else if(gm_state == "DELETED") {
00023       // AFAIR failed is not avialable anymore.
00024       bes_state=(!failed)?"Finished":"Failed"; arex_state="Deleted";
00025     } else if(gm_state == "CANCELING") {
00026       bes_state="Running"; arex_state="Killing";
00027     };
00028   }
00029 
00030   void addActivityStatus(Arc::XMLNode pnode,const std::string& gm_state,const std::string& glue_state,bool failed,bool pending) {
00031     std::string bes_state("");
00032     std::string arex_state("");
00033     convertActivityStatus(gm_state,bes_state,arex_state,failed,pending);
00034     Arc::XMLNode state = pnode.NewChild("bes-factory:ActivityStatus");
00035     state.NewAttribute("state")=bes_state;
00036     state.NewChild("a-rex:State")=arex_state;
00037     if(pending) state.NewChild("a-rex:State")="Pending";
00038     if(!glue_state.empty()) {
00039       std::string::size_type p = glue_state.find(':');
00040       if(p != std::string::npos) {
00041         if(glue_state.substr(0,p) == "INLRMS") {
00042           // Extrach state of batch system
00043           state.NewChild("a-rex:LRMSState")=glue_state.substr(p+1);
00044         };
00045       };
00046       state.NewChild("glue:State")=glue_state;
00047     };
00048   }
00049 
00050 }
00051