TProofMgr.h

Go to the documentation of this file.
00001 // @(#)root/proof:$Id: TProofMgr.h 30791 2009-10-19 07:07:32Z ganis $
00002 // Author: G. Ganis, Nov 2005
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2005, 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_TProofMgr
00013 #define ROOT_TProofMgr
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TProofMgr                                                            //
00019 //                                                                      //
00020 // The PROOF manager interacts with the PROOF server coordinator to     //
00021 // create or destroy a PROOF session, attach to or detach from          //
00022 // existing one, and to monitor any client activity on the cluster.     //
00023 // At most one manager instance per server is allowed.                  //
00024 //                                                                      //
00025 //////////////////////////////////////////////////////////////////////////
00026 
00027 #ifndef ROOT_TNamed
00028 #include "TNamed.h"
00029 #endif
00030 #ifndef ROOT_TUrl
00031 #include "TUrl.h"
00032 #endif
00033 #ifndef ROOT_TSystem
00034 #include "TSystem.h"
00035 #endif
00036 
00037 class TList;
00038 class TObjString;
00039 class TProof;
00040 class TProofDesc;
00041 class TProofLog;
00042 class TProofMgr;
00043 class TSignalHandler;
00044 
00045 typedef TProofMgr *(*TProofMgr_t)(const char *, Int_t, const char *);
00046 
00047 class TProofMgr : public TNamed {
00048 
00049 public:
00050    enum EServType { kProofd = 0, kXProofd = 1, kProofLite = 2 };
00051 
00052 private:
00053    TProofMgr(const TProofMgr&); // Not implemented
00054    TProofMgr& operator=(const TProofMgr&); // Not implemented
00055 
00056    static TProofMgr_t fgTXProofMgrHook; // Constructor hooks for TXProofMgr
00057    static TProofMgr_t GetXProofMgrHook();
00058 
00059 protected:
00060    Int_t          fRemoteProtocol; // Protocol number run by the daemon server
00061    EServType      fServType;       // Type of server: old-proofd, XrdProofd
00062    TList         *fSessions;       // PROOF session managed by this server
00063    TUrl           fUrl;            // Server URL
00064 
00065    TSignalHandler *fIntHandler;    // Interrupt signal handler (ctrl-c)
00066 
00067    static TList   fgListOfManagers; // Sub-list of TROOT::ListOfProofs for managers
00068 
00069    TProofMgr() : fRemoteProtocol(-1),
00070                         fServType(kXProofd), fSessions(0), fUrl(), fIntHandler(0) { }
00071 
00072 public:
00073    TProofMgr(const char *url, Int_t loglevel = -1, const char *alias = "");
00074    virtual ~TProofMgr();
00075 
00076    virtual Bool_t      IsLite() const { return (fServType == kProofLite); }
00077    virtual Bool_t      IsProofd() const { return (fServType == kProofd); }
00078    virtual Bool_t      IsValid() const { return kTRUE; }
00079    virtual void        SetInvalid() { }
00080 
00081    virtual TProof     *AttachSession(Int_t, Bool_t = kFALSE);
00082    virtual TProof     *AttachSession(TProofDesc *, Bool_t = kFALSE);
00083    virtual TProof     *CreateSession(const char * = 0, const char * = 0, Int_t = -1);
00084    virtual void        DetachSession(Int_t, Option_t * = "");
00085    virtual void        DetachSession(TProof *, Option_t * = "");
00086    virtual void        DiscardSession(TProof *p);
00087    virtual TProofDesc *GetProofDesc(Int_t id);
00088    virtual TProofDesc *GetProofDesc(TProof *p);
00089    virtual Int_t       GetRemoteProtocol() const { return fRemoteProtocol; }
00090    virtual TProofLog  *GetSessionLogs(Int_t = 0, const char * = 0, const char * = "-v \"| SvcMsg\"")
00091                                                       { return (TProofLog *)0; }
00092    virtual const char *GetUrl() { return fUrl.GetUrl(); }
00093    virtual Bool_t      MatchUrl(const char *url);
00094    virtual TList      *QuerySessions(Option_t *opt = "S");
00095    virtual TObjString *ReadBuffer(const char *, Long64_t, Int_t)
00096                                         { return (TObjString *)0; }
00097    virtual TObjString *ReadBuffer(const char *, const char *)
00098                                         { return (TObjString *)0; }
00099    virtual Int_t       Reset(Bool_t hard = kFALSE, const char *usr = 0);
00100    virtual void        ShowWorkers();
00101    virtual Int_t       SendMsgToUsers(const char *, const char * = 0);
00102    virtual void        SetAlias(const char *alias="") { TNamed::SetTitle(alias); }
00103    virtual void        SetROOTVersion(const char *) { }
00104    virtual void        ShowROOTVersions() { }
00105    virtual void        ShutdownSession(Int_t id) { DetachSession(id,"S"); }
00106    virtual void        ShutdownSession(TProof *p) { DetachSession(p,"S"); }
00107 
00108    // Remote file system actions
00109    virtual Int_t       Cp(const char *, const char * = 0, const char * = 0) { return -1; }
00110    virtual void        Find(const char * = "~/", const char * = 0, const char * = 0) { }
00111    virtual void        Grep(const char *, const char * = 0, const char * = 0) { }
00112    virtual void        Ls(const char * = "~/", const char * = 0, const char * = 0) { }
00113    virtual void        More(const char *, const char * = 0, const char * = 0) { }
00114    virtual Int_t       Rm(const char *, const char * = 0, const char * = 0) { return -1; }
00115    virtual void        Tail(const char *, const char * = 0, const char * = 0) { }
00116    virtual Int_t       Md5sum(const char *, TString &, const char * = 0) { return -1; }
00117    virtual Int_t       Stat(const char *, FileStat_t &, const char * = 0) { return -1; }
00118 
00119    virtual Int_t       GetFile(const char *, const char *, const char * = 0) { return -1; }
00120    virtual Int_t       PutFile(const char *, const char *, const char * = 0) { return -1; }
00121 
00122    static TList       *GetListOfManagers();
00123 
00124    static void         SetTXProofMgrHook(TProofMgr_t pmh);
00125 
00126    static TProofMgr *Create(const char *url, Int_t loglevel = -1,
00127                                    const char *alias = 0, Bool_t xpd = kTRUE);
00128 
00129    ClassDef(TProofMgr,0)  // Abstract PROOF manager interface
00130 };
00131 
00132 //
00133 // Metaclass describing the essentials of a PROOF session
00134 //
00135 class TProofDesc : public TNamed {
00136 public:
00137    enum EStatus { kUnknown = -1, kIdle = 0, kRunning =1, kShutdown = 2};
00138 
00139 private:
00140    TProofDesc(const TProofDesc&); // Not implemented
00141    TProofDesc& operator=(const TProofDesc&); // Not implemented
00142 
00143    Int_t          fLocalId;  // ID in the local list
00144    Int_t          fStatus;   // Session status (see EStatus)
00145    TProof        *fProof;    // Related instance of TProof
00146    Int_t          fRemoteId; // Remote ID assigned by the coordinator to the proofserv
00147    TString        fUrl;      // Url of the connection
00148 
00149 public:
00150    TProofDesc(const char *tag = 0, const char *alias = 0, const char *url = 0,
00151                      Int_t id = -1, Int_t remid = -1, Int_t status = kIdle, TProof *p = 0)
00152                     : TNamed(tag, alias),
00153      fLocalId(id), fStatus(0), fProof(p), fRemoteId(remid), fUrl(url) { SetStatus(status); }
00154    virtual ~TProofDesc() { }
00155 
00156    Int_t          GetLocalId() const { return fLocalId; }
00157    TProof        *GetProof() const { return fProof; }
00158    Int_t          GetRemoteId() const { return fRemoteId; }
00159    Int_t          GetStatus() const { return fStatus; }
00160    const char    *GetUrl() const { return fUrl; }
00161 
00162    Bool_t         IsIdle() const { return (fStatus == kIdle) ? kTRUE : kFALSE; }
00163    Bool_t         IsRunning() const { return (fStatus == kRunning) ? kTRUE : kFALSE; }
00164    Bool_t         IsShuttingDown() const { return (fStatus == kShutdown) ? kTRUE : kFALSE; }
00165 
00166    Bool_t         MatchId(Int_t id) const { return (fLocalId == id); }
00167 
00168    void           Print(Option_t *opt = "") const;
00169 
00170    void           SetStatus(Int_t st) { fStatus = (st < kIdle || st > kShutdown) ? -1 : st; }
00171 
00172    void           SetProof(TProof *p) { fProof = p; }
00173    void           SetRemoteId(Int_t id) { fRemoteId = id; }
00174 
00175    ClassDef(TProofDesc,1)  // Small class describing a proof session
00176 };
00177 
00178 #endif

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