12 #ifndef ROOT_XrdProofdProofServMgr
13 #define ROOT_XrdProofdProofServMgr
32 # include <sys/types.h>
33 # include <sys/socket.h>
34 # include "XrdNet/XrdNetPeer.hh"
36 # include "XrdNet/XrdNetAddr.hh"
38 #include "XrdOuc/XrdOucHash.hh"
39 #include "XrdOuc/XrdOucString.hh"
45 class XrdProtocol_Config;
51 #define PSMCNTOK(t) (t >= 0 && t < PSMMAXCNTS)
117 XpdEnv(
const char *
n,
const char *env,
const char *usr = 0,
const char *grp = 0,
118 int smi = -1,
int smx = -1,
int vmi = -1,
int vmx = -1) :
121 void Reset(
const char *
n,
const char *env,
const char *usr = 0,
const char *grp = 0,
122 int smi = -1,
int smx = -1,
int vmi = -1,
int vmx = -1) {
125 int Matches(
const char *usr,
const char *grp,
int ver = -1);
183 XrdOucString &users, XrdOucString &groups,
184 XrdOucString &rcval, XrdOucString &rcnam,
185 int &smi,
int &smx,
int &vmi,
int &vmx,
bool &
hex);
186 void FillEnvList(std::list<XpdEnv> *el,
const char *nam,
const char *val,
187 const char *usrs = 0,
const char *grps = 0,
188 int smi = -1,
int smx = -1,
int vmi = -1,
int vmx = -1,
bool hex = 0);
194 unsigned int seq, XrdOucString &emsg);
197 void *input,
const char *envfn,
const char *rcfn);
199 void *input,
const char *rcfn);
207 XrdOucString &tag, XrdOucString &
ord,
208 XrdOucString &cffile, XrdOucString &uenvs,
221 int TouchSession(
const char *fpid,
const char *path = 0);
222 int VerifySession(
const char *fpid,
int to = -1,
const char *path = 0);
238 char *val, XrdOucStream *cfg,
bool rcf);
285 const char *sessiondir,
287 XrdOucString &outfn);
290 XrdOucString &sesstag, XrdOucString &topsesstag,
291 XrdOucString &sessiondir, XrdOucString &sesswrkdir);
int CreateSockPath(XrdProofdProofServ *xps, XrdProofdProtocol *p, unsigned int seq, XrdOucString &emsg)
Create the socket path for the starting session Return 0 on success, -1 on error (error message in 'e...
int SetupProtocol(XrdNetPeer &peerpsrv, XrdProofdProofServ *xps, XrdOucString &e)
Setup the protocol object serving the peer described by 'peerpsrv'.
void Reset(const char *n, const char *env, const char *usr=0, const char *grp=0, int smi=-1, int smx=-1, int vmi=-1, int vmx=-1)
int BroadcastPriorities()
Broadcast priorities to the active sessions.
XrdOucHash< XrdProofdProofServ > fSessions
void SetReconnectTime(bool on=1)
Change reconnecting status.
int CurrentSessions(bool recalculate=0)
Return the number of current sessions (top masters)
static int ToVersCode(int ver, bool hex=0)
Transform version number ver (format patch + 100*minor + 10000*maj, e.g.
int Process(XrdProofdProtocol *p)
Process manager request.
void Print(const char *what)
Print the content of this env.
std::list< XrdProofdProofServ * > * ActiveSessions()
int CleanupProofServ(bool all=0, const char *usr=0)
Cleanup (kill) all 'proofserv' processes from the process table.
unsigned int GetSeqSessionN()
bool IsClientRecovering(const char *usr, const char *grp, int &deadline)
Returns true (an the recovering deadline) if the client has sessions in recovering state; returns fal...
void ParseCreateBuffer(XrdProofdProtocol *p, XrdProofdProofServ *xps, XrdOucString &tag, XrdOucString &ord, XrdOucString &cffile, XrdOucString &uenvs, int &intwait)
Extract relevant quantities from the buffer received during a create request.
int SetUserOwnerships(XrdProofdProtocol *p, const char *ord, const char *stag)
Set user ownerships on some critical files or directories.
int SetProofServEnv(XrdProofdProtocol *p, void *in)
Set environment for proofserv.
std::map< XrdProofdProtocol *, int > fDestroyTimes
virtual ~XrdProofdProofServMgr()
bool IsSessionSocket(const char *fpid)
Checks is fpid is the path of a session UNIX socket Returns TRUE is yes; cleans the socket if the ses...
int CreateProofServRootRc(XrdProofdProtocol *p, void *input, const char *rcfn)
Create in 'rcfn' the rootrc file for the proofserv being created return 0 on success, -1 on error.
void UpdateCounter(int t, int n)
int RmSession(const char *fpid)
Remove session file from the terminated sessions area.
int CheckFrequency() const
int DeleteFromSessions(const char *pid)
Delete from the hash list the session with ID pid.
XrdSysSemWait fProcessSem
void ResolveKeywords(XrdOucString &s, ProofServEnv_t *in)
Resolve some keywords in 's' <logfileroot>, <user>, <rootsys>
bool Alive(XrdProofdProtocol *p)
Check destroyed status.
XrdSysRecMutex fRecoverMutex
int AddSession(XrdProofdProtocol *p, XrdProofdProofServ *s)
Add new active session.
XrdOucString fParentExecs
XrdSysSemWait * ProcessSem()
int VerifyTimeOut() const
XrdSecCredsSaver_t fCredsSaver
int CreateProofServEnvFile(XrdProofdProtocol *p, void *input, const char *envfn, const char *rcfn)
Create in 'rcfn' the rootrc file for the proofserv being created return 0 on success, -1 on error.
void ExtractEnv(char *, XrdOucStream *, XrdOucString &users, XrdOucString &groups, XrdOucString &rcval, XrdOucString &rcnam, int &smi, int &smx, int &vmi, int &vmx, bool &hex)
Extract env information from the stream 'cfg'.
int Destroy(XrdProofdProtocol *p)
Handle a request to shutdown an existing session.
void FormFileNameInSessionDir(XrdProofdProtocol *p, XrdProofdProofServ *xps, const char *sessiondir, const char *extension, XrdOucString &outfn)
int CreateAdminPath(XrdProofdProofServ *xps, XrdProofdProtocol *p, int pid, XrdOucString &emsg)
Create the admin path for the starting session Return 0 on success, -1 on error (error message in 'em...
XrdProofSessionInfo(XrdProofdClient *c, XrdProofdProofServ *s)
Construct from 'c' and 's'.
XpdSrvMgrCreateCnt(XrdProofdProofServMgr *m, int t)
std::list< XpdEnv > fProofServEnvs
bool IsReconnecting()
Return true if in reconnection state, i.e.
XrdOucString fTermAdminPath
XrdSysRecMutex fEnvsMutex
int CheckActiveSessions(bool verify=1)
Go through the active sessions admin path and make sure sessions are alive.
int TouchSession(const char *fpid, const char *path=0)
Update the access time for the session pid file to the current time.
std::list< XrdProofdProofServ * > fActiveSessions
void DisconnectFromProofServ(int pid)
Change reconnecting status.
int Matches(const char *usr, const char *grp, int ver=-1)
Check if this env applies to 'usr', 'grp, 'ver'.
std::list< XpdClientSessions * > * fRecoverClients
XrdProofdProofServMgr * fMgr
void FillProofServ(XrdProofdProofServ &s, XrdROOTMgr *rmgr)
Fill 's' fields using the stored info.
void RegisterDirectives()
Register directives for configuration.
std::list< XrdProofdProofServ * > fProofServs
int Config(bool rcf=0)
Run configuration and parse the entered config directives.
int Attach(XrdProofdProtocol *p)
Handle a request to attach to an existing session.
std::list< XpdEnv > fProofServRCs
int ResolveSession(const char *fpid)
Handle a request to recover a session after stop&restart.
#define XrdSysMutexHelper
XpdClientSessions(XrdProofdClient *c=0)
void Reset()
Reset the content.
int Recover(XpdClientSessions *cl)
Handle a request to recover a session after stop&restart for a specific client.
int CleanClientSessions(const char *usr, int srvtype)
Go through the sessions admin path and clean all sessions belonging to 'usr'.
int MvSession(const char *fpid)
Move session file from the active to the terminated areas.
int PrepareSessionRecovering()
Go through the active sessions admin path and prepare reconnection of those still alive...
int VerifySession(const char *fpid, int to=-1, const char *path=0)
Check if the session is alive, i.e.
int operator==(const XpdClientSessions c)
int Detach(XrdProofdProtocol *p)
Handle a request to detach from an existing session.
void GetTagDirs(int opt, XrdProofdProtocol *p, XrdProofdProofServ *xps, XrdOucString &sesstag, XrdOucString &topsesstag, XrdOucString &sessiondir, XrdOucString &sesswrkdir)
Determine the unique tag and relevant dirs for this session.
XrdOucString fProofPlugin
int(* XrdSecCredsSaver_t)(XrdSecCredentials *, const char *fn, const XrdProofUI &ui)
int CheckTerminatedSessions()
Go through the terminated sessions admin path and make sure sessions they are gone.
void SendErrLog(const char *errlog, XrdProofdResponse *r)
Send content of errlog upstream asynchronously.
int CleanupLostProofServ()
Cleanup (kill) all 'proofserv' processes which lost control from their creator or controller daemon...
int SetProofServEnvOld(XrdProofdProtocol *p, void *in)
Set environment for proofserv; old version preparing the environment for proofserv protocol version <...
XpdEnv(const char *n, const char *env, const char *usr=0, const char *grp=0, int smi=-1, int smx=-1, int vmi=-1, int vmx=-1)
XrdProofdProofServ * PrepareProofServ(XrdProofdProtocol *p, XrdProofdResponse *r, unsigned short &sid)
Allocate and prepare the XrdProofdProofServ object describing this session.
int DoDirectiveShutdown(char *, XrdOucStream *, bool)
Process 'shutdown' directive.
unsigned int fSeqSessionN
void FillEnvList(std::list< XpdEnv > *el, const char *nam, const char *val, const char *usrs=0, const char *grps=0, int smi=-1, int smx=-1, int vmi=-1, int vmx=-1, bool hex=0)
Fill env entry(ies) in the relevant list.
void SetNextSessionsCheck(int t)
XrdProofdProofServMgr(XrdProofdManager *mgr, XrdProtocol_Config *pi, XrdSysError *e)
Constructor.
int Create(XrdProofdProtocol *p)
Handle a request to create a new session.
int DoDirective(XrdProofdDirective *d, char *val, XrdOucStream *cfg, bool rcf)
Update the priorities of the active sessions.
XrdOucString fTopSessionTag
int DoDirectivePutRc(char *, XrdOucStream *, bool)
Process 'putrc' directives.
XrdProofdProofServ * GetActiveSession(int pid)
Return active session with process ID pid, if any.
int ReadFromFile(const char *file)
Read content from 'file'.
int AcceptPeer(XrdProofdProofServ *xps, int to, XrdOucString &e)
Accept a callback from a starting-up server and setup the related protocol object.
int RecoverActiveSessions()
Accept connections from sessions still alive.
int DoDirectivePutEnv(char *, XrdOucStream *, bool)
Process 'putenv' directives.
XrdOucString fActiAdminPath
int fCounters[PSMMAXCNTS]
XpdSrvMgrCreateGuard(int *c=0)
XrdProofdClient * fClient
int SaveToFile(const char *file)
Save content to 'file'.
int DoDirectiveProofServMgr(char *, XrdOucStream *, bool)
Process 'proofswrvmgr' directive eg: xpd.proofswrvmgr checkfq:120 termto:100 verifyto:5 recoverto:20...
void BroadcastClusterInfo()
Broadcast cluster info to the active sessions.
int SetUserEnvironment(XrdProofdProtocol *p)
Set user environment: set effective user and group ID of the process to the ones of the owner of this...
XrdProofSessionInfo(const char *file)