ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
XrdProofdClient.h
Go to the documentation of this file.
1 // @(#)root/proofd:$Id$
2 // Author: G. Ganis June 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, 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_XrdProofdClient
13 #define ROOT_XrdProofdClient
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // XrdProofdClient //
18 // //
19 // Author: G. Ganis, CERN, 2007 //
20 // //
21 // Auxiliary class describing a PROOF client. //
22 // Used by XrdProofdProtocol. //
23 // //
24 //////////////////////////////////////////////////////////////////////////
25 #include <list>
26 #include <vector>
27 
28 #include "XpdSysPthread.h"
29 
30 #include "XrdOuc/XrdOucString.hh"
31 
32 #include "XrdProofdAux.h"
33 #include "XrdProofdProtocol.h"
34 #include "XrdProofdResponse.h"
35 #include "XrdProofdSandbox.h"
36 
37 #define XPC_DEFMAXOLDLOGS 10
38 
39 class XrdNet;
40 class XrdClientID;
41 class XrdROOT;
42 
44 
45  public:
47  bool master, bool changeown, XrdSysError *edest, const char *tmp, int rtime);
48 
49  virtual ~XrdProofdClient();
50 
51  inline const char *Group() const { return fUI.fGroup.c_str(); }
52  inline const char *User() const { return fUI.fUser.c_str(); }
53  inline bool IsValid() const { return fIsValid; }
54  bool Match(const char *usr, const char *grp = 0);
55  inline XrdSysRecMutex *Mutex() const { return (XrdSysRecMutex *)&fMutex; }
56  inline XrdROOT *ROOT() const { return fROOT; }
57  inline XrdProofdSandbox *Sandbox() const { return (XrdProofdSandbox *)&fSandbox; }
58  inline XrdProofUI UI() const { return fUI; }
59 
60  XrdProofdProofServ *GetServer(int psid);
62  void EraseServer(int psid);
63  int GetTopServers();
64 
65  int ResetClientSlot(int ic);
67 
69  int ReserveClientID(int cid);
70  int SetClientID(int cid, XrdProofdProtocol *p);
73 
74  void Broadcast(const char *msg);
75 
76  XrdOucString ExportSessions(XrdOucString &emsg, XrdProofdResponse *r = 0);
77  void SkipSessionsCheck(std::list<XrdProofdProofServ *> *active,
78  XrdOucString &emsg, XrdProofdResponse *r = 0);
79  void TerminateSessions(int srvtype, XrdProofdProofServ *ref,
80  const char *msg, XrdProofdPipe *pipe, bool changeown);
82 
83  void ResetSessions();
84 
85  void SetGroup(const char *g) { fUI.fGroup = g; }
86  void SetROOT(XrdROOT *r) { fROOT = r; }
87 
88  void SetValid(bool valid = 1) { fIsValid = valid; }
89 
90  int Size() const { return fClients.size(); }
91 
92  int Touch(bool reset = 0);
93 
95 
96  const char *AdminPath() const { return fAdminPath.c_str(); }
97 
98  private:
99 
100  XrdSysRecMutex fMutex; // Local mutex
101 
102  bool fChangeOwn; // TRUE if ownership must be changed where relevant
103  bool fIsValid; // TRUE if the instance is complete
104  bool fAskedToTouch; // TRUE if a touch request has already been sent for this client
105  int fReconnectTimeOut; // Time given for disconnected clients to reconnect
106 
107  XrdProofUI fUI; // user info
108  XrdROOT *fROOT; // ROOT vers instance to be used for proofserv
109 
110  XrdProofdSandbox fSandbox; // Clients sandbox
111 
112  XrdOucString fAdminPath; // Admin path for this client
113 
114  std::vector<XrdProofdProofServ *> fProofServs; // Allocated ProofServ sessions
115  std::vector<XrdClientID *> fClients; // Attached Client sessions
116 };
117 
118 //////////////////////////////////////////////////////////////////////////
119 // //
120 // XrdClientID //
121 // //
122 // Authors: G. Ganis, CERN, 2005 //
123 // //
124 // Mapping of clients and stream IDs //
125 // //
126 //////////////////////////////////////////////////////////////////////////
127 class XrdClientID {
128 private:
131  unsigned short fSid;
133 
134  void SetR() { fR = (fP && fSid > 0) ? fP->Response(fSid) : 0;}
135 public:
136  XrdClientID(XrdProofdProtocol *pt = 0, unsigned short id = 0)
137  { fP = pt; fSid = id; SetR(); fResetTime = -1; }
139 
140  XrdProofdClient *C() const { return fP->Client(); }
141  bool IsValid() const { return (fP != 0); }
142  XrdProofdProtocol *P() const { return fP; }
143  XrdProofdResponse *R() const { return fR; }
144  void Reset() { fP = 0; fSid = 0; SetR(); fResetTime = time(0); }
145  int ResetTime() { return fResetTime; }
146  void SetP(XrdProofdProtocol *p) { fP = p; SetR();}
147  void SetSid(unsigned short sid) { fSid = sid; SetR();}
148  unsigned short Sid() const { return fSid; }
149 };
150 
151 #endif
int GetClientID(XrdProofdProtocol *p)
Get next free client ID.
virtual ~XrdProofdClient()
Destructor.
int ResetClientSlot(int ic)
Reset slot at 'ic'.
int ReserveClientID(int cid)
Reserve a client ID.
XrdProofdProtocol * P() const
XrdClientID(XrdProofdProtocol *pt=0, unsigned short id=0)
int TrimSessionDirs()
If the static fgMaxOldLogs > 0, logs for a fgMaxOldLogs number of sessions are kept in the sandbox; w...
#define XrdSysRecMutex
Definition: XrdSysToOuc.h:18
void SetGroup(const char *g)
void SetSid(unsigned short sid)
XrdProofdProofServ * GetServObj(int id)
Get server at 'id'. If needed, increase the vector size.
void SkipSessionsCheck(std::list< XrdProofdProofServ * > *active, XrdOucString &emsg, XrdProofdResponse *r=0)
Skip the next sessions status check.
XrdProofUI UI() const
XrdProofdProtocol * fP
XrdSysRecMutex * Mutex() const
XrdSysRecMutex fMutex
std::vector< XrdClientID * > fClients
XrdProofdClient * C() const
unsigned short fSid
XrdOucString ExportSessions(XrdOucString &emsg, XrdProofdResponse *r=0)
Return a string describing the existing sessions.
XFontStruct * id
Definition: TGX11.cxx:108
XrdOucString fUser
Definition: XrdProofdAux.h:40
bool IsValid() const
bool Match(const char *usr, const char *grp=0)
return TRUE if this instance matches 'id' (and 'grp', if defined)
void Broadcast(const char *msg)
Broadcast message 'msg' to the connected clients.
XrdProofdClient(XrdProofUI ui, bool master, bool changeown, XrdSysError *edest, const char *tmp, int rtime)
Constructor.
XrdProofdResponse * Response(kXR_unt16 rid)
Get response instance corresponding to stream ID 'sid'.
TPaveText * pt
ROOT::R::TRInterface & r
Definition: Object.C:4
int changeown(const std::string &path, uid_t u, gid_t g)
Change the ownership of 'path' to the entity described by {u,g}.
Definition: proofexecv.cxx:802
XrdOucString fGroup
Definition: XrdProofdAux.h:41
void SetP(XrdProofdProtocol *p)
#define XrdSysError
Definition: XpdSysError.h:8
bool VerifySession(XrdProofdProofServ *xps, XrdProofdResponse *r=0)
Quick verification of session 'xps' to avoid attaching clients to non responding sessions.
unsigned short Sid() const
int Touch(bool reset=0)
Send a touch the connected clients: this will remotely touch the associated TSocket instance and sche...
int Size() const
XrdProofdSandbox * Sandbox() const
void TerminateSessions(int srvtype, XrdProofdProofServ *ref, const char *msg, XrdProofdPipe *pipe, bool changeown)
Terminate client sessions; IDs of signalled processes are added to sigpid.
const char * AdminPath() const
XrdROOT * ROOT() const
XrdProofdSandbox fSandbox
void SetROOT(XrdROOT *r)
int GetTopServers()
Return the number of valid proofserv topmaster sessions in the list.
const char * Group() const
XrdProofdProtocol * GetProtocol(int ic)
Return protocol attached to client slot at 'ic'.
XrdProofdResponse * fR
void EraseServer(int psid)
Erase server with id psid from the list.
const char * User() const
XrdProofdResponse * R() const
bool IsValid() const
XrdProofdProofServ * GetServer(int psid)
Get from the vector server instance with ID psid.
std::vector< XrdProofdProofServ * > fProofServs
XrdProofdProofServ * GetFreeServObj()
Get next free server ID.
void SetValid(bool valid=1)
XrdProofdClient * Client() const
XrdOucString fAdminPath
void ResetSessions()
Reset this instance.
int SetClientID(int cid, XrdProofdProtocol *p)
Set slot cid to instance 'p'.