Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TStatus.cxx
Go to the documentation of this file.
1// @(#)root/proofplayer:$Id$
2// Author: Maarten Ballintijn 7/06/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/** \class TStatus
13\ingroup proofkernel
14
15This class holds the status of an ongoing operation and collects
16error messages. It provides a Merge() operation allowing it to
17be used in PROOF to monitor status in the slaves.
18No messages indicates success.
19
20*/
21
22#include "TStatus.h"
23#include "Riostream.h"
24#include "TBuffer.h"
25#include "TClass.h"
26#include "TObjString.h"
27#include "TProofDebug.h"
28
30
31////////////////////////////////////////////////////////////////////////////////
32/// Default constructor.
33
34TStatus::TStatus() : fIter(&fMsgs), fExitStatus(-1),
35 fVirtMemMax(-1), fResMemMax(-1),
36 fVirtMaxMst(-1), fResMaxMst(-1)
37{
38 SetName("PROOF_Status");
42}
43
44////////////////////////////////////////////////////////////////////////////////
45/// Add an error message.
46
47void TStatus::Add(const char *mesg)
48{
49 fMsgs.Add(new TObjString(mesg));
51 Reset();
52}
53
54////////////////////////////////////////////////////////////////////////////////
55/// Add an info message.
56
57void TStatus::AddInfo(const char *mesg)
58{
59 fInfoMsgs.Add(new TObjString(mesg));
60}
61
62////////////////////////////////////////////////////////////////////////////////
63/// PROOF Merge() function.
64
66{
67 TIter stats(li);
68 PDB(kOutput,1)
69 Info("Merge", "start: max virtual memory: %.2f MB \tmax resident memory: %.2f MB ",
70 GetVirtMemMax()/1024., GetResMemMax()/1024.);
71 while (TObject *obj = stats()) {
72 TStatus *s = dynamic_cast<TStatus*>(obj);
73 if (s == 0) continue;
74
75 TObjString *os = 0;
76 // Errors
77 TIter nxem(&(s->fMsgs));
78 while ((os = (TObjString *) nxem())) {
79 Add(os->GetName());
80 }
81
82 // Infos (no duplications)
83 TIter nxwm(&(s->fInfoMsgs));
84 while ((os = (TObjString *) nxwm())) {
85 if (!fInfoMsgs.FindObject(os->GetName()))
86 AddInfo(os->GetName());
87 }
88
90 // Check the master values (relevantt if merging submaster info)
92 PDB(kOutput,1)
93 Info("Merge", "during: max virtual memory: %.2f MB \t"
94 "max resident memory: %.2f MB ",
95 GetVirtMemMax()/1024., GetResMemMax()/1024.);
96 if (GetVirtMemMax(kTRUE) > 0) {
97 PDB(kOutput,1)
98 Info("Merge", "during: max master virtual memory: %.2f MB \t"
99 "max master resident memory: %.2f MB ",
100 GetVirtMemMax(kTRUE)/1024., GetResMemMax(kTRUE)/1024.);
101 }
102 }
103
104 return fMsgs.GetSize();
105}
106
107////////////////////////////////////////////////////////////////////////////////
108/// Standard print function.
109
110void TStatus::Print(Option_t * /*option*/) const
111{
112 Printf("OBJ: %s\t%s\t%s", IsA()->GetName(), GetName(), (IsOk() ? "OK" : "ERROR"));
113
114 TObjString *os = 0;
115 // Errors first
116 if (fMsgs.GetSize() > 0) {
117 Printf("\n Errors:");
118 TIter nxem(&fMsgs);
119 while ((os = (TObjString *) nxem()))
120 Printf("\t%s",os->GetName());
121 Printf(" ");
122 }
123
124 // Infos
125 if (fInfoMsgs.GetSize() > 0) {
126 Printf("\n Infos:");
127 TIter nxem(&fInfoMsgs);
128 while ((os = (TObjString *) nxem()))
129 Printf("\t%s",os->GetName());
130 Printf(" ");
131 }
132
133 Printf(" Max worker virtual memory: %.2f MB \tMax worker resident memory: %.2f MB ",
134 GetVirtMemMax()/1024., GetResMemMax()/1024.);
135 Printf(" Max master virtual memory: %.2f MB \tMax master resident memory: %.2f MB ",
136 GetVirtMemMax(kTRUE)/1024., GetResMemMax(kTRUE)/1024.);
137}
138
139////////////////////////////////////////////////////////////////////////////////
140/// Reset the iterator on the messages.
141
143{
144 fIter.Reset();
145}
146
147////////////////////////////////////////////////////////////////////////////////
148/// Return the next message or 0.
149
150const char *TStatus::NextMesg()
151{
152 TObjString *os = (TObjString *) fIter();
153 if (os) return os->GetName();
154 return 0;
155}
156
157////////////////////////////////////////////////////////////////////////////////
158/// Set max memory values
159
161{
162 if (master) {
163 if (vmem > 0. && (fVirtMaxMst < 0. || vmem > fVirtMaxMst)) fVirtMaxMst = vmem;
164 if (rmem > 0. && (fResMaxMst < 0. || rmem > fResMaxMst)) fResMaxMst = rmem;
165 } else {
166 if (vmem > 0. && (fVirtMemMax < 0. || vmem > fVirtMemMax)) fVirtMemMax = vmem;
167 if (rmem > 0. && (fResMemMax < 0. || rmem > fResMemMax)) fResMemMax = rmem;
168 }
169}
170
171////////////////////////////////////////////////////////////////////////////////
172/// Stream an object of class TStatus.
173
175{
176 if (R__b.IsReading()) {
177 UInt_t R__s, R__c;
178 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
179 if (R__v > 4) {
180 R__b.ReadClassBuffer(TStatus::Class(), this, R__v, R__s, R__c);
181 } else {
182 // For version <= 4 masters we need a special streamer
183 TNamed::Streamer(R__b);
184 std::set<std::string> msgs;
185 TClass *cl = TClass::GetClass("set<string>");
186 if (cl) {
187 UInt_t SS__s = 0, SS__c = 0;
188 UInt_t SS__v = cl->GetClassVersion();
189 R__b.ReadClassBuffer(cl, &msgs, SS__v, SS__s, SS__c);
190 } else {
191 Error("Streamer", "no info found for 'set<string>' - skip");
192 return;
193 }
194 std::set<std::string>::const_iterator it;
195 for (it = msgs.begin(); it != msgs.end(); ++it) {
196 fMsgs.Add(new TObjString((*it).c_str()));
197 }
198 if (R__v > 2) {
199 R__b >> fExitStatus;
200 }
201 if (R__v > 1) {
202 R__b >> fVirtMemMax;
203 R__b >> fResMemMax;
204 }
205 if (R__v > 3) {
206 R__b >> fVirtMaxMst;
207 R__b >> fResMaxMst;
208 }
209 }
210 } else {
211 R__b.WriteClassBuffer(TStatus::Class(),this);
212 }
213}
214
215
short Version_t
Definition RtypesCore.h:65
long Long_t
Definition RtypesCore.h:54
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
#define PDB(mask, level)
Definition TProofDebug.h:56
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2503
Buffer base class used for serializing objects.
Definition TBuffer.h:43
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
Bool_t IsReading() const
Definition TBuffer.h:86
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
Version_t GetClassVersion() const
Definition TClass.h:418
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2968
Collection abstract base class.
Definition TCollection.h:65
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
TObject * FindObject(const char *name) const override
Find object using its name.
void Reset()
void Add(TObject *obj) override
Definition TList.h:81
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
void Streamer(TBuffer &) override
Stream an object of class TObject.
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:140
Collectable string class.
Definition TObjString.h:28
const char * GetName() const override
Returns name of object.
Definition TObjString.h:38
Mother of all ROOT objects.
Definition TObject.h:41
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:780
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:976
void ResetBit(UInt_t f)
Definition TObject.h:200
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:950
This class holds the status of an ongoing operation and collects error messages.
Definition TStatus.h:32
TStatus()
Default constructor.
Definition TStatus.cxx:34
TIter fIter
Definition TStatus.h:41
const char * NextMesg()
Return the next message or 0.
Definition TStatus.cxx:150
Int_t fExitStatus
Definition TStatus.h:44
void Add(const char *mesg)
Add an error message.
Definition TStatus.cxx:47
void Reset()
Reset the iterator on the messages.
Definition TStatus.cxx:142
virtual Int_t Merge(TCollection *list)
PROOF Merge() function.
Definition TStatus.cxx:65
void Print(Option_t *option="") const override
Standard print function.
Definition TStatus.cxx:110
Long_t fResMaxMst
Definition TStatus.h:48
void SetMemValues(Long_t vmem=-1, Long_t rmem=-1, Bool_t master=kFALSE)
Set max memory values.
Definition TStatus.cxx:160
Bool_t IsOk() const
Definition TStatus.h:54
THashList fInfoMsgs
iterator in messages
Definition TStatus.h:42
Long_t fResMemMax
Definition TStatus.h:46
TList fMsgs
Definition TStatus.h:40
Long_t fVirtMemMax
Definition TStatus.h:45
Long_t GetResMemMax(Bool_t master=kFALSE) const
Definition TStatus.h:63
Long_t GetVirtMemMax(Bool_t master=kFALSE) const
Definition TStatus.h:64
void AddInfo(const char *mesg)
Add an info message.
Definition TStatus.cxx:57
static TClass * Class()
TClass * IsA() const override
Definition TStatus.h:69
Long_t fVirtMaxMst
Definition TStatus.h:47
@ kNotOk
Definition TStatus.h:36
void Streamer(TBuffer &) override
Stream an object of class TStatus.
Definition TStatus.cxx:174