Logo ROOT   6.07/09
Reference Guide
TAlienMasterJobStatus.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 // TAlienMasterJobStatus //
15 // //
16 // Status of a MasterJob //
17 // //
18 //////////////////////////////////////////////////////////////////////////
19 
20 #include "TAlienJobStatus.h"
21 #include "TAlienMasterJobStatus.h"
22 #include "TObjString.h"
23 #include "TBrowser.h"
24 
26 
27 ////////////////////////////////////////////////////////////////////////////////
28 /// Cleanup.
29 
31 {
32  fJobs.DeleteAll();
33 
34  if (fMasterJob)
35  delete fMasterJob;
36 }
37 
38 ////////////////////////////////////////////////////////////////////////////////
39 /// Browser interface.
40 
42 {
43  if (b) {
44  // TString status("");
45  // status += GetStatus();
46  // b->Add(new TNamed(status, TString("overall status")));
47  // status = "";
48  // status += PercentFinished();
49  // b->Add(new TNamed(status, TString("percentage finished")));
50 
51  TIterator* iter = fJobs.MakeIterator();
52 
53  TObject* obj = 0;
54  while ((obj = iter->Next()) != 0) {
55  TObjString* keyStr = dynamic_cast<TObjString*>(obj);
56  TObject* value = fJobs.GetValue(obj);
57 
58  if (keyStr && value)
59  b->Add(value, keyStr->GetString().Data());
60  }
61  delete iter;
62  }
63 }
64 
65 ////////////////////////////////////////////////////////////////////////////////
66 /// Returns the status of the master job reduced to the subset defined
67 /// in TGridJobStatus.
68 
70 {
71  if (!fMasterJob)
72  return kUNKNOWN;
73 
74  return fMasterJob->GetStatus();
75 }
76 
77 ////////////////////////////////////////////////////////////////////////////////
78 /// Returns the percentage of finished subjobs, only DONE is considered
79 /// as finished.
80 
82 {
83  if (fJobs.GetSize() == 0)
84  return 0;
85 
86  TIterator* iter = fJobs.MakeIterator();
87 
88  Int_t done = 0;
89 
90  TObject* obj = 0;
91  while ((obj = iter->Next()) != 0) {
92  TObject* value = fJobs.GetValue(obj);
93  TAlienJobStatus* jobStatus = dynamic_cast<TAlienJobStatus*>(value);
94 
95  if (jobStatus) {
96  if (jobStatus->GetStatus() == kDONE)
97  ++done;
98  }
99  }
100 
101  delete iter;
102 
103  return (Float_t) done / fJobs.GetSize();
104 }
105 
106 ////////////////////////////////////////////////////////////////////////////////
107 /// Prints information of the master job and the sub job. Only the status is printed.
108 
110 {
111  if (fMasterJob) {
112  printf("Printing information for the master job: ");
114  }
115 
116  TIterator* iter = fJobs.MakeIterator();
117 
118  TObject* obj = 0;
119  while ((obj = iter->Next()) != 0) {
120  TObjString* keyStr = dynamic_cast<TObjString*>(obj);
121 
122  TObject* value = fJobs.GetValue(obj);
123  TAlienJobStatus* jobStatus = dynamic_cast<TAlienJobStatus*>(value);
124 
125  if (keyStr && jobStatus) {
126  printf("Printing info for subjob %s: ", keyStr->GetString().Data());
127  jobStatus->PrintJob(kFALSE);
128  }
129  }
130  delete iter;
131 }
void Add(TObject *obj, const char *name=0, Int_t check=-1)
Add object with name to browser.
Definition: TBrowser.cxx:261
Collectable string class.
Definition: TObjString.h:32
EGridJobStatus GetStatus() const
Returns the status of the master job reduced to the subset defined in TGridJobStatus.
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
Float_t PercentFinished()
Returns the percentage of finished subjobs, only DONE is considered as finished.
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: Rtypes.h:92
Iterator abstract base class.
Definition: TIterator.h:32
void PrintJob(Bool_t full=kTRUE) const
Prints this job.
const char * Data() const
Definition: TString.h:349
TAlienJobStatus * fMasterJob
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
Definition: TMap.cxx:235
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
TString GetString() const
Definition: TObjString.h:50
TIterator * MakeIterator(Bool_t dir=kIterForward) const
Create an iterator for TMap.
Definition: TMap.cxx:257
virtual EGridJobStatus GetStatus() const
Gets the status of the job reduced to the subset defined in TGridJobStatus.
void Browse(TBrowser *b)
Browser interface.
virtual Int_t GetSize() const
Definition: TCollection.h:95
#define ClassImp(name)
Definition: Rtypes.h:279
Mother of all ROOT objects.
Definition: TObject.h:44
void Print(Option_t *) const
Prints information of the master job and the sub job. Only the status is printed. ...
virtual TObject * Next()=0
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630