XRootD
XrdCmsUtils Class Reference

#include <XrdCmsUtils.hh>

+ Collaboration diagram for XrdCmsUtils:

Public Member Functions

 XrdCmsUtils ()
 
 ~XrdCmsUtils ()
 

Static Public Member Functions

static XrdCmsPerfMonloadPerfMon (XrdSysError *eDest, const char *libPath, XrdVersionInfo &urVer)
 Load the performance monitor plugin. More...
 
static bool ParseMan (XrdSysError *eDest, XrdOucTList **oldMans, char *hSpec, char *hPort, int *sPort=0, bool hush=false)
 
static char * ParseManPort (XrdSysError *eDest, XrdOucStream &CFile, char *hSpec)
 
static const char * SiteName (int snum)
 

Detailed Description

Definition at line 40 of file XrdCmsUtils.hh.

Constructor & Destructor Documentation

◆ XrdCmsUtils()

XrdCmsUtils::XrdCmsUtils ( )
inline

Definition at line 112 of file XrdCmsUtils.hh.

112 {}

◆ ~XrdCmsUtils()

XrdCmsUtils::~XrdCmsUtils ( )

Member Function Documentation

◆ loadPerfMon()

XrdCmsPerfMon * XrdCmsUtils::loadPerfMon ( XrdSysError eDest,
const char *  libPath,
XrdVersionInfo &  urVer 
)
static

Load the performance monitor plugin.

Parameters
eDestPointer to the error message object to route messages.
libPathA pointer to the shared library path.
urVerReference to the caller's version number.
Returns
Pointer to the performance monitor object or nil upon failure.

Definition at line 108 of file XrdCmsUtils.cc.

111 {
112  XrdOucPinLoader perfLib(eDest, &urVer, "cms.perf", libPath);
113 
114  XrdCmsPerfMon **perfMon = (XrdCmsPerfMon**)perfLib.Resolve("XrdCmsPerfMonitor");
115 
116  return (perfMon ? *perfMon : 0);
117 }
static XrdSysError eDest(0,"crypto_")

References eDest, and XrdOucPinLoader::Resolve().

Referenced by XrdCmsClientConfig::Configure(), and XrdCmsMeter::Monitor().

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

◆ ParseMan()

bool XrdCmsUtils::ParseMan ( XrdSysError eDest,
XrdOucTList **  oldMans,
char *  hSpec,
char *  hPort,
int *  sPort = 0,
bool  hush = false 
)
static

Obtain and merge a new manager list with an existing list.

Parameters
eDestPointer to the error message object to route messages.
oldMansA pointer to the existing list of managers, if any. If oldMans is nil, then the hSpec/hPort/sPort is processed but no list is returned.
hSpecthe host specification suitable for XrdNetAddr.Set(). The hSpec may end with a '+' indicating that all addresses assigned to hSpec be considered for inclusion.
hPortthe port specification which can be a text number or a service name (e.g. xroot).
sPortIf not nil, the *sPort will be set to the numeric hPort if the IP address in one of the entries matches the host address. Otherwise, the value is unchanged.
hushWhen true does not print the dns name to host mappings.
Returns
Success: True and if oldMans is supplied, the additional entries that do not duplicate existing entries are added to the front. Note: *oldMans->val is the port number. *oldMans->text is the host name. The list of objects belongs to the caller. Failure: False. Any existing list is not modified. However, sPort may be updated, if correct, even when false is returned.

Definition at line 123 of file XrdCmsUtils.cc.

