Loading...
Searching...
No Matches
XrdCmsClientMan Class Reference

`#include <XrdCmsClientMan.hh>`

Collaboration diagram for XrdCmsClientMan:

## Public Member Functions

| XrdCmsClientMan (char *host, int port, int cw, int nr, int rw, int rd)
| ~XrdCmsClientMan ()
int | delayResp (XrdOucErrInfo &Resp)
int | isActive ()
int | manPort ()
char * | Name ()
XrdCmsClientMan * | nextManager ()
char * | NPfx ()
int | Send (unsigned int &iMan, char *msg, int mlen=0)
int | Send (unsigned int &iMan, const struct iovec *iov, int iovcnt, int iotot=0)
void | setNext (XrdCmsClientMan *np)
void * | Start ()
int | Suspended ()
int | waitTime ()
int | whatsUp (const char *user, const char *path, unsigned int iMan)

## Static Public Member Functions

static void | setConfig (const char *cfn)
static void | setNetwork (XrdInet *nP)

## Static Public Attributes

static char | doDebug = 0

## Detailed Description

Definition at line 47 of file XrdCmsClientMan.hh.

## Constructor & Destructor Documentation

## XrdCmsClientMan()

XrdCmsClientMan::XrdCmsClientMan | ( | char * | host,
|  | int | port,
|  | int | cw,
|  | int | nr,
|  | int | rw,
|  | int | rd )

Definition at line 66 of file XrdCmsClientMan.cc.

: syncResp(0)
{
static XrdSysMutex initMutex;
static int Instance = 0;
char *dot;
Host = strdup(host);
if ((dot = index(Host, '.')))
{*dot = '\0'; HPfx = strdup(Host); *dot = '.';}
else HPfx = strdup(Host);
Port = port;
Link = 0;
Active = 0;
Silent = 0;
Suspend = 1;
RecvCnt = 0;
nrMax = nr;
NetBuff = BuffPool.Alloc(XrdOucEI::Max_Error_Len);
repWMax = rw;
repWait = 0;
minDelay= rd;
maxDelay= rd*3;
chkCount= chkVal;
lastUpdt= lastTOut = time(0);
Next = 0;
manInst = 1;
// Compute dally value
//
dally = cw / 2 - 1;
if (dally < 3) dally = 3;
else if (dally > 10) dally = 10;
// Provide a unique mask number for this manager
//
initMutex.Lock();
manMask = 1<<Instance++;
initMutex.UnLock();
}
XrdSysMutex::Lock
void Lock()
Definition XrdSysPthread.hh:222
XrdSysMutex::UnLock
void UnLock()
Definition XrdSysPthread.hh:224
XrdOucEI::Max_Error_Len
static const size_t Max_Error_Len
Definition XrdOucErrInfo.hh:51

References XrdSysMutex::Lock(), XrdOucEI::Max_Error_Len, and XrdSysMutex::UnLock().

Referenced by nextManager(), and setNext().

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

## ~XrdCmsClientMan()

XrdCmsClientMan::~XrdCmsClientMan | ( |  | ) |

Definition at line 112 of file XrdCmsClientMan.cc.

{
if (Link) Link->Close();
if (Host) free(Host);
if (HPfx) free(HPfx);
if (NetBuff) NetBuff->Recycle();
}

## Member Function Documentation

## delayResp()

int XrdCmsClientMan::delayResp | ( | XrdOucErrInfo & | Resp | ) |

Definition at line 124 of file XrdCmsClientMan.cc.

{
XrdCmsResp *rp;
int msgid;
// Obtain the message ID
//
if (!(msgid = Resp.getErrInfo()))
{Say.Emsg("Manager", Host, "supplied invalid waitr msgid");
Resp.setErrInfo(EILSEQ, "redirector protocol error");
syncResp.Post();
return SFS_ERROR;
}
// Allocate a delayed response object
//
if (!(rp = XrdCmsResp::Alloc(&Resp, msgid)))
{Say.Emsg("Manager",ENOMEM,"allocate resp object for",Resp.getErrUser());
Resp.setErrInfo(0, "0");
syncResp.Post();
return SFS_STALL;
}
// Add this object to our delayed response queue. If the manager bounced then
// purge all of the pending repsonses to avoid sending wrong ones.
//
if (msgid < maxMsgID) RespQ.Purge();
maxMsgID = msgid;
RespQ.Add(rp);
// Tell client to wait for response. The semaphore post allows the manager
// to get the next message from the cmsd. This prevents us from getting the
// delayed response before the response object is added to the queue.
//
Resp.setErrInfo(0, "");
syncResp.Post();
return SFS_STARTED;
}
SFS_ERROR
#define SFS_ERROR
Definition XrdSfsInterface.hh:109
SFS_STALL
#define SFS_STALL
Definition XrdSfsInterface.hh:107
SFS_STARTED
#define SFS_STARTED
Definition XrdSfsInterface.hh:111
XrdCmsResp::Alloc
static XrdCmsResp * Alloc(XrdOucErrInfo *erp, int msgid)
Definition XrdCmsResp.cc:64
XrdOucErrInfo::getErrUser
const char * getErrUser()
Definition XrdOucErrInfo.hh:297
XrdOucErrInfo::setErrInfo
int setErrInfo(int code, const char *emsg)
Definition XrdOucErrInfo.hh:147
XrdOucErrInfo::getErrInfo
int getErrInfo()
Definition XrdOucErrInfo.hh:243
XrdSysError::Emsg
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition XrdSysError.cc:95
XrdCms::Say
XrdSysError Say
Definition XrdCmsManager.cc:62

