KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVLogReader.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2 $Id: KVLogReader.cpp,v 1.13 2008/12/08 14:07:37 franklan Exp $
3 *******************************************************************************/
4 #include "KVLogReader.h"
5 #include "Riostream.h"
6 #include "TObjArray.h"
7 #include "TObjString.h"
8 #include "KVConfig.h"
9 
10 using namespace std;
11 
13 
14 
15 
18 {
19  fFMT = "%d";
20  Reset();
21 }
22 
23 
24 
27 
29 {
30  //reset informations read from file
31  fCPUused = fCPUreq = fSCRreq = fMEMreq = fScratchKB = fMemKB = 0;
32  fStatus = "";
33  fOK = kFALSE;
34  fGotRequests = kFALSE;
35  fGotStatus = kFALSE;
36 }
37 
38 
39 
42 
43 void KVLogReader::ReadFile(const Char_t* fname)
44 {
45  //Open file 'fname' and read contents
46 
47  Reset(); //clear last read infos
48 
49  ifstream filestream(fname);
50  if (!filestream.good()) {
51  cout << "Error in KVLogReader::ReadFile - cannot open file " << fname
52  << endl;
53  return;
54  }
55  KVString line;
56  line.ReadLine(filestream);
57  Bool_t ok = kTRUE;
58  while (filestream.good() && ok) {
59  ReadLine(line, ok); //perform action based on content of line
60  line.ReadLine(filestream);
61  }
62  filestream.close();
63 }
64 
65 
66 
73 
74 void KVLogReader::ReadLine(const KVString& line, Bool_t& ok)
75 {
76  //analyse contents of line read from log file
77  //
78  //if line contains "segmentation" then we put ok=kFALSE to stop reading file
79  //
80  //status will equal the contents of the current line
81 
82  ok = kTRUE;
83  if (line.Contains("egmentation")) {
84  ok = kFALSE;
85  fStatus = line;
86  fOK = kFALSE;
87  }
88  else if (line.Contains("Temps limite atteint")) {
89  //VEDA FORTRAN programme 'out of time' error seen during DST conversion
90  ok = kFALSE;
91  fStatus = "VEDA Fortran out of time";
92  fOK = kFALSE;
93  }
94  else if (line.Contains("rfcp : Input/output error")) {
95  //failure to copy new run to hpss system at ccali
96  ok = kFALSE;
97  fStatus = "rfcp error";
98  fOK = kFALSE;
99  }
100  else if (line.Contains("TXNetFile") && line.Contains("open attempt failed")) {
101  //failure to open recon file with xrootd
102  ok = kFALSE;
103  fStatus = "XROOTD error";
104  fOK = kFALSE;
105  }
106 }
107 
108 
109 
112 
114 {
115  //calculate ratio of used CPU to requested CPU
116  return (fCPUreq ? fCPUused / fCPUreq : 0.);
117 }
118 
119 
120 
124 
126 {
127  //Read lines "DISK_REQ: 3GB" and "MEM_REQ: 150MB"
128  //and fill corresponding variable with appropriate value
129 
130  line.Begin("*:");
131  KVString type = line.Next(kTRUE);
132  KVString stor = line.Next(kTRUE);
133  Double_t size = ReadStorage(stor);
134  if (type == "DISK_REQ")
135  fSCRreq = size;
136  else if (type == "MEM_REQ")
137  fMEMreq = size;
138  // both requests must be present in the logfile otherwise
139  // something very wrong has happened
140  if (fSCRreq && fMEMreq) fGotRequests = kTRUE;
141 }
142 
143 
144 
148 
150 {
151  //read line of type "* Jobname: run4049 *"
152  //with name of job.
153  unique_ptr<TObjArray> toks(line.Tokenize("*: "));
154  fJobname = ((TObjString*) toks->At(1))->GetString();
155 }
156 
157 
158 
161 
163 {
164  //try to get run number from jobname using format string fFMT
165  Int_t run;
166  sscanf(fJobname.Data(), fFMT.Data(), &run);
167  return run;
168 }
169 
170 
171 
180 
182 {
183  // job considered incomplete if
184  // - it was not 'killed'
185  // - it did not end in segmentation fault/violation
186  // AND
187  // - the end of job status report was not found
188  // - OR the disk & memory requests were not found
189  // - OR the status indicates the job was incomplete
190 
191  return (
192  (!Killed() && !SegFault())
193  &&
194  (
195  (!fGotStatus)
196  || (!fGotRequests)
197  || (fStatus == "VEDA Fortran out of time")
198  || (fStatus.BeginsWith("rfcp"))
199  )
200  );
201 };
202 
203 
int Int_t
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
size_t size(const MatrixT &matrix)
char Char_t
const Bool_t kFALSE
bool Bool_t
double Double_t
const Bool_t kTRUE
int type
Base class for reading batch log files at CC-IN2P3.
Definition: KVLogReader.h:15
virtual void ReadLine(const KVString &line, Bool_t &)
Definition: KVLogReader.cpp:74
void ReadStorageReq(const KVString &line)
void ReadJobname(const KVString &line)
Double_t GetCPUratio() const
calculate ratio of used CPU to requested CPU
void ReadFile(const Char_t *fname)
Open file 'fname' and read contents.
Definition: KVLogReader.cpp:43
virtual void Reset()
reset informations read from file
Definition: KVLogReader.cpp:28
virtual Bool_t Incomplete() const
Int_t GetRunNumber() const
try to get run number from jobname using format string fFMT
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:72
TLine * line