XRootD
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();}
XrdProtocol(const char *jname)
Definition: XrdProtocol.hh:156

◆ ~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 849 of file XrdCmsProtocol.cc.

852 {
853  XrdCmsProtocol *xp;
854 
855 // Grab a protocol object and, if none, return a new one
856 //
857  ProtMutex.Lock();
858  if ((xp = ProtStack)) ProtStack = xp->ProtLink;
859  else xp = new XrdCmsProtocol();
860  ProtMutex.UnLock();
861 
862 // Initialize the object if we actually got one
863 //
864  if (!xp) Say.Emsg("Protocol","No more protocol objects.");
865  else xp->Init(theRole, uMan, theMan, thePort);
866 
867 // All done
868 //
869  return xp;
870 }
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:95
XrdSysError Say

References XrdSysError::Emsg(), and XrdCms::Say.

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 1017 of file XrdCmsProtocol.cc.

1018 {
1019 
1020 // If we have a role, then we should simply pander it
1021 //
1022  if (myRole) Pander(myMan, myManPort);
1023 }

◆ 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)
Definition: XrdBwmTrace.hh:56
#define DEBUGR(y)
Definition: XrdCmsTrace.hh:51
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
XrdCmsCluster Cluster
XrdCmsState CmsState
Definition: XrdCmsState.cc:55
XrdCmsConfig Config
@ kYR_dnf
Definition: YProtocol.hh:133

References XrdCms::Cluster, XrdCms::CmsState, XrdCms::Config, DEBUGR, XrdCmsRouting::Delayable, XrdSysError::Emsg(), EPNAME, XrdCmsRouting::Forward, XrdCmsRouter::getMethod(), 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.

+ Here is the call graph for this function:

◆ Match()

XrdProtocol * XrdCmsProtocol::Match ( XrdLink lp)
virtual

Implements XrdProtocol.

Definition at line 234 of file XrdCmsProtocol.cc.

235 {
236 CmsRRHdr Hdr;
237 int 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)
char isConn
Definition: XrdCmsNode.hh:71
char isGone
Definition: XrdCmsNode.hh:72
void Lock()
Definition: XrdCmsNode.hh:175
char isOffline
Definition: XrdCmsNode.hh:64
void UnLock()
Definition: XrdCmsNode.hh:177
char isBound
Definition: XrdCmsNode.hh:69
void Del(XrdCmsNode *nP)
Definition: XrdCmsRTable.cc:72
XrdCmsRTable RTable
Definition: XrdCmsRTable.cc:40

References XrdCmsConfig::AskPing, XrdCms::Cluster, XrdCms::Config, XrdCmsRTable::Del(), XrdCmsCluster::Remove(), XrdCms::RTable, XrdLink::Serialize(), XrdLink::setEtext(), XrdCmsCluster::SLock(), and XrdCl::Sync().

+ 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, and XrdCms::Say.

+ Here is the call graph for this function:

◆ Ref()

void XrdCmsProtocol::Ref ( int  rcnt)

Definition at line 1059 of file XrdCmsProtocol.cc.

1060 {
1061 // Update the reference counter
1062 //
1063  refMutex.Lock();
1064  refCount += rcnt;
1065 
1066 // Check if someone is waiting for the count to drop to zero
1067 //
1068  if (refWait && refCount <= 0) {refWait->Post(); refWait = 0;}
1069 
1070 // All done
1071 //
1072  refMutex.UnLock();
1073 }

◆ 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 Stats(char *bfr, int bln)
int Statt(char *bfr, int bln)

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

+ Here is the call graph for this function:

Friends And Related Function 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: