XRootD
Loading...
Searching...
No Matches
XrdCmsProtocol Class Reference

#include <XrdCmsProtocol.hh>

+ Inheritance diagram for XrdCmsProtocol:
+ Collaboration diagram for XrdCmsProtocol:

Public Member Functions

 XrdCmsProtocol ()
 
 ~XrdCmsProtocol ()
 
void DoIt ()
 
int Execute (XrdCmsRRData &Data)
 
XrdProtocolMatch (XrdLink *lp)
 
int Process (XrdLink *lp)
 
void Recycle (XrdLink *lp, int consec, const char *reason)
 
void Ref (int rcnt)
 
int Stats (char *buff, int blen, int do_sync=0)
 
- Public Member Functions inherited from XrdProtocol
 XrdProtocol (const char *jname)
 
virtual ~XrdProtocol ()
 
- Public Member Functions inherited from XrdJob
 XrdJob (const char *desc="")
 
virtual ~XrdJob ()
 

Static Public Member Functions

static XrdCmsProtocolAlloc (const char *theRole="", XrdCmsManager *mP=0, const char *theMan=0, int thePort=0)
 

Friends

class XrdCmsJob
 

Additional Inherited Members

- Public Attributes inherited from XrdJob
const char * Comment
 
XrdJobNextJob
 

Detailed Description

Definition at line 44 of file XrdCmsProtocol.hh.

Constructor & Destructor Documentation

◆ XrdCmsProtocol()

XrdCmsProtocol::XrdCmsProtocol ( )
inline

Definition at line 66 of file XrdCmsProtocol.hh.

66: XrdProtocol("cms protocol handler") {Init();}

Referenced by Alloc().

+ Here is the caller graph for this function:

◆ ~XrdCmsProtocol()

XrdCmsProtocol::~XrdCmsProtocol ( )
inline

Definition at line 67 of file XrdCmsProtocol.hh.

67{}

Member Function Documentation

◆ Alloc()

XrdCmsProtocol * XrdCmsProtocol::Alloc ( const char *  theRole = "",
XrdCmsManager mP = 0,
const char *  theMan = 0,
int  thePort = 0 
)
static

Definition at line 892 of file XrdCmsProtocol.cc.

895{
896 XrdCmsProtocol *xp;
897
898// Grab a protocol object and, if none, return a new one
899//
900 ProtMutex.Lock();
901 if ((xp = ProtStack)) ProtStack = xp->ProtLink;
902 else xp = new XrdCmsProtocol();
903 ProtMutex.UnLock();
904
905// Initialize the object if we actually got one
906//
907 if (!xp) Say.Emsg("Protocol","No more protocol objects.");
908 else xp->Init(theRole, uMan, theMan, thePort);
909
910// All done
911//
912 return xp;
913}
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
XrdSysError Say

References XrdCmsProtocol(), XrdSysError::Emsg(), XrdSysMutex::Lock(), XrdCms::Say, and XrdSysMutex::UnLock().

Referenced by Match(), and XrdCmsSupervisor::Start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoIt()

void XrdCmsProtocol::DoIt ( )
virtual

Implements XrdJob.

Definition at line 1060 of file XrdCmsProtocol.cc.

1061{
1062
1063// If we have a role, then we should simply pander it
1064//
1065 if (myRole) Pander(myMan, myManPort);
1066}

◆ Execute()

int XrdCmsProtocol::Execute ( XrdCmsRRData Data)

Definition at line 202 of file XrdCmsProtocol.cc.

