Back to index

nordugrid-arc-nox  1.1.0~rc6
job_status.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include "job_status.h"
00006 
00007 namespace Paul
00008 {
00009 
00010 static std::map<SchedStatusLevel, std::string> str_map;
00011 
00012 std::string sched_status_to_string(SchedStatusLevel l)
00013 {
00014     if (l == NEW) {
00015         return "NEW";
00016     } else if (l == STARTING) {
00017         return "STARTING";
00018     } else if (l == RUNNING) {
00019         return "RUNNING";
00020     } else if (l == CANCELLED) {
00021         return "CANCELLED";
00022     } else if (l == FAILED) {
00023         return "FAILED";
00024     } else if (l == FINISHED) {
00025         return "FINISHED";
00026     } else if (l == KILLED) {
00027         return "KILLED";
00028     } else if (l == KILLING) {
00029         return "KILLING";
00030     } 
00031 
00032     return "UNKNOWN";
00033 }
00034 
00035 SchedStatusLevel sched_status_from_string(const std::string &s)
00036 {
00037     if (s == "NEW") { 
00038         return NEW;
00039     } else if (s == "STARTING") {
00040         return STARTING;
00041     } else if (s == "RUNNING") {
00042         return RUNNING;
00043     } else if (s == "CANCELLED") {
00044         return CANCELLED;
00045     } else if (s == "FAILED") { 
00046         return FAILED;
00047     } else if (s == "FINISHED") {
00048         return FINISHED;
00049     } else if (s == "KILLED") {
00050         return KILLED;
00051     } else if (s == "KILLING")  {
00052         return KILLING;
00053     }
00054 
00055     return UNKNOWN;
00056 }
00057 #if 0
00058 SchedStatusFactory::SchedStatusFactory(void)
00059 {
00060     str_map[NEW] = "NEW";
00061     str_map[STARTING] = "STARTING";
00062     str_map[RUNNING] = "RUNNING"; 
00063     str_map[CANCELLED] = "CANCELLED"; 
00064     str_map[FAILED] = "FAILED"; 
00065     str_map[FINISHED] = "FINISHED"; 
00066     str_map[KILLED] = "KILLED"; 
00067     str_map[KILLING] = "KILLING";
00068     str_map[UNKNOWN] = "UNKNOWN"; 
00069 }
00070 
00071 SchedStatus SchedStatusFactory::get(const std::string &state)
00072 {
00073     std::map<SchedStatusLevel, std::string>::iterator it;
00074     for (it = str_map.begin(); it != str_map.end(); it++) {
00075         if (state == it->second) {
00076             return SchedStatus(it->first, it->second);
00077         }
00078     }
00079     return get(UNKNOWN);
00080 }
00081 
00082 SchedStatus SchedStatusFactory::getFromARexStatus(const std::string &arex_state) 
00083 {
00084     if (arex_state == "ACCEPTED") {
00085         return get(STARTING);
00086     } else if(arex_state == "PREPARING") {
00087         return get(STARTING);
00088     } else if(arex_state == "SUBMITTING") {
00089         return get(STARTING);
00090     } else if(arex_state == "EXECUTING") {
00091         return get(RUNNING);
00092     } else if(arex_state == "FINISHING") {
00093         return get(RUNNING);
00094     } else if(arex_state == "FINISHED") {
00095         return get(FINISHED);
00096     } else if(arex_state == "DELETED") {
00097         return get(CANCELLED);
00098     } else if(arex_state == "KILLING") {
00099         return get(CANCELLED);
00100     }
00101     return get(UNKNOWN);
00102 }
00103 
00104 SchedStatus SchedStatusFactory::getFromARexStatus(ARexStatusLevel al)
00105 {
00106     // XXX  missing mapping
00107     get(UNKNOWN);
00108 }
00109 #endif
00110 
00111 } // namespace Paul