125 {
126  static const size_t maxSNLen = 63;
127  XrdOucTList *newMans, *newP, *oldP, *appList = (oldMans ? *oldMans : 0);
128  XrdOucTList *sP = siteList;
129  const char *eText;
130  char *plus, *atsn, *iName = 0;
131  int nPort, maxIP = 1, snum = 0;
132  bool isBad;
133 
134 // Generate local site name if we haven't done so yet
135 //
136  if (!siteList) siteList = GetLocalSite();
137 
138 // Handle site qualification first
139 //
140  if ((atsn = index(hPort, '@')))
141  {if (*(atsn+1) == '\0')
142  {eDest->Emsg("Config", "site name missing for", hSpec); return 0;}
143  *atsn++ = 0;
144  if (strlen(atsn) > maxSNLen)
145  {eDest->Emsg("Config", "site name too long for", hSpec); return 0;}
146  while(sP && strcmp(sP->text, atsn)) sP = sP->next;
147  if (sP) snum = sP->val;
148  else {siteIndex++;
149  siteList = new XrdOucTList(atsn, siteIndex, siteList);
150  snum = siteIndex;
151  }
152  }
153 
154 // Handle scope qualification next
155 //
156  if ((iName = index(hPort, '%')))
157  {if (*(iName+1) == '\0')
158  {eDest->Emsg("Config", "instance name missing for", hSpec); return 0;}
159  *iName++ = 0;
160  const char *xName = getenv("XRDNAME");
161  if (!xName || strcmp(xName, iName)) sPort = 0;
162  }
163 
164 // Check if this is a multi request
165 //
166  if (!(plus = index(hSpec, '+')) || *(plus+1) != 0) plus = 0;
167  else {*plus = 0; maxIP = 8;
168  if (XrdNetAddr::DynDNS())
169  {eDest->Emsg("Config", "Hostname globbing is not supported "
170  "via dynamic DNS!");
171  return false;
172  }
173  }
174 
175 // Check if the port was specified
176 //
177  if (isdigit(*hPort))
178  {if (XrdOuca2x::a2i(*eDest,"manager port",hPort,&nPort,1,65535))
179  return false;
180  } else {
181  if (!(nPort = XrdNetUtils::ServPort(hPort, "tcp")))
182  {eDest->Emsg("Config", "Unable to find tcp service",hPort,".");
183  return false;
184  }
185  }
186 
187 // Obtain the list. We can't fully resolve this now if we are using a dynamic
188 // DNS so that part will have to wait.
189 //
190  if (XrdNetAddr::DynDNS())
191  {if (sPort)
192  {XrdNetAddr myAddr(0), urAddr;
193  if (!urAddr.Set(hSpec, 0) && myAddr.Same(&urAddr)) *sPort = nPort;
194  }
195  newMans = new XrdOucTList(hSpec, nPort);
196  } else {
197  if (!(newMans = XrdNetUtils::Hosts(hSpec, nPort, maxIP, sPort, &eText)))
198  {char buff[1024];
199  snprintf(buff,sizeof(buff),"'%s'; %c%s",hSpec,tolower(*eText),eText+1);
200  eDest->Emsg("Config", "Unable to add host", buff);
201  return false;
202  }
203  }
204 
205 // If there is no pointer to a list, then the caller merely wanted sPort
206 //
207  if (!oldMans)
208  {while((newP = newMans)) {newMans = newMans->next; delete newP;}
209  return true;
210  }
211 
212 // Merge new list with old list
213 //
214  while((newP = newMans))
215  {newMans = newMans->next;
216  newP->ival[1] = snum;
217  oldP = *oldMans;
218  while(oldP)
219  {if (newP->val == oldP->val && !strcmp(newP->text, oldP->text))
220  {eDest->Say("Config warning: duplicate manager ",newP->text);
221  delete newP;
222  break;
223  }
224  oldP = oldP->next;
225  }
226  if (!oldP)
227  {if (!plus || strcmp(hSpec, newP->text)) isBad = false;
228  else {eDest->Say("Config warning: "
229  "Cyclic DNS registration for ",newP->text,"\n"
230  "Config warning: This cluster will exhibit "
231  "undefined behaviour!!!");
232  isBad = true;
233  }
234  appList = SInsert(appList, newP);
235  if (plus && !hush) Display(eDest, hSpec, newP->text, isBad);
236  }
237  }
238 
239 // Set the new list and return
240 //
241  *oldMans = appList;
242  return true;
243 }
static bool DynDNS()
Definition: XrdNetAddr.hh:52
const char * Set(const char *hSpec, int pNum=PortInSpec)
Definition: XrdNetAddr.cc:216
static int ServPort(const char *sName, bool isUDP=false, const char **eText=0)
Definition: XrdNetUtils.cc:839
static XrdOucTList * Hosts(const char *hSpec, int hPort=-1, int hWant=8, int *sPort=0, const char **eText=0)
Definition: XrdNetUtils.cc:541
XrdOucTList * next
Definition: XrdOucTList.hh:45
char * text
Definition: XrdOucTList.hh:46
static int a2i(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
Definition: XrdOuca2x.cc:45
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:95
void Say(const char *text1, const char *text2=0, const char *txt3=0, const char *text4=0, const char *text5=0, const char *txt6=0)
Definition: XrdSysError.cc:141

References XrdOuca2x::a2i(), XrdNetAddr::DynDNS(), eDest, XrdSysError::Emsg(), XrdNetUtils::Hosts(), XrdOucTList::next, XrdSysError::Say(), XrdNetUtils::ServPort(), XrdNetAddr::Set(), and XrdOucTList::text.

+ Here is the call graph for this function:

◆ ParseManPort()

char * XrdCmsUtils::ParseManPort ( XrdSysError eDest,
XrdOucStream CFile,
char *  hSpec 
)
static

Obtain the port for a manager specification

Parameters
eDestPointer to the error message object to route messages.
CFileThe configuration file stream.
hSpecThe initial manager specification which may or may not have the port number in it.
Returns
Success: Pointer to a copy of the port specification. The caller is responsible for freeing it using free(). Failure: A nil pointer. An error message has already been issued.

Definition at line 249 of file XrdCmsUtils.cc.

251 {
252  char *pSpec;
253 
254 // Screen out IPV6 specifications
255 //
256  if (*hSpec == '[')
257  {if (!(pSpec = index(hSpec, ']')))
258  {eDest->Emsg("Config", "Invalid manager specification -",hSpec);
259  return 0;
260  }
261  } else pSpec = hSpec;
262 
263 // Grab the port number if in the host name. Otherwise make sure it follows.
264 //
265  if ((pSpec = index(pSpec, ':')))
266  {if (!(*(pSpec+1))) pSpec = 0;
267  else *pSpec++ = '\0';
268  }
269  else if (!(pSpec = CFile.GetWord()) || !strcmp(pSpec, "if")) pSpec = 0;
270 
271 // We should have a port specification now
272 //
273  if (!pSpec) {eDest->Emsg("Config", "manager port not specified for", hSpec);
274  return 0;
275  }
276 
277 // All is well
278 //
279  return strdup(pSpec);
280 }
char * GetWord(int lowcase=0)

References eDest, XrdSysError::Emsg(), and XrdOucStream::GetWord().

+ Here is the call graph for this function:

◆ SiteName()

const char * XrdCmsUtils::SiteName ( int  snum)
static

Translate site number to site name.

Parameters
snumThe site number.
Returns
Pointer to the corresponding site name (anonymous if none).

Definition at line 310 of file XrdCmsUtils.cc.

311 {
312  XrdOucTList *sP = siteList;
313 
314 // Find matching site
315 //
316  while(sP && snum != sP->val) sP = sP->next;
317 
318 // Return result
319 //
320  return (sP ? sP->text : "anonymous");
321 }

References XrdOucTList::next, and XrdOucTList::text.

Referenced by XrdCmsManager::Verify().

+ Here is the caller graph for this function:

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