Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
39class XrdNet;
40class XrdClientID;
41class 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
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//////////////////////////////////////////////////////////////////////////
128private:
131 unsigned short fSid;
133
134 void SetR() { fR = (fP && fSid > 0) ? fP->Response(fSid) : 0;}
135public:
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
ROOT::R::TRInterface & r
Definition Object.C:4
#define g(i)
Definition RSha256.hxx:105
XFontStruct * id
Definition TGX11.cxx:109
unsigned short fSid
XrdProofdResponse * R() const
unsigned short Sid() const
void SetP(XrdProofdProtocol *p)
XrdProofdProtocol * P() const
void SetSid(unsigned short sid)
bool IsValid() const
XrdClientID(XrdProofdProtocol *pt=0, unsigned short id=0)
XrdProofdClient * C() const
XrdProofdResponse * fR
XrdProofdProtocol * fP
XrdOucString fUser
XrdOucString fGroup
XrdProofUI UI() const
const char * AdminPath() const
XrdSysRecMutex * Mutex() const
std::vector< XrdClientID * > fClients
virtual ~XrdProofdClient()
Destructor.
bool IsValid() 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.
int ReserveClientID(int cid)
Reserve a client ID.
void SetROOT(XrdROOT *r)
int GetTopServers()
Return the number of valid proofserv topmaster sessions in the list.
XrdProofdProofServ * GetFreeServObj()
Get next free server ID.
int GetClientID(XrdProofdProtocol *p)
Get next free client ID.
XrdOucString ExportSessions(XrdOucString &emsg, XrdProofdResponse *r=0)
Return a string describing the existing sessions.
XrdProofdSandbox * Sandbox() const
XrdROOT * ROOT() const
const char * Group() const
const char * User() const
int ResetClientSlot(int ic)
Reset slot at 'ic'.
void Broadcast(const char *msg)
Broadcast message 'msg' to the connected clients.
XrdOucString fAdminPath
XrdSysRecMutex fMutex
bool VerifySession(XrdProofdProofServ *xps, XrdProofdResponse *r=0)
Quick verification of session 'xps' to avoid attaching clients to non responding sessions.
void SetGroup(const char *g)
void ResetSessions()
Reset this instance.
XrdProofdProofServ * GetServer(int psid)
Get from the vector server instance with ID psid.
std::vector< XrdProofdProofServ * > fProofServs
int Touch(bool reset=0)
Send a touch the connected clients: this will remotely touch the associated TSocket instance and sche...
void SetValid(bool valid=1)
void EraseServer(int psid)
Erase server with id psid from the list.
XrdProofdProofServ * GetServObj(int id)
Get server at 'id'. If needed, increase the vector size.
int SetClientID(int cid, XrdProofdProtocol *p)
Set slot cid to instance 'p'.
XrdProofdSandbox fSandbox
XrdProofdProtocol * GetProtocol(int ic)
Return protocol attached to client slot at 'ic'.
bool Match(const char *usr, const char *grp=0)
return TRUE if this instance matches 'id' (and 'grp', if defined)
void SkipSessionsCheck(std::list< XrdProofdProofServ * > *active, XrdOucString &emsg, XrdProofdResponse *r=0)
Skip the next sessions status check.
XrdProofdResponse * Response(kXR_unt16 rid)
Get response instance corresponding to stream ID 'sid'.
XrdProofdClient * Client() const
int TrimSessionDirs()
If the static fgMaxOldLogs > 0, logs for a fgMaxOldLogs number of sessions are kept in the sandbox; w...
TPaveText * pt
int changeown(const std::string &path, uid_t u, gid_t g)
Change the ownership of 'path' to the entity described by {u,g}.