References XrdCmsResp::Alloc(), XrdOucErrInfo::getErrInfo(), XrdOucErrInfo::getErrUser(), XrdCms::Say, XrdOucErrInfo::setErrInfo(), SFS_ERROR, SFS_STALL, and SFS_STARTED.

Here is the call graph for this function:

## isActive()

int XrdCmsClientMan::isActive | ( |  | ) |

inline

Definition at line 55 of file XrdCmsClientMan.hh.

{AtomicRet(myData, Active);}
AtomicRet
#define AtomicRet(mtx, x)
Definition XrdSysAtomics.hh:76

References AtomicRet.

## manPort()

int XrdCmsClientMan::manPort | ( |  | ) |

inline

Definition at line 62 of file XrdCmsClientMan.hh.

{return Port;}

## Name()

char * XrdCmsClientMan::Name | ( |  | ) |

inline

Definition at line 59 of file XrdCmsClientMan.hh.

{return Host;}

Referenced by XrdCmsFinderRMT::Prepare().

Here is the caller graph for this function:

## nextManager()

XrdCmsClientMan * XrdCmsClientMan::nextManager | ( |  | ) |

inline

Definition at line 57 of file XrdCmsClientMan.hh.

{return Next;}

References XrdCmsClientMan().

Referenced by XrdCmsFinderRMT::~XrdCmsFinderRMT().

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

## NPfx()

char * XrdCmsClientMan::NPfx | ( |  | ) |

inline

Definition at line 60 of file XrdCmsClientMan.hh.

{return HPfx;}

## Send() [1/2]

int XrdCmsClientMan::Send | ( | unsigned int & | iMan,
|  | char * | msg,
|  | int | mlen = 0 )

Definition at line 167 of file XrdCmsClientMan.cc.

{
int allok = 0;
// Determine message length
//
if (!mlen) mlen = strlen(msg);
// Send the request
//
myData.Lock();
iMan = manInst;
if (Active)
{if (Link)
{if (!(allok = Link->Send(msg, mlen) > 0))
{Active = 0;
Link->Close(1);
manInst++;
} else SendCnt++;
}
}
myData.UnLock();
// All done
//
return allok;
}

Referenced by XrdCmsFinderRMT::Forward(), and XrdCmsFinderRMT::Prepare().

Here is the caller graph for this function:

## Send() [2/2]

int XrdCmsClientMan::Send | ( | unsigned int & | iMan,
|  | const struct iovec * | iov,
|  | int | iovcnt,
|  | int | iotot = 0 )

Definition at line 197 of file XrdCmsClientMan.cc.

{
int allok = 0;
// Send the request
//
myData.Lock();
iMan = manInst;
if (Active)
{if (Link)
{if (!(allok = Link->Send(iov, iovcnt, iotot) > 0))
{Active = 0;
Link->Close(1);
manInst++;
} else SendCnt++;
}
}
myData.UnLock();
// All done
//
return allok;
}

## setConfig()

void XrdCmsClientMan::setConfig | ( | const char * | cfn | ) |

inline static

Definition at line 81 of file XrdCmsClientMan.hh.

{ConfigFN = cfn;}

Referenced by XrdCmsFinderRMT::Configure().

Here is the caller graph for this function:

## setNetwork()

void XrdCmsClientMan::setNetwork | ( | XrdInet * | nP | ) |

inline static

Definition at line 79 of file XrdCmsClientMan.hh.

{Network = nP;}

Referenced by XrdCmsFinderRMT::Configure().

Here is the caller graph for this function:

## setNext()

void XrdCmsClientMan::setNext | ( | XrdCmsClientMan * | np | ) |

inline

Definition at line 77 of file XrdCmsClientMan.hh.

{Next = np;}

References XrdCmsClientMan().

Here is the call graph for this function:

## Start()

void * XrdCmsClientMan::Start | ( |  | ) |

Definition at line 225 of file XrdCmsClientMan.cc.

