00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_XrdProofdClient
00013 #define ROOT_XrdProofdClient
00014
00015
00016
00017
00018
00019
00020
00021
00022
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;
00105
00106 bool fChangeOwn;
00107 bool fIsValid;
00108 bool fAskedToTouch;
00109
00110 XrdProofUI fUI;
00111 XrdROOT *fROOT;
00112
00113 XrdProofdSandbox fSandbox;
00114
00115 XrdOucString fAdminPath;
00116
00117 std::vector<XrdProofdProofServ *> fProofServs;
00118 std::vector<XrdClientID *> fClients;
00119 };
00120
00121
00122
00123
00124
00125
00126
00127
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