XRootD
Loading...
Searching...
No Matches
XrdSsiClientProvider Class Reference
Inheritance diagram for XrdSsiClientProvider:
Collaboration diagram for XrdSsiClientProvider:

Public Member Functions

 XrdSsiClientProvider ()
virtual ~XrdSsiClientProvider ()
XrdSsiServiceGetService (XrdSsiErrInfo &eInfo, const std::string &contact, int oHold=256)
virtual bool Init (XrdSsiLogger *logP, XrdSsiCluster *clsP, std::string cfgFn, std::string parms, int argc, char **argv)
virtual rStat QueryResource (const char *rName, const char *contact=0)
virtual void SetCBThreads (int cbNum, int ntNum)
virtual bool SetConfig (XrdSsiErrInfo &eInfo, std::string &optname, int optvalue)
virtual void SetSpread (short ssz)
virtual void SetTimeout (tmoType what, int tmoval)
Public Member Functions inherited from XrdSsiProvider
 XrdSsiProvider ()
 Constructor.
virtual int Control (CTL_Cmd cmd, const void *argP, void *&resP)
int GetVersion ()
virtual void ResourceAdded (const char *rName)
virtual void ResourceRemoved (const char *rName)

Additional Inherited Members

Public Types inherited from XrdSsiProvider
enum  CTL_Cmd { CTL_None = 0 }
enum  rStat {
  notPresent = 0 ,
  isPresent ,
  isPending
}
enum  tmoType {
  connect_N =0 ,
  connect_T ,
  idleClose ,
  request_T ,
  response_T ,
  stream_T
}
Static Public Attributes inherited from XrdSsiProvider
static const int SsiVersion = 0x00010000
Protected Member Functions inherited from XrdSsiProvider
virtual ~XrdSsiProvider ()
 Destructor. The providor object cannot be and never is explicitly deleted.

Detailed Description

Definition at line 99 of file XrdSsiClient.cc.

Constructor & Destructor Documentation

◆ XrdSsiClientProvider()

XrdSsiClientProvider::XrdSsiClientProvider ( )
inline

Definition at line 129 of file XrdSsiClient.cc.

129{}

◆ ~XrdSsiClientProvider()

virtual XrdSsiClientProvider::~XrdSsiClientProvider ( )
inlinevirtual

Definition at line 130 of file XrdSsiClient.cc.

130{}

Member Function Documentation

◆ GetService()

XrdSsiService * XrdSsiClientProvider::GetService ( XrdSsiErrInfo & eInfo,
const std::string & contact,
int oHold = 256 )
virtual

Obtain a service object (client-side or server-side).

Parameters
eInfothe object where error status is to be placed.
contactthe point of first contact when processing a request. The contact may be "host:port" where "host" is a DNS name, an IPV4 address (i.e. d.d.d.d), or an IPV6 address (i.e. [x:x:x:x:x:x]), and "port" is either a numeric port number or the service name assigned to the port number. You may specify more than one contact by separating each with a comma (e.g. host1:port,host2:port,...). Each host must be equivalent with respect to request processing. This is a null string if the call is being made server-side. Note that only one service object is obtained by a server.
oHoldthe maximum number of request objects that should be held in reserve for future calls.
Returns
=0 A service object could not be created, eInfo has the reason.
!0 Pointer to a service object.

Reimplemented from XrdSsiProvider.

Definition at line 141 of file XrdSsiClient.cc.

