Logo ROOT   6.10/09
Reference Guide
TMonaLisaWriter.h
Go to the documentation of this file.
1 // @(#)root/monalisa:$Id$
2 // Author: Andreas Peters 5/10/2005
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2006, 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 #ifndef ROOT_TMonaLisaWriter
13 #define ROOT_TMonaLisaWriter
14 
15 #include "TVirtualMonitoring.h"
16 #include "TStopwatch.h"
17 
18 #ifndef __CINT__
19 #include <ApMon.h>
20 #else
21 struct ApMon;
22 #endif
23 
24 #include <time.h>
25 #include <map>
26 
27 class MonitoredTFileInfo;
28 
29 //////////////////////////////////////////////////////////////////////////
30 // //
31 // TMonaLisaWriter //
32 // //
33 // Class defining interface to MonaLisa Monitoring Services in ROOT. //
34 // The TMonaLisaWriter object is used to send monitoring information to //
35 // a MonaLisa server using the ML ApMon package (libapmoncpp.so/UDP //
36 // packets). The MonaLisa ApMon library for C++ can be downloaded at //
37 // http://monalisa.cacr.caltech.edu/monalisa__Download__ApMon.html, //
38 // current version: //
39 //http://monalisa.cacr.caltech.edu/download/apmon/ApMon_cpp-2.2.0.tar.gz//
40 // //
41 // The ROOT implementation is primary optimized for process/job //
42 // monitoring, although all other generic MonaLisa ApMon functionality //
43 // can be exploited through the ApMon class directly via //
44 // dynamic_cast<TMonaLisaWriter*>(gMonitoringWriter)->GetApMon(). //
45 // //
46 //////////////////////////////////////////////////////////////////////////
47 
48 class TMonaLisaValue : public TNamed {
49 
50 private:
51  Double_t fValue; // double monitor value
52 
53  TMonaLisaValue(const TMonaLisaValue&); // Not implented
54  TMonaLisaValue& operator=(const TMonaLisaValue&); // Not implented
55 
56 public:
57  TMonaLisaValue(const char *name, Double_t value)
58  : TNamed(name, ""), fValue(value) { }
59  virtual ~TMonaLisaValue() { }
60 
61  Double_t GetValue() const { return fValue; }
62  Double_t *GetValuePtr() { return &fValue; }
63 
64  ClassDef(TMonaLisaValue, 1) // Interface to MonaLisa Monitoring Values
65 };
66 
67 
68 class TMonaLisaText : public TNamed {
69 
70 public:
71  TMonaLisaText(const char *name, const char *text) : TNamed(name, text) { }
72  virtual ~TMonaLisaText() { }
73 
74  const char *GetText() const { return GetTitle(); }
75 
76  ClassDef(TMonaLisaText, 1) // Interface to MonaLisa Monitoring Text
77 };
78 
79 
81 
82 private:
83  ApMon *fApmon; //! connection to MonaLisa
84  TString fJobId; //! job id
85  TString fSubJobId; //! sub job id
86  TString fHostname; //! hostname of MonaLisa server
87  Int_t fPid; //! process id
88  Bool_t fInitialized; // true if initialized
89  Bool_t fVerbose; // verbocity
90  Double_t fLastRWSendTime; // timestamp of the last send command for file reads/writes
91  Double_t fLastFCloseSendTime; // In order not to flood ML servers
92  time_t fLastProgressTime; // timestamp of the last send command for player process
93 
94  std::map<UInt_t, MonitoredTFileInfo *> //!
95  *fMonInfoRepo; //! repo to gather per-file-instance mon info;
96  // ROOT should really have something like this
97 
98  Int_t fReportInterval; // interval after which to send the latest value
99 
100  TStopwatch fStopwatch; // cpu and time measurement for job and proc status
101  TStopwatch fFileStopwatch; // time measurements for data access throughputs
102 
103  TMonaLisaWriter(const TMonaLisaWriter&); // Not implemented
104  TMonaLisaWriter& operator=(const TMonaLisaWriter&); // Not implemented
105 
106  void Init(const char *monserver, const char *montag, const char *monid,
107  const char *monsubid, const char *option);
108 
109  Bool_t SendFileCheckpoint(TFile *file);
110 public:
111  TMonaLisaWriter(const char *monserver, const char *montag, const char *monid = 0,
112  const char *monsubid = 0, const char *option = "");
113 
114  virtual ~TMonaLisaWriter();
115 
116  ApMon *GetApMon() const { return fApmon; }
117 
118  virtual Bool_t SendParameters(TList *valuelist, const char *identifier = 0);
119  virtual Bool_t SendInfoTime();
120  virtual Bool_t SendInfoUser(const char *user = 0);
121  virtual Bool_t SendInfoDescription(const char *jobtag);
122  virtual Bool_t SendInfoStatus(const char *status);
123 
124  virtual Bool_t SendFileCloseEvent(TFile *file);
125 
126  // An Open might have several phases, and the timings might be interesting
127  // to report
128  // The info is only gathered, and sent when forcesend=kTRUE
129  virtual Bool_t SendFileOpenProgress(TFile *file, TList *openphases, const char *openphasename,
130  Bool_t forcesend = kFALSE);
131 
132  virtual Bool_t SendFileReadProgress(TFile *file);
133  virtual Bool_t SendFileWriteProgress(TFile *file);
134 
135  virtual Bool_t SendProcessingStatus(const char *status, Bool_t restarttimer=kFALSE);
136  virtual Bool_t SendProcessingProgress(Double_t nevent, Double_t nbytes, Bool_t force=kFALSE);
137  virtual void SetLogLevel(const char *loglevel = "WARNING");
138  virtual void Verbose(Bool_t onoff) { fVerbose = onoff; }
139 
140  void Print(Option_t *option = "") const;
141 
142  ClassDef(TMonaLisaWriter, 1) // Interface to MonaLisa Monitoring
143 };
144 
145 #endif
TStopwatch fFileStopwatch
TMonaLisaValue(const char *name, Double_t value)
TString fHostname
sub job id
ApMon * GetApMon() const
TMonaLisaValue(const TMonaLisaValue &)
virtual void Verbose(Bool_t onoff)
const char Option_t
Definition: RtypesCore.h:62
Double_t * GetValuePtr()
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
const char * GetText() const
Basic string class.
Definition: TString.h:129
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TStopwatch fStopwatch
TMonaLisaValue & operator=(const TMonaLisaValue &)
Double_t fLastFCloseSendTime
virtual ~TMonaLisaText()
TString fJobId
connection to MonaLisa
#define ClassDef(name, id)
Definition: Rtypes.h:297
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
TMonaLisaText(const char *name, const char *text)
Bool_t fInitialized
process id
Int_t fReportInterval
repo to gather per-file-instance mon info;
virtual void Print(Option_t *option="") const
Print TNamed name and title.
Definition: TNamed.cxx:119
A doubly linked list.
Definition: TList.h:43
time_t fLastProgressTime
TString fSubJobId
job id
virtual ~TMonaLisaValue()
const Bool_t kFALSE
Definition: RtypesCore.h:92
double Double_t
Definition: RtypesCore.h:55
TText * text
Definition: file.py:1
Double_t GetValue() const
std::map< UInt_t, MonitoredTFileInfo * > * fMonInfoRepo
Double_t fLastRWSendTime
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
Int_t fPid
hostname of MonaLisa server
Stopwatch class.
Definition: TStopwatch.h:28