XrdProofdClient.h

Go to the documentation of this file.
00001 // @(#)root/proofd:$Id: XrdProofdClient.h 31441 2009-11-27 07:29:29Z ganis $
00002 // Author: G. Ganis June 2007
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_XrdProofdClient
00013 #define ROOT_XrdProofdClient
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 // XrdProofdClient                                                      //
00018 //                                                                      //
00019 // Author: G. Ganis, CERN, 2007                                         //
00020 //                                                                      //
00021 // Auxiliary class describing a PROOF client.                           //
00022 // Used by XrdProofdProtocol.                                           //
00023 //                                                                      //
00024 //////////////////////////////////////////////////////////////////////////
00025 #include <list>
00026 #include <vector>
00027 
00028 #ifdef OLDXRDOUC
00029 #  include "XrdSysToOuc.h"
00030 #  include "XrdOuc/XrdOucPthread.hh"
00031 #else
00032 #  include "XrdSys/XrdSysPthread.hh"
00033 #endif
00034 #include "XrdOuc/XrdOucString.hh"
00035 
00036 #include "XrdProofdAux.h"
00037 #include "XrdProofdSandbox.h"
00038 #include "XrdProofdProtocol.h"
00039 #include "XrdProofdResponse.h"
00040 
00041 #define XPC_DEFMAXOLDLOGS 10
00042 
00043 class XrdNet;
00044 class XrdClientID;
00045 class XrdROOT;
00046 
00047 class XrdProofdClient {
00048 
00049  public:
00050    XrdProofdClient(XrdProofUI ui,
00051                    bool master, bool changeown, XrdSysError *edest, const char *tmp);
00052 
00053    virtual ~XrdProofdClient();
00054 
00055    inline const char      *Group() const { return fUI.fGroup.c_str(); }
00056    inline const char      *User() const { return fUI.fUser.c_str(); }
00057    inline bool             IsValid() const { return fIsValid; }
00058    bool                    Match(const char *usr, const char *grp = 0);
00059    inline XrdSysRecMutex  *Mutex() const { return (XrdSysRecMutex *)&fMutex; }
00060    inline XrdROOT         *ROOT() const { return fROOT; }
00061    inline XrdProofdSandbox *Sandbox() const { return (XrdProofdSandbox *)&fSandbox; }
00062    inline XrdProofUI       UI() const { return fUI; }
00063 
00064    XrdProofdProofServ     *GetServer(int psid);
00065    XrdProofdProofServ     *GetServer(XrdProofdProtocol *p);
00066    void                    EraseServer(int psid);
00067    int                     GetTopServers();
00068 
00069    int                     ResetClientSlot(int ic);
00070    XrdProofdProtocol      *GetProtocol(int ic);
00071 
00072    int                     GetClientID(XrdProofdProtocol *p);
00073    int                     ReserveClientID(int cid);
00074    int                     SetClientID(int cid, XrdProofdProtocol *p);
00075    XrdProofdProofServ     *GetFreeServObj();
00076    XrdProofdProofServ     *GetServObj(int id);
00077 
00078    void                    Broadcast(const char *msg);
00079 
00080    XrdOucString            ExportSessions(XrdOucString &emsg, XrdProofdResponse *r = 0);
00081    void                    SkipSessionsCheck(std::list<XrdProofdProofServ *> *active,
00082                                              XrdOucString &emsg, XrdProofdResponse *r = 0);
00083    void                    TerminateSessions(int srvtype, XrdProofdProofServ *ref,
00084                                              const char *msg, XrdProofdPipe *pipe, bool changeown);
00085    bool                    VerifySession(XrdProofdProofServ *xps, XrdProofdResponse *r = 0);
00086 
00087    void                    ResetSessions();
00088 
00089    void                    SetGroup(const char *g) { fUI.fGroup = g; }
00090    void                    SetROOT(XrdROOT *r) { fROOT = r; }
00091 
00092    void                    SetValid(bool valid = 1) { fIsValid = valid; }
00093 
00094    int                     Size() const { return fClients.size(); }
00095 
00096    int                     Touch(bool reset = 0);
00097 
00098    int                     TrimSessionDirs() { return fSandbox.TrimSessionDirs(); }
00099 
00100    const char             *AdminPath() const { return fAdminPath.c_str(); }
00101 
00102  private:
00103 
00104    XrdSysRecMutex          fMutex; // Local mutex
00105 
00106    bool                    fChangeOwn; // TRUE if ownership must be changed where relevant
00107    bool                    fIsValid; // TRUE if the instance is complete
00108    bool                    fAskedToTouch; // TRUE if a touch request has already been sent for this client
00109 
00110    XrdProofUI              fUI;         // user info
00111    XrdROOT                *fROOT;        // ROOT vers instance to be used for proofserv
00112 
00113    XrdProofdSandbox        fSandbox;     // Clients sandbox
00114 
00115    XrdOucString            fAdminPath;    // Admin path for this client
00116 
00117    std::vector<XrdProofdProofServ *> fProofServs; // Allocated ProofServ sessions
00118    std::vector<XrdClientID *> fClients;    // Attached Client sessions
00119 };
00120 
00121 //////////////////////////////////////////////////////////////////////////
00122 //                                                                      //
00123 // XrdClientID                                                          //
00124 //                                                                      //
00125 // Authors: G. Ganis, CERN, 2005                                        //
00126 //                                                                      //
00127 // Mapping of clients and stream IDs                                    //
00128 //                                                                      //
00129 //////////////////////////////////////////////////////////////////////////
00130 class XrdClientID {
00131 private:
00132    XrdProofdProtocol *fP;
00133    XrdProofdResponse *fR;
00134    unsigned short     fSid;
00135 
00136    void               SetR() { fR = (fP && fSid > 0) ? fP->Response(fSid) : 0;}
00137 public:
00138    XrdClientID(XrdProofdProtocol *pt = 0, unsigned short id = 0)
00139             { fP = pt; fSid = id; SetR();}
00140    ~XrdClientID() { }
00141 
00142    XrdProofdClient   *C() const { return fP->Client(); }
00143    bool               IsValid() const { return (fP != 0); }
00144    XrdProofdProtocol *P() const { return fP; }
00145    XrdProofdResponse *R() const { return fR; }
00146    void               Reset() { fP = 0; fSid = 0; SetR(); }
00147    void               SetP(XrdProofdProtocol *p) { fP = p; SetR();}
00148    void               SetSid(unsigned short sid) { fSid = sid; SetR();}
00149    unsigned short     Sid() const { return fSid; }
00150 };
00151 
00152 #endif

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