144{
145 static const int maxTMO = 0x7fffffff;
146 XrdNetAddr netAddr;
147 std::string eMsg;
148 const char *eText = 0;
149 char buff[512];
150
151// Allocate a scheduler if we do not have one and set default env (1st call)
152//
153 if (!Atomic_GET(initDone))
154 {clMutex.Lock();
155 if (!Logger) SetLogger();
156 if (!schedP) SetScheduler();
158 if (!dsTTLSet) clEnvP->PutInt("DataServerTTL", maxTMO);
159 if (!reqTOSet) clEnvP->PutInt("RequestTimeout", maxTMO);
160 if (!strTOSet) clEnvP->PutInt("StreamTimeout", maxTMO);
161 clEnvP->PutInt("ParallelEvtLoop",maxPEL);
162 if (rDisp == rDispNone || rDisp == rDispRR)
163 clEnvP->PutInt("IPNoShuffle", 1);
164 initDone = true;
165 clMutex.UnLock();
166 }
167
168// If no contact is given then declare an error
169//
170 if (contact.empty())
171 {eInfo.Set("Contact not specified.", EINVAL); return 0;}
172
173// If this is a single contact which is really a singleton, don't create
174// a registry entry for it as it's just not needed (we need one to rotate).
175//
176 if (contact.find(',') != std::string::npos
177 || !XrdNetUtils::Singleton(contact.c_str()))
178 {int cNum = contactN++;
179 bool rotate = rDisp == rDispRR;
180 snprintf(buff,sizeof(buff),"%ccontact-%d:4901",XrdNetRegistry::pfx,cNum);
181 if (!XrdNetRegistry::Register(buff, contact.c_str(), &eMsg, rotate))
182 eText = (eMsg.size() ? eMsg.c_str() : "reason unknown");
183
184 } else {
185
186 if (!(eText = netAddr.Set(contact.c_str()))
187 && !netAddr.Format(buff, sizeof(buff), XrdNetAddrInfo::fmtName))
188 eText = "formatting failed";
189 }
190
191// Check if validation or registration failed
192//
193 if (eText)
194 {snprintf(buff, sizeof(buff), "Unable to validate contact; %s", eText);
195 eInfo.Set(buff, EINVAL);
196 return 0;
197 }
198
199// Allocate a service object and return it
200//
201 return new XrdSsiServReal(buff, oHold);
202}
#define eMsg(x)
#define Atomic_GET(x)
static Env * GetEnv()
Get default client environment.
bool PutInt(const std::string &key, int value)
Definition XrdClEnv.cc:110
int Format(char *bAddr, int bLen, fmtUse fmtType=fmtAuto, int fmtOpts=0)
@ fmtName
Hostname if it is resolvable o/w use fmtAddr.
const char * Set(const char *hSpec, int pNum=PortInSpec)
static bool Register(const char *hName, const char *hList[], int hLNum, std::string *eText=0, bool rotate=false)
static const char pfx
Registry names must start with this character.
static bool Singleton(const char *hSpec, const char **eText=0)
void Set(const char *eMsg=0, int eNum=0, int eArg=0)
XrdScheduler * schedP
short maxPEL
XrdCl::Env * clEnvP
XrdSysMutex clMutex
static const int rDispRR
XrdSysLogger * Logger
static const int rDispNone
bool reqTOSet
char rDisp
bool strTOSet
bool dsTTLSet

References Atomic_GET, XrdSsi::clEnvP, XrdSsi::clMutex, XrdSsi::dsTTLSet, eMsg, XrdNetAddrInfo::fmtName, XrdNetAddrInfo::Format(), XrdCl::DefaultEnv::GetEnv(), XrdSsi::Logger, XrdSsi::maxPEL, XrdNetRegistry::pfx, XrdSsi::rDisp, XrdSsi::rDispNone, XrdSsi::rDispRR, XrdNetRegistry::Register(), XrdSsi::reqTOSet, XrdSsi::schedP, XrdNetAddr::Set(), XrdSsiErrInfo::Set(), XrdNetUtils::Singleton(), and XrdSsi::strTOSet.

Here is the call graph for this function:

◆ Init()

virtual bool XrdSsiClientProvider::Init ( XrdSsiLogger * logP,
XrdSsiCluster * clsP,
std::string cfgFn,
std::string parms,
int argc,
char ** argv )
inlinevirtual

Initialize server-side processing. This method is invoked prior to any other method in the XrdSsiProvider object.

