ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TAlienJob.cxx
Go to the documentation of this file.
1 // @(#)root/alien:$Id$
2 // Author: Jan Fiete Grosse-Oetringhaus 06/10/2004
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TAlienJob //
15 // //
16 // Alien implentation of TGridJob //
17 // //
18 // Related classes are TAlienJobStatus. //
19 // //
20 //////////////////////////////////////////////////////////////////////////
21 
22 #include "TGrid.h"
23 #include "TAlienJob.h"
24 #include "TAlienJobStatus.h"
25 #include "TObjString.h"
26 #include "gapi_job_operations.h"
27 
29 
30 
31 ////////////////////////////////////////////////////////////////////////////////
32 /// Queries the job for its status and returns a TGridJobStatus object.
33 /// Returns 0 in case of failure.
34 
35 TGridJobStatus *TAlienJob::GetJobStatus() const
36 {
37  TString jobID;
38  jobID = fJobID;
39 
40  GAPI_JOBARRAY *gjobarray = gapi_queryjobs("-", "%", "-", "-", "-", "-",
41  jobID.Data(), "-", "-");
42 
43  if (!gjobarray)
44  return 0;
45 
46  if (gjobarray->size() == 0) {
47  delete gjobarray;
48  return 0;
49  }
50 
52 
53  GAPI_JOB gjob = gjobarray->at(0);
54  std::map<std::string, std::string>::const_iterator iter = gjob.gapi_jobmap.begin();
55  for (; iter != gjob.gapi_jobmap.end(); ++iter) {
56  status->fStatus.Add(new TObjString(iter->first.c_str()), new TObjString(iter->second.c_str()));
57  }
58 
59  delete gjobarray;
60 
61  return status;
62 }
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 /// Cancels a job e.g. sends a kill command.
66 /// Returns kFALSE in case of failure, otherwise kTRUE.
67 
69 {
70  if (gGrid) {
71  return gGrid->Kill((TGridJob*)this);
72  }
73  Error("Cancel","No GRID connection (gGrid=0)");
74  return kFALSE;
75 }
76 
77 ////////////////////////////////////////////////////////////////////////////////
78 /// Resubmits a job.
79 /// Returns kFALSE in case of failure, otherwise kTRUE.
80 
82 {
83  if (gGrid) {
84  return gGrid->Resubmit((TGridJob*)this);
85  }
86  Error("Cancel","No GRID connection (gGrid=0)");
87  return kFALSE;
88 }
ClassImp(TAlienJob) TGridJobStatus *TAlienJob jobID
Queries the job for its status and returns a TGridJobStatus object.
Definition: TAlienJob.cxx:38
Collectable string class.
Definition: TObjString.h:32
virtual Bool_t Kill(TGridJob *gridjob)
Definition: TGrid.h:123
R__EXTERN TGrid * gGrid
Definition: TGrid.h:135
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection)...
Definition: TMap.cxx:53
virtual Bool_t Resubmit()
Resubmits a job.
Definition: TAlienJob.cxx:81
Basic string class.
Definition: TString.h:137
TAlienJobStatus * status
Definition: TAlienJob.cxx:51
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
const char * Data() const
Definition: TString.h:349
std::map< std::string, std::string >::const_iterator iter
Definition: TAlienJob.cxx:54
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
virtual Bool_t Resubmit(TGridJob *gridjob)
Definition: TGrid.h:125
#define ClassImp(name)
Definition: Rtypes.h:279
virtual Bool_t Cancel()
Cancels a job e.g.
Definition: TAlienJob.cxx:68
GAPI_JOBARRAY * gjobarray
Definition: TAlienJob.cxx:40