Logo ROOT   6.21/01
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 
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 
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 
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
virtual Bool_t SendInfoStatus(const char *status)
Sends a <status> text to MonaLisa following the process scheme: <site> –> <jobid> –> &#39;status&#39; = <st...
TStopwatch fFileStopwatch
virtual Bool_t SendFileWriteProgress(TFile *file)
virtual Bool_t SendFileCloseEvent(TFile *file)
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()
void Init(const char *monserver, const char *montag, const char *monid, const char *monsubid, const char *option)
Creates a TMonaLisaWriter object to send monitoring information to a MonaLisa server using the MonaLi...
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:48
const char * GetText() const
Basic string class.
Definition: TString.h:131
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual Bool_t SendProcessingProgress(Double_t nevent, Double_t nbytes, Bool_t force=kFALSE)
Send the procesing progress to MonaLisa.
TStopwatch fStopwatch
TMonaLisaValue & operator=(const TMonaLisaValue &)
TMonaLisaWriter(const TMonaLisaWriter &)
Double_t fLastFCloseSendTime
virtual void SetLogLevel(const char *loglevel="WARNING")
Set MonaLisa log level.
virtual Bool_t SendFileOpenProgress(TFile *file, TList *openphases, const char *openphasename, Bool_t forcesend=kFALSE)
Send the fileopen progress to MonaLisa.
virtual ~TMonaLisaText()
TString fJobId
connection to MonaLisa
#define ClassDef(name, id)
Definition: Rtypes.h:326
virtual Bool_t SendInfoTime()
Sends the current time to MonaLisa following the processing scheme <site> –> <jobid> –> &#39;time&#39; = >u...
virtual ~TMonaLisaWriter()
Cleanup.
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual Bool_t SendInfoUser(const char *user=0)
Sends the <user> text to MonaLisa following the process scheme: <site> –> <jobid> –> &#39;user&#39; = <user...
TMonaLisaText(const char *name, const char *text)
Bool_t fInitialized
process id
virtual Bool_t SendParameters(TList *valuelist, const char *identifier=0)
Send the parameters to MonaLisa.
Int_t fReportInterval
repo to gather per-file-instance mon info;
A doubly linked list.
Definition: TList.h:44
TMonaLisaWriter & operator=(const TMonaLisaWriter &)
time_t fLastProgressTime
TString fSubJobId
job id
virtual ~TMonaLisaValue()
const Bool_t kFALSE
Definition: RtypesCore.h:88
double Double_t
Definition: RtypesCore.h:55
TText * text
virtual Bool_t SendProcessingStatus(const char *status, Bool_t restarttimer=kFALSE)
Send the procesing status &#39;status&#39; to MonaLisa following the processing scheme: <site> –> <jobid> –...
Definition: file.py:1
virtual Bool_t SendInfoDescription(const char *jobtag)
Sends the description <jobtag> following the processing scheme: <site> –> <jobid> –> &#39;jobname&#39; = <j...
void Print(Option_t *option="") const
Print info about MonaLisa object.
Double_t GetValue() const
std::map< UInt_t, MonitoredTFileInfo * > * fMonInfoRepo
Double_t fLastRWSendTime
Bool_t SendFileCheckpoint(TFile *file)
char name[80]
Definition: TGX11.cxx:109
virtual Bool_t SendFileReadProgress(TFile *file)
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