Parameters
logPpointer to the logger object for message routing.
clsPpointer to the cluster management object. This pointer is nil when a service object is being obtained by an unclustered system (i.e. a stand-alone server).
cfgFnfile path to the the conifiguration file.
parmsconifiguration parameters, if any.
argcThe count of command line arguments (always >= 1).
argvPointer to a null terminated array of tokenized command line arguments. These arguments are taken from the command line after the "-+xrdssi" option (see invoking xrootd), if present. The first argument is always the same as argv[0] in main().
Returns
true Initialization succeeded.
=0 Initialization failed. The method should include an error message in the log indicating why initialization failed.

Implements XrdSsiProvider.

Definition at line 108 of file XrdSsiClient.cc.

114 {return true;}

◆ QueryResource()

virtual rStat XrdSsiClientProvider::QueryResource ( const char * rName,
const char * contact = 0 )
inlinevirtual

Implements XrdSsiProvider.

Definition at line 116 of file XrdSsiClient.cc.

118 {return notPresent;}

References XrdSsiProvider::notPresent.

◆ SetCBThreads()

void XrdSsiClientProvider::SetCBThreads ( int cbNum,
int ntNum )
virtual

Set thread values. This call is deprecated. You should use SetConfig(). This method has no meaning server-side and is ignored.

Parameters
cbNumEquivalent to SetConfig("cbThreads", cbNum).
ntNumEquivalent to SetConfig("netThreads", ntNum).

Reimplemented from XrdSsiProvider.

Definition at line 208 of file XrdSsiClient.cc.

209{
210// Validate thread number
211//
212 if (cbNum > 1)
213 {if (cbNum > 32767) cbNum = 32767; // Max short value
214 if (ntNum < 1) ntNum = cbNum*10/100;
215 if (ntNum < 3) ntNum = 0;
216 else if (ntNum > 100) ntNum = 100;
217 clMutex.Lock();
218 maxTCB = static_cast<short>(cbNum);
219 maxCLW = static_cast<short>(ntNum);
220 clMutex.UnLock();
221 }
222}
short maxCLW
short maxTCB

References XrdSsi::clMutex, XrdSsi::maxCLW, and XrdSsi::maxTCB.

◆ SetConfig()

bool XrdSsiClientProvider::SetConfig ( XrdSsiErrInfo & eInfo,
std::string & optname,
int optvalue )
virtual

Set a configuration option for execution behaviour.

Parameters
eInfoThe object where error status is to be placed.
optnameThe name of the option (see table below).
optvalueThe value to be set for the option.
Returns
true Option set.
false Option not set, eInfo holds the reason.
Note
All calls to SetConfig() must occur before GetService() is called.

The following table list the currently supported keynames and what the value actually does. These options only apply to the client. The options must be set before calling GetService().

cbThreads The maximum number of threads to be used for callbacks and sets the maximum number of active callbacks (default 300). set a value between 1 and 32767. Note: the nproc ulimit is final arbiter of the actual number of threads to use. hiResTime enables the use of a high resolution timer in log message timestamps. The optvalue is immaterial as this simply sets feature on and once set on cannot be set off. netThreads The maximum number of threads to be used to handle network traffic. The minimum is 3, the default is 10% of cbThreads but no more than 100. pollers The number network interrupt pollers to run. Larger values allow the initial fielding of more interrupts. Care must be taken to not overrun netThreads. The default is 3. The suggested maximum is the number of cores. reqDispatch Request dispatch algorithm to use when contact has multiple endpoints. Choose one of: < 0: Random choice each time. = 0: Use DNS order. > 0: Round robbin (the default).

Reimplemented from XrdSsiProvider.

Definition at line 228 of file XrdSsiClient.cc.

