27 ClassImp(TAlienJobStatus);
33 TAlienJobStatus::TAlienJobStatus(TMap *status)
39 TMapIter next(status);
40 while ( (key = (TObjString*)next())) {
41 val = (TObjString*)status->GetValue(key->GetName());
42 fStatus.Add(key->Clone(), val->Clone());
50 TAlienJobStatus::~TAlienJobStatus()
58 void TAlienJobStatus::Browse(TBrowser* b)
61 TIterator *iter = fStatus.MakeIterator();
63 while ((obj = iter->Next()) != 0) {
64 TObject* value = fStatus.GetValue(obj);
66 TObjString* keyStr =
dynamic_cast<TObjString*
>(obj);
67 TObjString* valueStr =
dynamic_cast<TObjString*
>(value);
69 if (keyStr->GetString() == TString(
"jdl")) {
70 TString valueParsed(valueStr->GetString());
71 valueParsed.ReplaceAll(
"\n", 1);
72 valueParsed.ReplaceAll(
" ", 2);
73 b->Add(
new TPair(
new TObjString(
"jdl"),
new TObjString(valueParsed)));
76 const char* outputdir = GetJdlKey(
"OutputDir");
82 sandbox = TString(
"/proc/") + TString(GetKey(
"user")) + TString(
"/") + TString(GetKey(
"queueId")) + TString(
"/job-output");
85 b->Add(
new TAlienDirectory(sandbox.Data(),
"job-output"));
88 b->Add(
new TNamed(valueStr->GetString(), keyStr->GetString()));
98 const char *TAlienJobStatus::GetJdlKey(
const char* key)
100 const char *jdl = GetKey(
"jdl");
103 const char* jdltagbegin = strstr(jdl,key);
104 const char* jdltagquote = strchr(jdltagbegin,
'"');
105 const char* jdltagend = strchr(jdltagbegin,
';');
114 const char* jdltagquote2 = strchr(jdltagquote,
'"');
118 fJdlTag = TString(jdltagquote);
119 fJdlTag = fJdlTag(0,jdltagquote2-jdltagquote);
121 return fJdlTag.Data();
127 const char *TAlienJobStatus::GetKey(
const char* key)
129 TObject* obj = fStatus.FindObject(key);
130 TPair* pair =
dynamic_cast<TPair*
>(obj);
132 TObjString*
string =
dynamic_cast<TObjString*
> (pair->Value());
133 return string->GetName();
142 TGridJobStatus::EGridJobStatus TAlienJobStatus::GetStatus()
const
144 TObject* obj = fStatus.FindObject(
"status");
145 TPair* pair =
dynamic_cast<TPair*
>(obj);
148 TObjString*
string =
dynamic_cast<TObjString*
> (pair->Value());
151 const char* status =
string->GetString().Data();
153 if (strcmp(status,
"INSERTING") == 0 ||
154 strcmp(status,
"WAITING") == 0 ||
155 strcmp(status,
"QUEUED") == 0 ||
156 strcmp(status,
"ASSIGNED") == 0)
158 else if (strcmp(status,
"STARTED") == 0 ||
159 strcmp(status,
"SAVING") == 0 ||
160 strcmp(status,
"SPLITTING") == 0 ||
161 strcmp(status,
"RUNNING") == 0 ||
162 strcmp(status,
"SPLIT") == 0)
164 else if (strcmp(status,
"EXPIRED") == 0 ||
165 string->GetString().BeginsWith(
"ERROR_") == kTRUE ||
166 strcmp(status,
"FAILED") == 0 ||
167 strcmp(status,
"ZOMBIE") == 0)
169 else if (strcmp(status,
"KILLED") == 0)
171 else if (strcmp(status,
"DONE") == 0)
181 void TAlienJobStatus::Print(Option_t *)
const
190 void TAlienJobStatus::PrintJob(Bool_t full)
const
192 TObject* obj = fStatus.FindObject(
"status");
193 TPair* pair =
dynamic_cast<TPair*
>(obj);
196 TObjString*
string =
dynamic_cast<TObjString*
> (pair->Value());
198 printf(
"The status of the job is %s\n", string->GetString().Data());
205 printf(
"==================================================\n");
206 printf(
"Detail Information:\n");
208 TIterator* iter = fStatus.MakeIterator();
210 while ((obj = iter->Next()) != 0) {
211 TObject* value = fStatus.GetValue(obj);
213 TObjString* keyStr =
dynamic_cast<TObjString*
>(obj);
214 TObjString* valueStr =
dynamic_cast<TObjString*
>(value);
216 printf(
"%s => %s\n", (keyStr) ? keyStr->GetString().Data() :
"", (valueStr) ? valueStr->GetString().Data() :
"");