Back to index

nordugrid-arc-nox  1.1.0~rc6
JobStateARC0.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include "JobStateARC0.h"
00006 
00007 namespace Arc {
00008 
00009   JobState::StateType JobStateARC0::StateMap(const std::string& state) {
00010     std::string state_ = state;
00011 /*
00012    Infosys states (mapped from GM states):
00013  ACCEPTING
00014  ACCEPTED
00015  PREPARED
00016  SUBMITTING
00017  INLRMS: *
00018  KILLING
00019  EXECUTED
00020  KILLED
00021  FAILED
00022 
00023    GM states (either not mapped or somehow obtained directly):
00024  ACCEPTED 
00025  PREPARING
00026  SUBMIT
00027  INLRMS
00028  CANCELING
00029  FINISHING
00030  FINISHED
00031  DELETED
00032  PENDING:*
00033 */
00034     if (state_.substr(0,8) == "PENDING:") state_.erase(0,8);
00035     // remove spaces because sometimes we may have 'INLRMS: *'
00036     std::string::size_type p = 0;
00037     while((p = state_.find(' ',p)) != std::string::npos)
00038       state_.erase(p,1);
00039     if ((state_ == "ACCEPTED") ||
00040         (state_ == "ACCEPTING"))
00041       return JobState::ACCEPTED;
00042     else if ((state_ == "PREPARING") ||
00043              (state_ == "PREPARED"))
00044       return JobState::PREPARING;
00045     else if ((state_ == "SUBMIT") ||
00046              (state_ == "SUBMITTING"))
00047       return JobState::SUBMITTING;
00048     else if (state_ == "INLRMS:Q")
00049       return JobState::QUEUING;
00050     else if (state_ == "INLRMS:R")
00051       return JobState::RUNNING;
00052     else if (state_ == "INLRMS:H")
00053       return JobState::HOLD;
00054     else if (state_.substr(0,6) == "INLRMS")
00055       return JobState::QUEUING; // expect worst ?
00056     else if ((state_ == "FINISHING") ||
00057              (state_ == "KILLING") ||
00058              (state_ == "CANCELING") ||
00059              (state_ == "EXECUTED"))
00060       return JobState::FINISHING;
00061     else if (state_ == "FINISHED")
00062       return JobState::FINISHED;
00063     else if (state_ == "KILLED")
00064       return JobState::KILLED;
00065     else if (state_ == "FAILED")
00066       return JobState::FAILED;
00067     else if (state_ == "DELETED")
00068       return JobState::DELETED;
00069     else if (state_ == "")
00070       return JobState::UNDEFINED;
00071     else
00072       return JobState::OTHER;
00073   }
00074 
00075 }