42#include <sys/resource.h>
47#include "XrdVersion.hh"
127 (
const char *hostname,
128 const struct sockaddr &netaddr,
188#define TS_Lib(x, y, z) if (!strcmp(x, var)) \
189 return (XrdOucUtils::parseLib(*eDest, CFile, x, y, z) ? 0 : 1);
191#define TS_String(x,m) if (!strcmp(x,var)) {free(m); m = strdup(val); return 0;}
193#define TS_Xeq(x,m) if (!strcmp(x,var)) return m(eDest, CFile);
194#define TS_Xer(x,m,v) if (!strcmp(x,var)) return m(eDest, CFile, v);
196#define TS_Set(x,v) if (!strcmp(x,var)) {v=1; CFile.Echo(true); return 0;}
198#define TS_unSet(x,v) if (!strcmp(x,var)) {v=0; CFile.Echo(true); return 0;}
248 int NoGo = 0, immed = 0;
250 extern int opterr,
optopt;
255 if (argc > 1 &&
'-' == *argv[1])
256 while ((c=getopt(argc,argv,
"iw")) && ((
unsigned char)c != 0xff))
261 case 'w': immed = -1;
263 default: buff[0] =
'-'; buff[1] =
optopt; buff[2] =
'\0';
264 Say.
Say(
"Config warning: unrecognized option, ",buff,
", ignored.");
271 {
if (!strcmp(argv[
optind],
"manager")) isManager = 1;
272 else if (!strcmp(argv[
optind],
"server" )) isServer = 1;
273 else if (!strcmp(argv[
optind],
"super" )) isServer = isManager = 1;
274 else Say.
Say(
"Config warning: unrecognized parameter, ",
275 argv[
optind],
", ignored.");
280 inArgv = argv; inArgc = argc;
283 {
Say.
Emsg(
"Config",
"Required config file not specified.");
304 if (!(isManager || isServer))
305 if (!(NoGo |= ConfigProc(1)) && !(isManager || isServer))
306 {
Say.
Say(
"Config warning: role not specified; manager role assumed.");
312 if (!NoGo) NoGo |= ConfigProc();
320 if (immed)
doWait = (immed > 0 ? 0 : 1);
324 if (isManager < 0) isManager = 1;
325 if (isPeer < 0) isPeer = 1;
326 if (isProxy < 0) isProxy = 1;
327 if (isServer < 0) isServer = 1;
359 {
if ((isManager && !isServer) || isPeer)
361 {
Say.
Emsg(
"Config",
"port for this",
myRole,
"not specified.");
380 Say.
Say(
"Config warning: metric scheduling requested without a "
381 "metrics supplier!");
384 Say.
Say(
"Config warning: metrics supplier specified without "
385 "any scheduling metrics!");
391 sprintf(buff,
" phase 1 %s initialization %s.",
myRole,
392 (NoGo ?
"failed" :
"completed"));
421 sprintf(buff,
" phase 2 %s initialization started.",
myRole);
442 if (!strncmp(AdminPath,
"/tmp/", 5))
443 Say.
Say(
"Config warning: adminpath resides in /tmp and may be unstable!");
456 (isManager|isPeer ?
"olbd.nimda":
"olbd.admin"),AdminMode));
461 {
if (!(
mySID = setupSid())) NoGo = 1;
463 Say.
Say(
"Config ",
"Global System Identification: ",
mySID);
465 {envData +=
"&site=";
473 envCGI = (envData.length() > 0 ? strdup(envData.c_str()) : 0);
481 if (!NoGo) NoGo = ConfigOSS();
487 if (!NoGo && isManager) NoGo = setupManager();
488 if (!NoGo && (isServer ||
ManList)) NoGo = setupServer();
496 if (isPeer && isSolo)
503 if (isManager) Who = (isServer ? -1 : 1);
509 if (!NoGo) NoGo |= Manifest();
513 sprintf(buff,
" phase 2 %s initialization %s.",
myRole,
514 (NoGo ?
"failed" :
"completed"));
536 if (
eDest) dynamic = 1;
550 TS_Xeq(
"adminpath", xapath);
553 TS_Xeq(
"blacklist", xblk);
555 TS_Xeq(
"defaults", xdefs);
559 TS_Xeq(
"localroot", xlclrt);
566 TS_Xeq(
"prepmsg", xprepm);
567 TS_Xeq(
"remoteroot", xrmtrt);
568 TS_Xeq(
"repstats", xreps);
571 TS_Xeq(
"subcluster", xsubc);
572 TS_Xeq(
"superport", xsupp);
576 TS_Xer(
"whitelist", xblk,
true);
581 if (!strcmp(var,
"conwait")
582 || !strcmp(var,
"request"))
return 0;
586 if (!strcmp(var,
"pidpath"))
587 {
Say.
Say(
"Config warning: 'cms.pidpath' no longer "
588 "supported; use 'all.pidpath'.");
590 Say.
Say(
"Config warning: ignoring unknown directive '", var,
"'.");
604 time_t eTime = time(0);
618 0,
"Notification handler"))
619 Say.
Emsg(
"cmsd", errno,
"start notification handler");
624 (
void *)0, 0,
"Prep handler"))
625 Say.
Emsg(
"cmsd", errno,
"start prep handler");
631 (
void *)0, 0,
"supervisor"))
648 Say.
Emsg(
"cmsd", errno,
"start admin handler");
660 {
Say.
Emsg(
"Config", errno,
"create state monitor thread");
666 if ((isManager || isPeer) &&
SRVDelay)
667 {wTime =
SRVDelay -
static_cast<int>((time(0) - eTime));
702void XrdCmsConfig::ConfigDefaults(
void)
705 int myTZ, isEast = 0;
709 myName = (
char *)
"localhost";
795 pendplife= 60*60*24*7;
830 if (myTZ <= 0) {isEast = 0x10; myTZ = -myTZ;}
831 if (myTZ > 12) myTZ = 12;
839int XrdCmsConfig::ConfigN2N()
861int XrdCmsConfig::ConfigOSS()
864 const char *,
XrdOucEnv *, XrdVersionInfo &);
876 if (!
ossLib && isProxy)
ossLib = strdup(
"libXrdPss.so");
881 if (!
ossFS)
return 1;
885 if (!isManager && isServer && (arFunc =
theEnv.
GetPtr(
"XrdOssStatInfo2*")))
894int XrdCmsConfig::ConfigProc(
int getrole)
897 int cfgFD, retc, NoGo = 0;
911 if (getrole) CFile.SetEroute(0);
915 while((var = CFile.GetMyFirstWord()))
917 {
if (!strcmp(
"all.role", var) || !strcmp(
"olb.role", var))
918 if (xrole(&
Say, CFile))
919 {CFile.SetEroute(&
Say); CFile.Echo(); NoGo = 1;
923 else if (!strncmp(var,
"cms.", 4)
924 || !strncmp(var,
"olb.", 4)
925 || !strcmp(var,
"ofs.osslib")
926 || !strcmp(var,
"oss.defaults")
927 || !strcmp(var,
"oss.localroot")
928 || !strcmp(var,
"oss.remoteroot")
929 || !strcmp(var,
"oss.namelib")
930 || !strcmp(var,
"all.export")
931 || !strcmp(var,
"all.manager")
932 || !strcmp(var,
"all.role")
933 || !strcmp(var,
"all.seclib")
934 || !strcmp(var,
"all.subcluster"))
935 {
if (
ConfigXeq(var+4, CFile, 0)) {CFile.Echo(); NoGo = 1;}}
936 else if (!strcmp(var,
"oss.stagecmd"))
DiskSS =
true;
940 if ((retc = CFile.LastError()))
959 char buff[512], pp, *mp = prog;
963 while(*mp && *mp !=
' ') mp++;
969 {sprintf(buff,
"find %s executable", ptype);
970 eDest->
Emsg(
"Config", errno, buff, prog);
985int XrdCmsConfig::Manifest()
988 const char *clID, *xop = 0;
993 if (!xrdEnv || !(envFN = xrdEnv->
Get(
"envFile")))
return 0;
995 if ((clID = index(
mySID,
' '))) clID++;
998 if ((xfd =
open(envFN, O_WRONLY|O_APPEND)) < 0) xop =
"open";
999 else {
bool bad =
false;
1001 bad =
write(xfd,(
void *)
"&pfx=",5) < 0
1003 if (!bad && AdminPath)
1004 bad =
write(xfd,(
void *)
"&ap=", 4) < 0
1005 ||
write(xfd,(
void *)AdminPath,strlen(AdminPath)) < 0;
1006 if (!bad) bad =
write(xfd,(
void *)
"&cn=", 4) < 0
1007 ||
write(xfd,(
void *)clID, strlen(clID)) < 0;
1008 if (bad) xop =
"append to";
1012 if (xop)
Say.
Emsg(
"Config", errno, xop, envFN);
1021int XrdCmsConfig::MergeP()
1023 static const unsigned long long stage4MM =
XRDEXP_STAGEMM & ~XRDEXP_STAGE;
1032 unsigned long long Opts;
1033 int pbLen = 0, NoGo = 0, export2MM = isManager && !isServer;
1042 if (export2MM) npinfo.
ssvec = (
Opts & stage4MM ? 1 : 0);
1043 else npinfo.
ssvec = (
Opts & stageAny ? 1 : 0);
1045 Say.
Emsg(
"Config",
"Ignoring duplicate export path",plp->
Path());
1056 {
if (
SanList) Who =
"subcluster manager:";
1057 else Who = (isServer ?
"manager:" :
"meta-manager:");
1058 }
else Who =
"redirector:";
1059 Say.
Say(
"The following paths are available to the ", Who);
1062 {ptype = pp->
PType();
1063 Say.
Say(ptype, (strlen(ptype) > 1 ?
" " :
" "), pp->
Path());
1064 pbLen += strlen(pp->
Path())+8; pp = pp->
Next();
1073 {pbP =
myPaths = (
char *)malloc(pbLen);
1075 {pbP += sprintf(pbP,
"\n%s %s", pp->
PType(), pp->
Path());
1091int XrdCmsConfig::setupManager()
1101 const char *urDom, *myDom = index(
myName,
'.');
1103 while(tP) {nP = tP; tP = tP->
next;
delete nP;}
1105 if (myDom)
while(tP)
1106 {
if ((urDom = index(tP->
text,
'.')) && strcmp(urDom, myDom))
1107 {
Say.
Emsg(
"Config",
"Subcluster's manager", tP->
text,
1108 "is in a different domain.");
1113 if (isBad) {
Say.
Emsg(
"Config",
"Cross domain subclusters disallowed!");
1127 {
Say.
Say(
"Config round robin scheduling in effect.");
1134 0,
"Performance monitor")))
1135 {
Say.
Emsg(
"Config", rc,
"create perf monitor thread");
1144 0,
"Refcount monitor")))
1145 {
Say.
Emsg(
"Config", rc,
"create refcount monitor thread");
1160 if (!isServer && blkChk)
1172int XrdCmsConfig::setupServer()
1180 {
Say.
Emsg(
"Config",
"Manager node not specified for",
myRole,
"role");
1187 while(tp) {n++; tp = tp->
next;}
1189 {
Say.
Emsg(
"Config",
"Too many managers have been specified");
return 1;}
1199 (isManager|isPeer ?
"olbd.seton":
"olbd.notes"),
1205 if (isManager || isPeer)
return 0;
1207 if (isProxy)
return 0;
1218 Say.
Say(
"Config warning: load based scheduling disabled.");
1229char *XrdCmsConfig::setupSid()
1237 if (getenv(
"XRDIFADDRS"))
ifList = strdup(getenv(
"XRDIFADDRS"));
1246 if (isManager && isServer) sfx =
'u';
1247 else sfx = (isManager ?
'm' :
's');
1248 if (isProxy) sfx = toupper(sfx);
1260 if (!sidVal || *sidVal ==
'!')
1262 if (!sidVal) msg =
"too many managers.";
1263 else msg = sidVal+1;
1264 Say.
Emsg(
"cmsd",
"Unable to generate system ID; ", msg);
1274void XrdCmsConfig::Usage(
int rc)
1276std::cerr <<
"\nUsage: cmsd [xrdopts] [-i] [-m] [-s] -c <cfile>" <<std::endl;
1302 if (!isManager)
return CFile.
noEcho();
1305 {
eDest->
Emsg(
"Config",
"allow type not specified");
return 1;}
1307 if (!strcmp(val,
"host")) ishost = 1;
1308 else if (!strcmp(val,
"netgroup")) ishost = 0;
1309 else {
eDest->
Emsg(
"Config",
"invalid allow type -", val);
1314 {
eDest->
Emsg(
"Config",
"allow target name not specified");
return 1;}
1348 if (isManager)
return CFile.
noEcho();
1351 {
eDest->
Emsg(
"Config",
"protocol not specified");
return 1;}
1353 if (strcmp(val,
"xroot"))
1354 {
eDest->
Emsg(
"Config",
"unsupported protocol, '", val,
"'.");
return 1;}
1359 {
eDest->
Emsg(
"Config",
"data server port not specified");
return 1;}
1366 {
eDest->
Emsg(
"Config",
"Unable to find tcp service '",val,
"'.");
1370 if (!(val = CFile.
GetWord()) || !strcmp(val,
"monitor"))
adsMon = 1;
1371 else if (!strcmp(val,
"nomonitor"))
adsMon = 0;
1372 else {
eDest->
Emsg(
"Config",
"invalid option, '", val,
"'.");
1397 mode_t mode = S_IRWXU;
1402 if (!pval || !pval[0])
1403 {
eDest->
Emsg(
"Config",
"adminpath not specified");
return 1;}
1408 {
eDest->
Emsg(
"Config",
"adminpath not absolute");
return 1;}
1409 pval = strdup(pval);
1413 if ((val = CFile.
GetWord()) && val[0])
1414 {
if (!strcmp(
"group", val)) mode |= S_IRWXG;
1415 else {
eDest->
Emsg(
"Config",
"invalid admin path modifier -", val);
1416 free(pval);
return 1;
1422 if (AdminPath) free(AdminPath);
1445 const char *fType = (iswl ?
"whitelist" :
"blacklist");
1450 if (!isManager || isServer)
return CFile.
noEcho();
1455 if (blkList) {free(blkList); blkList = 0;}
1459 if (!val || !val[0])
1466 do {
if (!strcmp(val,
"check"))
1467 {
if (!(val = CFile.
GetWord()) || !val[0])
1468 {
eDest->
Emsg(
"Config",fType,
"check interval not specified");
1474 }
while((val = CFile.
GetWord()));
1478 if (iswl) blkChk = -blkChk;
1482 if (!val || !val[0])
return 0;
1484 {
eDest->
Emsg(
"Config",
"blacklist path not absolute");
return 1;}
1488 blkList = strdup(val);
1511 if (!(val = CFile.
GetWord()) || !val[0])
1512 {
eDest->
Emsg(
"Config",
"tag not specified");
return 1;}
1516 if ((
int)strlen(val) > 16)
1517 {
eDest->
Emsg(
"Config",
"tag is > 16 characters");
return 1;}
1568 const char *etxt =
"invalid delay option";
1569 int i, ppp, minV = 1, ispercent = 0, noStage = 0;
1570 static struct delayopts {
const char *opname;
int *oploc;
int istime;}
1579 {
"nostage", &noStage, 01},
1590 int numopts =
sizeof(dyopts)/
sizeof(
struct delayopts);
1592 if (!isManager && !isPeer)
return CFile.
noEcho();
1595 {
eDest->
Emsg(
"Config",
"delay arguments not specified");
return 1;}
1598 {
for (i = 0; i < numopts; i++)
1599 if (!strcmp(val, dyopts[i].opname))
1600 {
if (!(val = CFile.
GetWord()))
1601 {
eDest->
Emsg(
"Config",
"delay ", dyopts[i].opname,
1602 " argument not specified.");
1605 if (dyopts[i].istime < 0 && !strcmp(val,
"*")) ppp = -1;
1606 else if (dyopts[i].istime)
1610 if (*dyopts[i].opname ==
'r')
1614 if (*dyopts[i].opname ==
's')
1615 {ppp = strlen(val);
SUPLevel = 0; minV = 0;
1616 if (val[ppp-1] ==
'%')
1617 {ispercent = 1; val[ppp-1] =
'\0';}
1622 if (!ispercent) *dyopts[i].oploc = ppp;
1627 eDest->
Say(
"Config warning: ignoring invalid delay option '",val,
"'.");
1704 int Hold = 0, limCent = 0, limFix = 0, limV = 0, qMax = 0, rTry = -1;
1709 if (isMeta || isPeer)
return CFile.
noEcho();
1714 {
eDest->
Emsg(
"Config",
"dfs option not specified");
return 1;}
1718do{
if (!strcmp(
"mdhold", val))
1719 {
if (!(val = CFile.
GetWord()))
1720 {
eDest->
Emsg(
"Config",
"mdhold value not specified.");
return 1;}
1723 else if (!strcmp(
"limit", val))
1724 {
if (!(val = CFile.
GetWord()))
1725 {
eDest->
Emsg(
"Config",
"limit value not specified.");
return 1;}
1726 if ((limCent = !strcmp(
"central",val)) && !(val = CFile.
GetWord()))
1727 {
eDest->
Emsg(
"Config",
"limit value not specified.");
return 1;}
1728 if ((limFix = (*val ==
'=')) && *(val+1)) val++;
1731 else if (!strcmp(
"lookup", val))
1732 {
if (!(val = CFile.
GetWord()))
1733 {
eDest->
Emsg(
"Config",
"lookup value not specified.");
return 1;}
1736 else {
eDest->
Emsg(
"Config",
"invalid lookup value '", val,
"'.");
1740 else if (!strcmp(
"qmax", val))
1741 {
if (!(val = CFile.
GetWord()))
1742 {
eDest->
Emsg(
"Config",
"qmax value not specified.");
return 1;}
1745 else if (!strcmp(
"redirect",val))
1746 {
if (!(val = CFile.
GetWord()))
1747 {
eDest->
Emsg(
"Config",
"redirect value not specified.");
return 1;}
1750 else {
eDest->
Emsg(
"Config",
"invalid redirect value -", val);
1754 else if (!strcmp(
"retries", val))
1755 {
if (!(val = CFile.
GetWord()))
1756 {
eDest->
Emsg(
"Config",
"retries value not specified.");
return 1;}
1759 else {
eDest->
Emsg(
"Config",
"invalid dfs option '",val,
"'.");
return 1;}
1760 }
while((val = CFile.
GetWord()));
1765 if (isManager && isServer)
1773 {
if (limFix) limV = -limV;
1775 else if (isManager) limV = 0;
1831 struct xeqopts {
const char *opname;
int doset;
XrdOucProg **pgm;} xqopts[] =
1841 int i, xtval = 0, numopts =
sizeof(xqopts)/
sizeof(
struct xeqopts);
1846 if (!isServer)
return CFile.
noEcho();
1851 while (val && *val !=
'/')
1852 {
for (i = 0; i < numopts; i++)
1853 if (!strcmp(val, xqopts[i].opname))
1854 {xqopts[i].doset = 1;
1859 eDest->
Say(
"Config warning: ignoring invalid fsxeq type option '",val,
"'.");
1866 {
eDest->
Emsg(
"Config",
"fsxeq type option not specified");
return 1;}
1871 {
eDest->
Emsg(
"Config",
"fsxeq program not specified");
return 1;}
1879 for (i = 0; i < numopts; i++)
1880 if (xqopts[i].doset)
1881 {
if (!*xqopts[i].pgm) *(xqopts[i].pgm) =
new XrdOucProg(0);
1882 if ((*(xqopts[i].pgm))->Setup(val,
eDest))
return 1;
1911 if (!isManager)
return CFile.
noEcho();
1914 {
eDest->
Emsg(
"Config",
"fxhold value not specified.");
return 1;}
1916 if (!strcmp(val,
"noloc"))
1917 {
if (!(val = CFile.
GetWord()))
1918 {
eDest->
Emsg(
"Config",
"fxhold noloc value not specified.");
return 1;}
1922 if (!(val = CFile.
GetWord()))
return 0;
1953 if (!isServer)
return CFile.
noEcho();
1958 if (!val || !val[0])
1959 {
eDest->
Emsg(
"Config",
"localroot path not specified");
return 1;}
1961 {
eDest->
Emsg(
"Config",
"localroot path not absolute");
return 1;}
1966 while (i && val[i] ==
'/') val[i--] =
'\0';
2012 StorageHelper(
char **v1,
char **v2) : val1(v1), val2(v2) {}
2013 ~StorageHelper() {
if (*val1) free(*val1);
2014 if (*val2) free(*val2);
2016 char **val1, **val2;
2020 char *val, *hSpec = 0, *hPort = 0;
2021 StorageHelper SHelp(&hSpec, &hPort);
2022 int rc, xMeta = 0, xPeer = 0, xProxy = 0, *myPort = 0;
2027 {
if ((xMeta = !strcmp(
"meta", val))
2028 || (xPeer = !strcmp(
"peer", val))
2029 || (xProxy = !strcmp(
"proxy", val)))
2030 {
if ((xMeta && (isServer || isPeer))
2031 || (xPeer && !isPeer)
2032 || (xProxy && !isProxy))
return CFile.
noEcho();
2034 }
else if (isPeer)
return CFile.
noEcho();
2040 if (!strcmp(
"any", val) || !strcmp(
"all", val)) val = CFile.
GetWord();
2045 {
eDest->
Emsg(
"Config",
"manager host name not specified");
return 1;}
2046 hSpec = strdup(val);
2055 {
if (strcmp(val,
"if"))
2056 {
eDest->
Emsg(
"Config",
"expecting manager 'if' but",val,
"found");
2061 {
if (!rc) CFile.
noEcho();
return rc < 0;}
2066 if (isManager && !isServer)
2068 {
if (((xMeta && isMeta) || (!xMeta && !isMeta)))
2070 if (isMeta) theList = 0;
2099 char *val, xopt[16];
2101 bool xAll =
false, xOff =
false, xRmt =
false;
2106 {
if ((xAll = !strcmp(
"all", val))
2107 || (xOff = !strcmp(
"off", val))
2108 || (xRmt = !strcmp(
"remote", val)))
2109 {
if (xAll)
nbSQ = 2;
2110 else if (xRmt)
nbSQ = 1;
2114 }
else {
eDest->
Emsg(
"Config",
"nbsendq option not specified");
return 1;}
2119 {
size_t size =
sizeof(xopt)-1;
2120 strncpy(xopt, val, size);
2122 if (!(val= CFile.
GetWord()) || *val == 0)
2123 {
eDest->
Emsg(
"Config",
"nbsendq ", xopt,
" argument not specified");
2126 if (!strcmp(xopt,
"maxq"))
2127 {
if (!strcmp(
"val",
"none")) ival = -1;
2132 else if (!strcmp(xopt,
"warn"))
2136 else eDest->
Say(
"Config warning: ignoring invalid nbsendq option '",xopt,
"'.");
2163{
char *pgm=0, *val, rest[2048];
2165 if (!isServer)
return CFile.
noEcho();
2168 {
eDest->
Emsg(
"Config",
"perf options not specified");
return 1;}
2170 if (!strcmp(
"xrootd", val))
return CFile.
noEcho();
2173 do {
if (!strcmp(
"int", val))
2174 {
if (!(val = CFile.
GetWord()))
2175 {
eDest->
Emsg(
"Config",
"perf int value not specified");
2180 else if (!strcmp(
"lib", val))
2181 {
if (perfpgm) {free(perfpgm); perfpgm = 0;}
2186 else if (!strcmp(
"pgm", val))
2187 {
if (!CFile.
GetRest(rest,
sizeof(rest)))
2188 {
eDest->
Emsg(
"Config",
"perf pgm parameters too long");
2192 {
eDest->
Emsg(
"Config",
"perf pgm value not specified");
2198 else eDest->
Say(
"Config warning: ignoring invalid perf option '",val,
"'.");
2199 }
while((val = CFile.
GetWord()));
2203 if (perfpgm) {free(perfpgm); perfpgm = 0;}
2206 if (pgm) {
if (!isExec(
eDest,
"perf", pgm))
return 1;
2207 else perfpgm = strdup(pgm);
2241 {
eDest->
Emsg(
"Config",
"ping value not specified");
return 1;}
2243 if (ping < 3) ping = 3;
2245 while((val = CFile.
GetWord()))
2246 {
if (!strcmp(
"log", val))
2247 {
if (!(val = CFile.
GetWord()))
2248 {
eDest->
Emsg(
"Config",
"ping log value not specified");
2253 else if (!strcmp(
"usage", val))
2254 {
if (!(val = CFile.
GetWord()))
2255 {
eDest->
Emsg(
"Config",
"ping usage value not specified");
2291{
int reset=0, scrub=0, echo = 0, doset = 0;
2292 char *prepif=0, *val, rest[2048];
2294 if (!isServer)
return CFile.
noEcho();
2298 do {
if (!strcmp(
"echo", val)) doset = echo = 1;
2299 else if (!strcmp(
"reset", val))
2300 {
if (!(val = CFile.
GetWord()))
2301 {
eDest->
Emsg(
"Config",
"prep reset value not specified");
2307 else if (!strcmp(
"scrub", val))
2308 {
if (!(val = CFile.
GetWord()))
2309 {
eDest->
Emsg(
"Config",
"prep scrub value not specified");
2315 else if (!strcmp(
"ifpgm", val))
2316 {
if (!CFile.
GetRest(rest,
sizeof(rest)))
2317 {
eDest->
Emsg(
"Config",
"prep ifpgm parameters too long");
return 1;}
2319 {
eDest->
Emsg(
"Config",
"prep ifpgm value not specified");
2325 else eDest->
Say(
"Config warning: ignoring invalid prep option '",val,
"'.");
2326 }
while((val = CFile.
GetWord()));
2332 if (scrub) pendplife = scrub;
2334 if (prepif) {
if (!isExec(
eDest,
"prep", prepif))
return 1;
2357 char *val, buff[2048];
2363 {
eDest->
Emsg(
"Config",
"no value for prepmsg directive");
2372 if (!CFile.
GetRest(buff,
sizeof(buff)))
2373 {
eDest->
Emsg(
"Config",
"prepmsg arguments too long");
2400 static struct repsopts {
const char *opname;
int opval;} rsopts[] =
2406 int i, neg, rsval = 0, numopts =
sizeof(rsopts)/
sizeof(
struct repsopts);
2409 {
eDest->
Emsg(
"config",
"repstats option not specified");
return 1;}
2411 {
if (!strcmp(val,
"off")) rsval = 0;
2412 else {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
2413 for (i = 0; i < numopts; i++)
2414 {
if (!strcmp(val, rsopts[i].opname))
2415 {
if (neg) rsval &= ~rsopts[i].opval;
2416 else rsval |= rsopts[i].opval;
2421 eDest->
Say(
"Config warning: ignoring invalid repstats option '",val,
"'.");
2447 char *val, *colon, *slash;
2452 if (isManager)
return CFile.
noEcho();
2457 if (!val || !val[0])
2458 {
eDest->
Emsg(
"Config",
"remoteroot path not specified");
return 1;}
2463 {colon = index(val,
':'); slash = index(val,
'/');
2464 if ((colon+1) != slash)
2465 {
eDest->
Emsg(
"Config",
"remoteroot path not absolute");
return 1;}
2471 while (i && val[i] ==
'/') val[i--] =
'\0';
2534 char *val, *Tok1, *Tok2;
2535 int rc, xMeta=0, xPeer=0, xProxy=0, xServ=0, xMan=0, xSolo=0;
2539 if (!(val = CFile.
GetWord()) || !strcmp(val,
"if"))
2540 {
eDest->
Emsg(
"Config",
"role not specified");
return 1;}
2545 if ((val = CFile.
GetWord()) && strcmp(val,
"if"))
2546 {Tok2 = strdup(val);
2552 if (val && !strcmp(
"if", val))
2555 {free(Tok1);
if (Tok2) free(Tok2);
2577 default:
eDest->
Emsg(
"Config",
"invalid role -", Tok1, Tok2); rc = 1;
2583 if (Tok2) free(Tok2);
2588 if (isServer > 0 || isManager > 0 || isProxy > 0 || isPeer > 0)
2589 {
eDest->
Say(
"Config warning: role directive over-ridden by command line.");
2595 isServer = xServ; isManager = xMan; isProxy = xProxy;
2596 isPeer = xPeer; isSolo = xSolo; isMeta = xMeta;
2599 myRoleID =
static_cast<int>(roleID);
2637 int i, ppp, V_hntry = -1;
2638 static struct schedopts {
const char *opname;
int maxv;
int *oploc;}
2641 {
"cpu", 100, &
P_cpu},
2643 {
"gsdflt", 100, &
P_gsdf},
2647 {
"mem", 100, &
P_mem},
2648 {
"pag", 100, &
P_pag},
2649 {
"space", 100, &
P_dsk},
2652 {
"affinity", -2, 0},
2654 {
"tryhname", 1, &V_hntry}
2656 int numopts =
sizeof(scopts)/
sizeof(
struct schedopts);
2659 {
eDest->
Emsg(
"Config",
"sched option not specified");
return 1;}
2662 {
for (i = 0; i < numopts; i++)
2663 if (!strcmp(val, scopts[i].opname))
2664 {
if (!(val = CFile.
GetWord()))
2665 {
eDest->
Emsg(
"Config",
"sched ", scopts[i].opname,
2666 "argument not specified.");
2669 if (scopts[i].maxv == -2)
2670 {
if (!xschedm(val,
eDest, CFile))
return 1;
2673 if (scopts[i].maxv == -3)
2674 {
if (!xschedp(val,
eDest, CFile))
return 1;
2677 if (scopts[i].maxv < 0)
2682 0, scopts[i].maxv))
return 1;
2683 *scopts[i].oploc = ppp;
2687 {
int rc = xschedx(val,
eDest, CFile);
2688 if (rc < 0)
return 1;
2689 if (rc > 0)
eDest->
Say(
"Config warning: "
2690 "ignoring invalid sched option '",val,
"'.");
2697 if (V_hntry >= 0)
DoHnTry =
static_cast<char>(V_hntry);
2707 if (!strcmp(val,
"default"))
2710 {
eDest->
Emsg(
"Config",
"sched affinity not specified");
return 0;}
2713 if (!strcmp(val,
"none"))
2720 if (!strcmp(val,
"weak"))
return 1;
2724 if (!strcmp(val,
"strong"))
return 1;
2726 if (!strcmp(val,
"strict"))
2731 if (!strcmp(val,
"randomized"))
2736 eDest->
Emsg(
"Config",
"Invalid sched affinity -", val);
2744 int afpsign, afpval;
2746 if (!strcmp(val,
"all"))
2751 if (!strcmp(val,
"first")) afpsign = 1;
2752 else if (!strcmp(val,
"last")) afpsign = -1;
2753 else {
eDest->
Emsg(
"Config",
"sched affpath option invalid -", val);
2758 {
eDest->
Emsg(
"Config",
"sched affpath argument not specified");
return 0;}
2774 if (!strcmp(val,
"maxretries"))
2775 {
if (!(val = CFile.
GetWord()))
2776 {
eDest->
Emsg(
"Config",
"sched ",
"maxretries argument not specified.");
2786 if (!strcmp(val,
"nomultisrc"))
2798 if (!strncmp(val,
"nomultisrc@", 11))
2810 int &hlen,
int &port)
2812 const char *badTarget =
"Invalid sched redirect target '%s'%s";
2815 const char *eText =
"not a redirect target";
2819 if (host) {free(host); host = 0; hlen = port = 0;}
2823 if (!(at = index(val,
'@')))
return true;
2825 {snprintf(hName,
sizeof(hName),
2826 "Missing sched redirect target after '%s'.", val);
2830 *at = 0; val = at + 1;
2835 {snprintf(hName,
sizeof(hName), badTarget, val,
".");
2842 if ((eText = netAddr.
Set(val)))
2843 {snprintf(hName,
sizeof(hName), badTarget, val,
";");
2852 {snprintf(hName,
sizeof(hName), badTarget, val,
".");
2859 host = strdup(hName);
2860 hlen = strlen(hName)+1;
2861 port = netAddr.
Port();
2885 if (!isManager)
return CFile.
noEcho();
2935 int i, alinger = -1, arecalc = -1, minfP = -1, hwmP = -1;
2936 long long minf = -1, hwm = -1;
2937 bool haveopt =
false;
2939 while((val = CFile.
GetWord()))
2940 {
if (!strcmp(
"linger", val))
2941 {
if (!(val = CFile.
GetWord()))
2942 {
eDest->
Emsg(
"Config",
"linger value not specified");
return 1;}
2945 else if (!strcmp(
"recalc", val))
2946 {
if (!(val = CFile.
GetWord()))
2947 {
eDest->
Emsg(
"Config",
"recalc value not specified");
return 1;}
2950 else if (!strcmp(
"min", val))
2951 {
if (!(val = CFile.
GetWord()) || !isdigit(*val))
2952 {
eDest->
Emsg(
"Config",
"space min value not specified");
return 1;}
2955 else if (!strcmp(
"mwfiles", val)) {
DoMWChk = 0; haveopt =
true;}
2956 else if (isdigit(*val))
break;
2957 else {
eDest->
Emsg(
"Config",
"invalid space parameters");
return 1;}
2960 if (val && isdigit(*val))
2962 if (val[i-1] ==
'%')
2969 if (val && isdigit(*val))
2971 if (val[i-1] !=
'%')
2977 if (minfP >= 0 && minf < 0)
2978 {
eDest->
Emsg(
"Config",
"absolute min value not specified");
return 1;}
2980 if (val && isdigit(*val))
2982 if (val[i-1] ==
'%')
2989 if (val && isdigit(*val))
2991 if (val[i-1] !=
'%')
2997 if (hwmP >= 0 && hwm < 0)
2998 {
eDest->
Emsg(
"Config",
"absolute high watermark value not specified");
return 1;}
3000 if (val) {
eDest->
Emsg(
"Config",
"invalid space parameter -", val);
return 1;}
3002 if (!haveopt && alinger < 0 && arecalc < 0 && minf < 0)
3003 {
eDest->
Emsg(
"Config",
"no space values specified");
return 1;}
3006 if (arecalc >= 0)
DiskAsk = arecalc;
3009 {
if (hwmP < minfP) hwmP = minfP + 1;
3014 {
if (hwm < minf) hwm = minf+1073741824;
3015 minf = minf >> 20LL; hwm = hwm >> 20LL;
3016 if (minf >> 31LL) {minf = 0x7fefffff; hwm = 0x7fffffff;}
3017 else if (hwm >> 31LL) minf = 0x7fffffff;
3018 DiskMin =
static_cast<int>(minf);
3019 DiskHWM =
static_cast<int>(hwm);
3041 StorageHelper(
char **v1,
char **v2) : val1(v1), val2(v2) {}
3042 ~StorageHelper() {
if (*val1) free(*val1);
3043 if (*val2) free(*val2);
3045 char **val1, **val2;
3048 char *val, *hSpec = 0, *hPort = 0;
3049 StorageHelper SHelp(&hSpec, &hPort);
3053 if (isMeta || isServer || isPeer || isProxy)
return CFile.
noEcho();
3058 if (val && !strcmp(
"of", val)) val = CFile.
GetWord();
3063 {
eDest->
Emsg(
"Config",
"cluster manager host name not specified");
3066 hSpec = strdup(val);
3093{
const char *invp =
"superport port";
3094 char *val, cport[32];
3098 {
eDest->
Emsg(
"Config",
"tcp port not specified");
return 1;}
3100 strncpy(cport, val,
sizeof(cport)-1); cport[
sizeof(cport)-1] =
'\0';
3102 if ((val = CFile.
GetWord()) && !strcmp(
"if", val))
3105 {
if (!rc) CFile.
noEcho();
return rc < 0;}
3107 if (!strcmp(cport,
"any")) pnum = 0;
3108 else if (!strcmp(cport,
"-p")) pnum =
PortTCP;
3109 else if (isdigit(*cport))
3112 {
eDest->
Emsg(
"Config",
"Unable to find superport", cport);
3137 static struct traceopts {
const char *opname;
int opval;} tropts[] =
3148 int i, neg, trval = 0, numopts =
sizeof(tropts)/
sizeof(
struct traceopts);
3151 {
eDest->
Emsg(
"config",
"trace option not specified");
return 1;}
3153 {
if (!strcmp(val,
"off")) trval = 0;
3154 else {
if ((neg = (val[0] ==
'-' && val[1]))) val++;
3155 for (i = 0; i < numopts; i++)
3156 {
if (!strcmp(val, tropts[i].opname))
3157 {
if (neg) trval &= ~tropts[i].opval;
3158 else trval |= tropts[i].opval;
3163 eDest->
Say(
"Config warning: ignoring invalid trace option '",val,
"'.");
3190 char *val, parms[1024];
3194 if (!(val = CFile.
GetWord()) || !val[0])
3195 {
eDest->
Emsg(
"Config",
"vnid not specified");
return 1;}
3206 {
if (!CFile.
GetRest(parms,
sizeof(parms)))
3207 {
eDest->
Emsg(
"Config",
"vnid plug-in parameters too long");
return 1;}
void * XrdCmsStartMonPerf(void *carg)
void * XrdCmsStartMonRefs(void *carg)
void * XrdCmsStartSupervising(void *carg)
void * XrdCmsStartAnote(void *carg)
void * XrdCmsStartPreparing(void *carg)
void * XrdCmsStartMonStat(void *carg)
void * XrdCmsStartAdmin(void *carg)
#define XrdCmsMAX_PATH_LEN
static XrdSysError eDest(0,"crypto_")
XrdOss * XrdOssGetSS(XrdSysLogger *Logger, const char *config_fn, const char *OssLib, const char *OssParms, XrdOucEnv *envP, XrdVersionInfo &urVer)
static bool InitAREvents(void *arFunc)
void * Start(XrdNetSocket *AdminSock)
static void setSync(XrdSysSemaphore *sync)
void * Notes(XrdNetSocket *AdminSock)
void SetTries(bool xdfs, int tcnt)
void Init(int Opts, int DMlife, int DPLife)
static void Init(XrdScheduler *sP, XrdCmsCluster *cP, const char *blfn, int chkt=600)
int Init(int fxHold, int fxDelay, int fxQuery, int seFS, int nxHold)
static const int min_nxTime
static const int RepStat_shr
static const int RepStat_frq
int GenLocalPath(const char *oldp, char *newp)
XrdCmsPList_Anchor PathList
static const int RepStat_All
unsigned long long DirFlags
XrdOucPListAnchor PexpList
int Configure1(int argc, char **argv, char *cfn)
int ConfigXeq(char *var, XrdOucStream &CFile, XrdSysError *eDest)
XrdOucName2Name * xeq_N2N
XrdOucName2Name * lcl_N2N
int Configure0(XrdProtocol_Config *pi)
static bool Start(const XrdOucTList *mL)
int Monitor(char *pgm, int itv)
void setVirtual(vType vVal)
static void do_StateDFS(XrdCmsBaseFR *rP, int rc)
int Add(const char *pname, XrdCmsPInfo *pinfo)
int setParms(int rcnt, int stime, int deco=0)
void Reset(const char *iName, const char *aPath, int aMode)
int Init(int Tint=0, int Tdly=0)
static const char * Name(RoleID rid)
static const char * Type(RoleID rid)
static RoleID Convert(const char *Tok1, const char *Tok2)
static char * getVnId(XrdSysError &eDest, const char *cfgFN, const char *nidlib, const char *nidparm, char nidType)
static char * setSystemID(XrdOucTList *tp, const char *iVNID, const char *iTag, char iType)
static int Configure(const char *Lib, const char *Cfn=0)
void Update(StateType StateT, int ActivVal, int StageVal=0)
static int Init(const char *AdminPath, int AdminMode)
static char * ParseManPort(XrdSysError *eDest, XrdOucStream &CFile, char *hSpec)
static bool ParseMan(XrdSysError *eDest, XrdOucTList **oldMans, char *hSpec, char *hPort, int *sPort=0, bool hush=false)
static const int noPort
Do not add port number.
int Format(char *bAddr, int bLen, fmtUse fmtType=fmtAuto, int fmtOpts=0)
@ fmtAuto
Hostname if already resolved o/w use fmtAddr.
const char * Set(const char *hSpec, int pNum=PortInSpec)
void AddHost(char *hname)
void AddNetGroup(char *hname)
static XrdNetSocket * Create(XrdSysError *Say, const char *path, const char *fn, mode_t mode, int isudp=0)
static int ServPort(const char *sName, bool isUDP=false, const char **eText=0)
char * Get(const char *varname)
static int Export(const char *Var, const char *Val)
void * GetPtr(const char *varname)
void PutPtr(const char *varname, void *value)
static unsigned long long ParseDefs(XrdOucStream &Config, XrdSysError &Eroute, unsigned long long Flags)
static XrdOucPList * ParsePath(XrdOucStream &Config, XrdSysError &Eroute, XrdOucPListAnchor &Export, unsigned long long Defopts)
virtual int lfn2pfn(const char *lfn, char *buff, int blen)=0
unsigned long long Flag()
XrdOucEnv * SetEnv(XrdOucEnv *newEnv)
char * GetWord(int lowcase=0)
int GetRest(char *theBuf, int Blen, int lowcase=0)
static char * genPath(const char *path, const char *inst, const char *psfx=0)
static bool parseLib(XrdSysError &eDest, XrdOucStream &Config, const char *libName, char *&path, char **libparm)
static const char * InstName(int TranOpt=0)
static int doIf(XrdSysError *eDest, XrdOucStream &Config, const char *what, const char *hname, const char *nname, const char *pname)
static int a2i(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
static int a2sz(XrdSysError &, const char *emsg, const char *item, long long *val, long long minv=-1, long long maxv=-1)
static int a2tm(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
void Schedule(XrdJob *jp)
static void SetQW(unsigned int qwVal)
static void SetQM(unsigned int qmVal)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
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)
XrdSysLogger * logger(XrdSysLogger *lp=0)
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)
static void Wait(int milliseconds)
void SetLogger(XrdSysLogger *logp)
XrdVERSIONINFODEF(myVersion, cmsclient, XrdVNUMBER, XrdVERSION)
Generic structure to pass security information back and forth.