33 const char *usr = (
const char *)u;
35 if (
g && usr &&
g->HasMember(usr))
48 XrdOucString *msg = (XrdOucString *)u;
50 if (msg->length() > 0)
53 *msg =
g->Name(); *msg +=
": ";
56 *msg +=
", members(s): ";
78 XrdOucString *opt = (XrdOucString *)
s;
80 if (!opt || opt->length() <= 0 || (*opt) ==
"getfirst")
84 if (opt->beginswith(
"getnextgrp:")) {
85 XrdOucString grp(
"||");
86 grp.insert(
g->Name(),1);
87 if (opt->find(grp) == STR_NPOS) {
101 : fName(
n), fMembers(
m)
124 XPDLOC(GMGR,
"Group::Print")
128 if (
fName !=
"default") {
145 if (!usr || !usr[0] ||
n == 0)
161 if (
m->Active() <= 0) {
177 if (!usr || !usr[0]) {
181 if (
m) na =
m->Active();
193 XrdOucString u(usr); u +=
",";
196 if (iu == 0 ||
fMembers[iu-1] ==
',')
267 if (grp && strlen(grp) > 0) {
286 if (!usr || strlen(usr) <= 0)
292 if (grp && strlen(grp) > 0) {
294 if (
g && (!strncmp(
g->Name(),
"default",7) ||
g->HasMember(usr)))
304 return ((!
g) ?
fGroups.Find(
"default") :
g);
327 XPDLOC(GMGR,
"GroupMgr::Config")
329 if ((!fn || strlen(fn) <= 0)) {
356 TRACE(DBG,
"enter: time of last modification: " << st.st_mtime);
393 XPDLOC(GMGR,
"GroupMgr::ParseInfoFrom")
396 if (!fn || strlen(fn) <= 0) {
397 TRACE(XERR,
"file name undefined!");
403 if (!(fin = fopen(fn,
"r"))) {
404 TRACE(XERR,
"cannot open file: "<<fn<<
" (errno:"<<errno<<
")");
410 while (fgets(lin,
sizeof(lin),fin)) {
412 if (lin[strlen(lin)-1] ==
'\n') lin[strlen(lin)-1] =
'\0';
414 if (lin[0] ==
'#' || strlen(lin) <= 0)
continue;
416 bool gotkey = 0, gotgrp = 0;
417 XrdOucString gl(lin), tok, key,
group;
420 while ((from = gl.tokenize(tok, from,
',')) != -1) {
421 if (tok.length() > 0) {
425 }
else if (!gotgrp) {
433 if (!gotkey || !gotgrp) {
435 TRACE(DBG,
"incomplete line: " << lin);
439 if (key ==
"include") {
441 XrdOucString subfn =
group;
446 TRACE(XERR,
"problems parsing included file "<<subfn);
451 if (key ==
"priorityfile") {
463 if (key ==
"group") {
467 while ((from = gl.tokenize(tok, from,
',')) != -1) {
468 if (tok.length() > 0)
470 g->AddMember(tok.c_str());
472 }
else if (key ==
"property") {
477 bool gotname = 0, gotnom = 0;
478 while ((from = gl.tokenize(tok, from,
',')) != -1) {
479 if (tok.length() > 0) {
483 }
else if (!gotnom) {
484 nom = atoi(tok.c_str());
490 if (!gotname || !gotnom) {
492 TRACE(DBG,
"incomplete property line: " << lin);
498 if (
name ==
"priority")
499 g->SetPriority((
float)nom);
500 if (
name ==
"fraction")
517 XPDLOC(GMGR,
"GroupMgr::ReadPriorities")
523 TRACE(DBG,
"time of last modification: " << st.st_mtime);
527 TRACE(DBG,
"file unchanged since last reading - do nothing ");
546 while (fgets(lin,
sizeof(lin),fin)) {
548 if (lin[strlen(lin)-1] ==
'\n') lin[strlen(lin)-1] =
'\0';
550 if (lin[0] ==
'#' || strlen(lin) <= 0)
continue;
552 XrdOucString gl(lin),
group, value;
555 if ((from = gl.tokenize(
group, 0,
'=')) == -1)
560 TRACE(XERR,
"found info for unknown group: "<<
group<<
" - ignoring");
563 gl.tokenize(value, from,
'=');
564 if (value.length() <= 0) {
565 TRACE(XERR,
"value missing: read line is: '"<<gl<<
"'");
569 if (value.find(
'.') == STR_NPOS)
572 g->SetPriority((
float)strtod(value.c_str(),0));
590 if (
g->Active() > 0) {
592 if (glo->
prmin == -1 ||
g->Priority() < glo->
prmin)
593 glo->
prmin =
g->Priority();
594 if (glo->
prmax == -1 ||
g->Priority() > glo->
prmax)
595 glo->
prmax =
g->Priority();
597 if (
g->Fraction() > 0) {
598 g->SetFracEff((
float)(
g->Fraction()));
599 glo->
totfrac += (float)(
g->Fraction());
620 if (eff && eff->
glo) {
622 if (
g->Active() > 0) {
624 float ef =
g->Priority() / glo->
prmin;
626 }
else if (eff->
opt == 1) {
627 if (
g->Fraction() < 0) {
631 }
else if (eff->
opt == 2) {
632 if (
g->FracEff() < 0) {
638 float ef =
g->FracEff() * eff->
norm;
680 }
else if (glo.
totfrac > 100) {
#define TRACE(Flag, Args)
static int CheckUser(const char *, XrdProofGroup *g, void *u)
Check if user 'u' is memmebr of group 'grp'.
static int AuxFunc(const char *, XrdProofGroup *g, void *s)
Generic function used for auxiliary purpose.
static int SetGroupFracEff(const char *, XrdProofGroup *g, void *s)
Check if user 'u' is memmebr of group 'grp'.
static int GetGroupsInfo(const char *, XrdProofGroup *g, void *s)
Fill the global group structure.
static int PrintGroup(const char *, XrdProofGroup *g, void *)
Print info describing group 'g' to stdout.
static int ExportGroup(const char *, XrdProofGroup *g, void *u)
Add a string describing group 'g' to a global string.
#define XrdSysMutexHelper
XrdProofGroupMgr(const char *fn=0)
Constructor.
XrdProofGroup * Next()
Returns the instance of next group in the pseudo-iterator functionality.
XrdProofGroup * Apply(int(*f)(const char *, XrdProofGroup *, void *), void *arg)
Apply function 'f' to the hash table of groups; 'arg' is passed to 'f' in the last argument.
XrdOucHash< XrdProofGroup > fGroups
void Print(const char *grp)
Return a string describing the group.
int Config(const char *fn)
(Re-)configure the group info using the file 'fn'.
XrdProofGroup * GetGroup(const char *grp)
Returns the instance of for group 'grp.
int ParseInfoFrom(const char *fn)
Parse config information from the open file 'fin'.
XrdOucString Export(const char *grp)
Return a string describing the group.
int SetEffectiveFractions(bool optprio)
Go through the list of active groups (those having at least a non-idle member) and determine the effe...
int ReadPriorities()
Read update priorities from the file defined at configuration time.
XrdProofGroup * GetUserGroup(const char *usr, const char *grp=0)
Returns the instance of the first group to which this user belongs; if grp != 0, return the instance ...
XrdProofdFile fPriorityFile
~XrdProofGroup()
Destructor.
int Active(const char *usr=0)
Return the number of active groups (usr = 0) or the number of active sessions for user 'usr'.
bool HasMember(const char *usr)
Check if 'usr' is member of this group.
void Count(const char *usr, int n=1)
Modify the active count.
XrdProofGroup(const char *n, const char *m=0)
Constructor.
XrdOucHash< XrdProofGroupMember > fActives
void Print()
Dump group content.
static char * Expand(char *p)
Expand path 'p' relative to: $HOME if begins with ~/ <user>'s $HOME if begins with ~<user>/ $PWD if d...
static constexpr double s