TMonaLisaWriter.h

Go to the documentation of this file.
00001 // @(#)root/monalisa:$Id: TMonaLisaWriter.h 23209 2008-04-14 13:25:09Z rdm $
00002 // Author: Andreas Peters   5/10/2005
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TMonaLisaWriter
00013 #define ROOT_TMonaLisaWriter
00014 
00015 #ifndef ROOT_TVirtualMonitoring
00016 #include "TVirtualMonitoring.h"
00017 #endif
00018 #ifndef ROOT_TStopwatch
00019 #include "TStopwatch.h"
00020 #endif
00021 
00022 #ifndef __CINT__
00023 #include <ApMon.h>
00024 #else
00025 struct ApMon;
00026 #endif
00027 
00028 #include <time.h>
00029 #include <map>
00030 
00031 class MonitoredTFileInfo;
00032 
00033 //////////////////////////////////////////////////////////////////////////
00034 //                                                                      //
00035 // TMonaLisaWriter                                                      //
00036 //                                                                      //
00037 // Class defining interface to MonaLisa Monitoring Services in ROOT.    //
00038 // The TMonaLisaWriter object is used to send monitoring information to //
00039 // a MonaLisa server using the ML ApMon package (libapmoncpp.so/UDP     //
00040 // packets). The MonaLisa ApMon library for C++ can be downloaded at    //
00041 // http://monalisa.cacr.caltech.edu/monalisa__Download__ApMon.html,     //
00042 // current version:                                                     //
00043 //http://monalisa.cacr.caltech.edu/download/apmon/ApMon_cpp-2.2.0.tar.gz//
00044 //                                                                      //
00045 // The ROOT implementation is primary optimized for process/job         //
00046 // monitoring, although all other generic MonaLisa ApMon functionality  //
00047 // can be exploited through the ApMon class directly via                //
00048 // dynamic_cast<TMonaLisaWriter*>(gMonitoringWriter)->GetApMon().       //
00049 //                                                                      //
00050 //////////////////////////////////////////////////////////////////////////
00051 
00052 class TMonaLisaValue : public TNamed {
00053 
00054 private:
00055    Double_t fValue;  // double monitor value
00056 
00057    TMonaLisaValue(const TMonaLisaValue&); // Not implented
00058    TMonaLisaValue& operator=(const TMonaLisaValue&); // Not implented
00059 
00060 public:
00061    TMonaLisaValue(const char *name, Double_t value)
00062       : TNamed(name, ""), fValue(value) { }
00063    virtual ~TMonaLisaValue() { }
00064 
00065    Double_t  GetValue() const { return fValue; }
00066    Double_t *GetValuePtr() { return &fValue; }
00067 
00068    ClassDef(TMonaLisaValue, 1)  // Interface to MonaLisa Monitoring Values
00069 };
00070 
00071 
00072 class TMonaLisaText : public TNamed {
00073 
00074 public:
00075    TMonaLisaText(const char *name, const char *text) : TNamed(name, text) { }
00076    virtual ~TMonaLisaText() { }
00077 
00078    const char *GetText() const { return GetTitle(); }
00079 
00080    ClassDef(TMonaLisaText, 1)   // Interface to MonaLisa Monitoring Text
00081 };
00082 
00083 
00084 class TMonaLisaWriter : public TVirtualMonitoringWriter {
00085 
00086 private:
00087    ApMon     *fApmon;            //! connection to MonaLisa
00088    TString    fJobId;            //! job id
00089    TString    fSubJobId;         //! sub job id
00090    TString    fHostname;         //! hostname of MonaLisa server
00091    Int_t      fPid;              //! process id
00092    Bool_t     fInitialized;      // true if initialized
00093    Bool_t     fVerbose;          // verbocity
00094    Double_t   fLastRWSendTime;     // timestamp of the last send command for file reads/writes
00095    Double_t   fLastFCloseSendTime; // In order not to flood ML servers
00096    time_t     fLastProgressTime; // timestamp of the last send command for player process
00097 
00098    std::map<UInt_t,  MonitoredTFileInfo *>   //!
00099              *fMonInfoRepo;      //! repo to gather per-file-instance mon info;
00100                                  // ROOT should really have something like this
00101 
00102    Int_t      fReportInterval;   // interval after which to send the latest value
00103 
00104    TStopwatch fStopwatch;        // cpu and time measurement for job and proc status
00105    TStopwatch fFileStopwatch;     // time measurements for data access throughputs
00106 
00107    TMonaLisaWriter(const TMonaLisaWriter&); // Not implemented
00108    TMonaLisaWriter& operator=(const TMonaLisaWriter&); // Not implemented
00109 
00110    void Init(const char *monserver, const char *montag, const char *monid,
00111              const char *monsubid, const char *option);
00112 
00113    Bool_t SendFileCheckpoint(TFile *file);
00114 public:
00115    TMonaLisaWriter(const char *monserver, const char *montag, const char *monid = 0,
00116                    const char *monsubid = 0, const char *option = "");
00117 
00118    virtual ~TMonaLisaWriter();
00119 
00120    ApMon *GetApMon() const { return fApmon; }
00121 
00122    virtual Bool_t SendParameters(TList *valuelist, const char *identifier = 0);
00123    virtual Bool_t SendInfoTime();
00124    virtual Bool_t SendInfoUser(const char *user = 0);
00125    virtual Bool_t SendInfoDescription(const char *jobtag);
00126    virtual Bool_t SendInfoStatus(const char *status);
00127 
00128    virtual Bool_t SendFileCloseEvent(TFile *file);
00129 
00130    // An Open might have several phases, and the timings might be interesting
00131    // to report
00132    // The info is only gathered, and sent when forcesend=kTRUE
00133    virtual Bool_t SendFileOpenProgress(TFile *file, TList *openphases, const char *openphasename,
00134                                Bool_t forcesend = kFALSE);
00135 
00136    virtual Bool_t SendFileReadProgress(TFile *file);
00137    virtual Bool_t SendFileWriteProgress(TFile *file);
00138 
00139    virtual Bool_t SendProcessingStatus(const char *status, Bool_t restarttimer=kFALSE);
00140    virtual Bool_t SendProcessingProgress(Double_t nevent, Double_t nbytes, Bool_t force=kFALSE);
00141    virtual void   SetLogLevel(const char *loglevel = "WARNING");
00142    virtual void   Verbose(Bool_t onoff) { fVerbose = onoff; }
00143 
00144    void   Print(Option_t *option = "") const;
00145 
00146    ClassDef(TMonaLisaWriter, 1)   // Interface to MonaLisa Monitoring
00147 };
00148 
00149 #endif

Generated on Tue Jul 5 14:45:41 2011 for ROOT_528-00b_version by  doxygen 1.5.1