203{
204 EPNAME("Execute");
205 static kXR_unt32 theDelay = htonl(Config.SUPDelay);
207 const char *etxt;
208
209// Check if we can continue
210//
211 if (CmsState.Suspended && Arg.Routing & XrdCmsRouting::Delayable)
212 {Reply_Delay(Arg, theDelay); return 0;}
213
214// Validate request code and execute the request. If successful, forward the
215// request to subscribers of this node if the request is forwardable.
216//
217 if (!(Method = Router.getMethod(Arg.Request.rrCode)))
218 Say.Emsg("Protocol", "invalid request code from", myNode->Ident);
219 else if ((etxt = (myNode->*Method)(Arg)))
220 if (*etxt == '!')
221 {DEBUGR(etxt+1 <<" delayed " <<Arg.waitVal <<" seconds");
222 return -EINPROGRESS;
223 } else if (*etxt == '.') return -ECONNABORTED;
224 else Reply_Error(Arg, kYR_EINVAL, etxt);
225 else if (Arg.Routing & XrdCmsRouting::Forward && Cluster.NodeCnt
226 && !(Arg.Request.modifier & kYR_dnf)) Reissue(Arg);
227 return 0;
228}
unsigned int kXR_unt32
Definition XPtypes.hh:90
#define EPNAME(x)
#define DEBUGR(y)
char * Ident
Definition XrdCmsNode.hh:61
NodeMethod_t getMethod(int Code)
const char *(XrdCmsNode::* NodeMethod_t)(XrdCmsRRData &)
XrdCmsRouter Router
@ kYR_EINVAL
Definition YProtocol.hh:153
XrdCmsState CmsState
XrdCmsConfig Config

References XrdCms::CmsState, XrdCms::Config, DEBUGR, XrdCmsRouting::Delayable, XrdSysError::Emsg(), EPNAME, XrdCmsRouting::Forward, XrdCmsRouter::getMethod(), XrdCmsNode::Ident, XrdCms::kYR_dnf, XrdCms::kYR_EINVAL, XrdCms::CmsRRHdr::modifier, XrdCmsCluster::NodeCnt, XrdCmsRRData::Request, XrdCms::Router, XrdCmsRRData::Routing, XrdCms::CmsRRHdr::rrCode, XrdCms::Say, XrdCmsConfig::SUPDelay, and XrdCmsState::Suspended.

Referenced by XrdCmsJob::DoIt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Match()

XrdProtocol * XrdCmsProtocol::Match ( XrdLink lp)
virtual

Implements XrdProtocol.

Definition at line 234 of file XrdCmsProtocol.cc.

235{
236CmsRRHdr Hdr;
237int dlen;
238
239// Peek at the first few bytes of data (shouldb be all zeroes)
240//
241 if ((dlen = lp->Peek((char *)&Hdr,sizeof(Hdr),readWait)) != sizeof(Hdr))
242 {if (dlen <= 0) lp->setEtext("login not received");
243 return (XrdProtocol *)0;
244 }
245
246// Verify that this is our protocol and whether a version1 client is here
247//
248 if (Hdr.streamid || Hdr.rrCode != kYR_login)
249 {if (!strncmp((char *)&Hdr, "login ", 6))
250 lp->setEtext("protocol version 1 unsupported");
251 return (XrdProtocol *)0;
252 }
253
254// Return the protocol object
255//
257}
static XrdCmsProtocol * Alloc(const char *theRole="", XrdCmsManager *mP=0, const char *theMan=0, int thePort=0)
@ kYR_login
Definition YProtocol.hh:90

References Alloc(), XrdCms::kYR_login, XrdLink::Peek(), XrdCms::CmsRRHdr::rrCode, XrdLink::setEtext(), and XrdCms::CmsRRHdr::streamid.

+ Here is the call graph for this function:

◆ Process()

int XrdCmsProtocol::Process ( XrdLink lp)
virtual

Implements XrdProtocol.

Definition at line 468 of file XrdCmsProtocol.cc.