{
// First step is to connect to the manager
//
do {Hookup();
// Now simply start receiving messages on the stream. When we get a
// respwait reply then we must be assured that the object representing
// the request is added to the queue before the actual reply arrives.
// We do this by waiting on syncResp which is posted once the request
// object is fully processed. The actual response associated with the
// respwait is synchronized during the callback phase since the client
// must receive the respwait before the subsequent response.
//
while(Receive())
if (Response.modifier & CmsResponse::kYR_async) relayResp();
else if (Response.rrCode == kYR_status) setStatus();
else if (XrdCmsClientMsg::Reply(HPfx, Response, NetBuff))
{if (Response.rrCode == kYR_waitresp) syncResp.Wait();}
// Tear down the connection
//
myData.Lock();
if (Link) {Link->Close(); Link = 0;}
Active = 0; Suspend = 1;
myData.UnLock();
// Indicate the problem
//
Say.Emsg("ClientMan", "Disconnected from", Host);
XrdSysTimer::Snooze(dally);
} while(1);
// We should never get here
//
return (void *)0;
}
XrdCmsClientMsg::Reply
static int Reply(const char *Man, XrdCms::CmsRRHdr &hdr, XrdOucBuffer *buff)
Definition XrdCmsClientMsg.cc:142
XrdSysTimer::Snooze
static void Snooze(int seconds)
Definition XrdSysTimer.cc:168
XrdCms::kYR_waitresp
@ kYR_waitresp
Definition YProtocol.hh:145
XrdCms::kYR_status
@ kYR_status
Definition YProtocol.hh:112
XrdCms::CmsResponse::kYR_async
@ kYR_async
Definition YProtocol.hh:170

References XrdCms::CmsResponse::kYR_async, XrdCms::kYR_status, XrdCms::kYR_waitresp, XrdCmsClientMsg::Reply(), XrdCms::Say, and XrdSysTimer::Snooze().

Referenced by XrdCmsStartManager().

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

## Suspended()

int XrdCmsClientMan::Suspended | ( |  | ) |

inline

Definition at line 70 of file XrdCmsClientMan.hh.

{AtomicBeg(myData);
int sVal = AtomicGet(Suspend);
AtomicEnd(myData);
if (!sVal) return sVal;
return chkStatus();
}
AtomicBeg
#define AtomicBeg(Mtx)
Definition XrdSysAtomics.hh:63
AtomicGet
#define AtomicGet(x)
Definition XrdSysAtomics.hh:71
AtomicEnd
#define AtomicEnd(Mtx)
Definition XrdSysAtomics.hh:64

References AtomicBeg, AtomicEnd, and AtomicGet.

## waitTime()

int XrdCmsClientMan::waitTime | ( |  | ) |

inline

Definition at line 86 of file XrdCmsClientMan.hh.

{AtomicRet(myData, repWait);}

References AtomicRet.

## whatsUp()

int XrdCmsClientMan::whatsUp | ( | const char * | user,
|  | const char * | path,
|  | unsigned int | iMan )

Definition at line 267 of file XrdCmsClientMan.cc.

{
EPNAME("whatsUp");
unsigned int xMan;
int theDelay, inQ;
bool lClose = false;
// The cmsd did not respond. Increase silent count and see if restart is needed
// Otherwise, increase the wait interval just in case things are just slow.
//
myData.Lock();
if (Active)
{if (Active == RecvCnt)
{if ((time(0)-lastTOut) >= repWait)
{Silent++;
if (Silent > nrMax)
{Active = 0; Silent = 0; Suspend = 1;
if (Link && iMan == manInst)
{Link->Close(1);
manInst++; lClose = true;
}
} else if (Silent & 0x02 && repWait < repWMax) repWait++;
}
} else {Active = RecvCnt; Silent = 0; lastTOut = time(0);}
}
// Calclulate how long to delay the client. This will be based on the number
// of outstanding requests bounded by the config delay value.
//
inQ = XrdCmsClientMsg::inQ();
theDelay = inQ * qTime;
xMan = manInst;
myData.UnLock();
theDelay = theDelay/1000 + (theDelay % 1000 ? 1 : 0);
if (theDelay < minDelay) theDelay = minDelay;
if (theDelay > maxDelay) theDelay = maxDelay;
// Do Some tracing here
//
TRACE(Redirect, user <<" no resp from inst " <<iMan <<" of "<<HPfx
<<" in " <<repWait
<<" inst " <<xMan <<(lClose ? " closed" : " steady")
<<"; inQ " <<inQ <<" delay " <<theDelay <<" path=" <<path);
return theDelay;
}
EPNAME
#define EPNAME(x)
Definition XrdBwmTrace.hh:56
TRACE
#define TRACE(act, x)
Definition XrdTrace.hh:63
XrdCmsClientMsg::inQ
static int inQ()
Definition XrdCmsClientMsg.hh:52

References EPNAME, XrdCmsClientMsg::inQ(), and TRACE.

Here is the call graph for this function:

## Member Data Documentation

## doDebug

char XrdCmsClientMan::doDebug = 0

static

Definition at line 51 of file XrdCmsClientMan.hh.

Referenced by XrdCmsFinderRMT::Forward(), XrdCmsFinderRMT::Locate(), XrdCmsFinderRMT::Prepare(), and XrdCmsFinderRMT::Space().

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

- XrdCmsClientMan.hh
- XrdCmsClientMan.cc