230{
231// Look for an option we recognize
232//
233 if (optname == "cbThreads")
234 {if (optvalue < 1)
235 {eInfo.Set("invalid cbThreads value.", EINVAL); return false;}
236 if (optvalue > 32767) optvalue = 32767;
237 clMutex.Lock();
238 maxTCB = static_cast<short>(optvalue);
239 clMutex.UnLock();
240 }
241 else if (optname == "hiResTime") hiResTime = true;
242 else if (optname == "netThreads")
243 {if (optvalue < 1)
244 {eInfo.Set("invalid netThreads value.", EINVAL); return false;}
245 if (optvalue > 32767) optvalue = 32767;
246 clMutex.Lock();
247 maxCLW = static_cast<short>(optvalue);
248 clMutex.UnLock();
249 }
250 else if (optname == "pollers")
251 {if (optvalue < 1)
252 {eInfo.Set("invalid pollers value.", EINVAL); return false;}
253 if (optvalue > 32767) optvalue = 32767;
254 clMutex.Lock();
255 maxPEL = static_cast<short>(optvalue);
256 clMutex.UnLock();
257 }
258 else if (optname == "reqDispatch")
259 {clMutex.Lock();
260 if (optvalue < 0) rDisp = rDispRand;
261 else if (optvalue > 0) rDisp = rDispRR;
262 else rDisp = rDispNone;
263 clMutex.UnLock();
264 }
265 else {eInfo.Set("invalid option name.", EINVAL); return false;}
266
267 return true;
268}
static const int rDispRand
bool hiResTime

References XrdSsi::clMutex, XrdSsi::hiResTime, XrdSsi::maxCLW, XrdSsi::maxPEL, XrdSsi::maxTCB, XrdSsi::rDisp, XrdSsi::rDispNone, XrdSsi::rDispRand, XrdSsi::rDispRR, and XrdSsiErrInfo::Set().

Here is the call graph for this function:

◆ SetSpread()

void XrdSsiClientProvider::SetSpread ( short ssz)
virtual

Set the client-size request spread size.

Parameters
sszThe spread value which may be <0, -0, or >0: >0 The maximum number of connections to use to to handle requests. No more or less are used until reset. =0 Turns on auto-tuning using curent setting. The initial default is 4. The size is automatically increased to accomodate the number of simultaeous requests. <0 Turns on auto-tuning using curent setting using the abs(sval) as the new spread value. The size is The size is automatically increased to accomodate the number of simultaeous requests.
Note
This method may be called at any time. An abs(ssz) value > 1024 is set to 1024. Auto-tuning must be requested; it's not the default.

Reimplemented from XrdSsiProvider.

Definition at line 345 of file XrdSsiClient.cc.

346{
347 sidScale.setSpread(ssz);
348}
void setSpread(short sval)
XrdSsiScale sidScale

References XrdSsi::sidScale.

◆ SetTimeout()

void XrdSsiClientProvider::SetTimeout ( XrdSsiProvider::tmoType what,
int tmoval )
virtual

Reimplemented from XrdSsiProvider.

Definition at line 354 of file XrdSsiClient.cc.

355{
356
357// Ignore invalid timeouts
358//
359 if (tmoval <= 0) return;
360
361// Get global environment
362//
363 clMutex.Lock();
365
366// Set requested timeout
367//
368 switch(what)
369 {case connect_N: clEnvP->PutInt("ConnectionRetry", tmoval);
370 break;
371 case connect_T: clEnvP->PutInt("ConnectionWindow", tmoval);
372 break;
373 case idleClose: clEnvP->PutInt("DataServerTTL", tmoval);
374 dsTTLSet = true;
375 break;
376 case request_T: clEnvP->PutInt("RequestTimeout", tmoval);
377 reqTOSet = true;
378 break;
379 case stream_T: clEnvP->PutInt("StreamTimeout", tmoval);
380 strTOSet = true;
381 break;
382 default: break;
383 }
384
385// All done
386//
387 clMutex.UnLock();
388}
@ idleClose
Time before an idle socket is closed (client)
@ stream_T
Time to wait for socket activity (Client)
@ connect_T
Time to wait for a connection (client)
@ request_T
Time to wait for a request to finsish(client)
@ connect_N
Number of times to try connection (client)

References XrdSsi::clEnvP, XrdSsi::clMutex, XrdSsiProvider::connect_N, XrdSsiProvider::connect_T, XrdSsi::dsTTLSet, XrdCl::DefaultEnv::GetEnv(), XrdSsiProvider::idleClose, XrdSsi::reqTOSet, XrdSsiProvider::request_T, XrdSsiProvider::stream_T, and XrdSsi::strTOSet.

Here is the call graph for this function:

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