469{
470 const char *Reason;
471 Bearing myWay;
472 int tOut;
473
474// Now admit the login
475//
476 Link = lp;
477 if ((Routing=Admit()))
478 {loggedIn = 1;
479 if (RSlot) {myWay = isLateral; tOut = -1;}
480 else {myWay = isDown; tOut = Config.AskPing*1000;}
481 myNode->UnLock();
482 if ((Reason = Dispatch(myWay, tOut, 2))) lp->setEtext(Reason);
483 Cluster.SLock(true); myNode->isOffline = 1; Cluster.SLock(false);
484 }
485
486// Serialize all activity on the link before we proceed. This makes sure that
487// there are no outstanding tasks initiated by this node. We don't need a node
488// lock for this because we are no longer reading requests so no new tasks can
489// be started. Since the node is marked bound, any attempt to reconnect will be
490// rejected until we finish removing this node. We get the node lock afterwards.
491//
492 lp->Serialize();
493 if (!myNode) return -1;
494 Sync();
495 myNode->Lock();
496
497// Immediately terminate redirectors (they have an Rslot). The redirector node
498// can be directly deleted as all references were serialized through the
499// RTable and one we remove our node there can be no references left.
500//
501 if (RSlot)
502 {RTable.Del(myNode); RSlot = 0;
503 myNode->UnLock(); delete myNode; myNode = 0;
504 return -1;
505 }
506
507// We have a node that may or may not be in the cluster at this point, or may
508// need to remain in the cluster as a shadow member. In any case, the node
509// object lock will be released by Remove().
510//
511 if (myNode)
512 {myNode->isConn = 0;
513 if (myNode->isBound) Cluster.Remove(0, myNode, !loggedIn);
514 else if (myNode->isGone) Cluster.Remove(myNode);
515 else myNode->UnLock();
516 }
517
518// All done indicate the connection is dead
519//
520 return -1;
521}
void SLock(bool dolock, bool wrmode=true)
void Remove(XrdCmsNode *theNode)
void Lock()
char isOffline
Definition XrdCmsNode.hh:64
void UnLock()
void Del(XrdCmsNode *nP)

References XrdCmsConfig::AskPing, XrdCms::Config, XrdCmsRTable::Del(), XrdCmsNode::isBound, XrdCmsNode::isConn, XrdCmsNode::isGone, XrdCmsNode::isOffline, XrdCmsNode::Lock(), XrdCmsCluster::Remove(), XrdLink::Serialize(), XrdLink::setEtext(), XrdCmsCluster::SLock(), and XrdCmsNode::UnLock().

+ Here is the call graph for this function:

◆ Recycle()

void XrdCmsProtocol::Recycle ( XrdLink lp,
int  consec,
const char *  reason 
)
virtual

Implements XrdProtocol.

Definition at line 527 of file XrdCmsProtocol.cc.

528{
529 bool isLoggedIn = loggedIn != 0;
530
531 ProtMutex.Lock();
532 ProtLink = ProtStack;
533 ProtStack = this;
534 ProtMutex.UnLock();
535
536 if (!lp) return;
537
538 if (isLoggedIn)
539 if (reason) Say.Emsg("Protocol", lp->ID, "logged out;", reason);
540 else Say.Emsg("Protocol", lp->ID, "logged out.");
541 else
542 if (reason) Say.Emsg("Protocol", lp->ID, "login failed;", reason);
543}

References XrdSysError::Emsg(), XrdLink::ID, XrdSysMutex::Lock(), XrdCms::Say, and XrdSysMutex::UnLock().

+ Here is the call graph for this function:

◆ Ref()

void XrdCmsProtocol::Ref ( int  rcnt)

Definition at line 1102 of file XrdCmsProtocol.cc.

1103{
1104// Update the reference counter
1105//
1106 refMutex.Lock();
1107 refCount += rcnt;
1108
1109// Check if someone is waiting for the count to drop to zero
1110//
1111 if (refWait && refCount <= 0) {refWait->Post(); refWait = 0;}
1112
1113// All done
1114//
1115 refMutex.UnLock();
1116}

References XrdSysMutex::Lock(), XrdSysSemaphore::Post(), and XrdSysMutex::UnLock().

Referenced by XrdCmsJob::DoIt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Stats()

int XrdCmsProtocol::Stats ( char *  buff,
int  blen,
int  do_sync = 0 
)
virtual

Implements XrdProtocol.

Definition at line 549 of file XrdCmsProtocol.cc.

550{
551
552// All the statistics are handled by the cluster
553//
554
555// If we are a manager then we have different information
556//
557 return (Config.asManager() ? Cluster.Statt(buff, blen)
558 : Cluster.Stats(buff, blen));
559}
int Statt(char *bfr, int bln)
int Stats(char *buff, int blen, int do_sync=0)

References XrdCmsConfig::asManager(), XrdCms::Config, XrdCmsCluster::Stats(), and XrdCmsCluster::Statt().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ XrdCmsJob

friend class XrdCmsJob
friend

Definition at line 46 of file XrdCmsProtocol.hh.


The documentation for this class was generated from the following files: