33 const char *usr = (
const char *)u;
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)
177 if (!usr || !usr[0]) {
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)
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")
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;
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)
620 if (eff && eff->
glo) {
626 }
else if (eff->
opt == 1) {
631 }
else if (eff->
opt == 2) {
680 }
else if (glo.
totfrac > 100) {
static int AuxFunc(const char *, XrdProofGroup *g, void *s)
Generic function used for auxiliary purpose.
void AddMember(const char *usr)
XrdOucHash< XrdProofGroup > fGroups
XrdProofGroupMgr(const char *fn=0)
Constructor.
int ParseInfoFrom(const char *fn)
Parse config information from the open file 'fin'.
XrdProofGroup(const char *n, const char *m=0)
Constructor.
#define TRACE(Flag, Args)
int SetEffectiveFractions(bool optprio)
Go through the list of active groups (those having at least a non-idle member) and determine the effe...
void SetPriority(float p)
XrdOucHash< XrdProofGroupMember > fActives
XrdProofGroup * GetGroup(const char *grp)
Returns the instance of for group 'grp.
void Print()
Dump group content.
bool HasMember(const char *usr)
Check if 'usr' is member of this group.
int ReadPriorities()
Read update priorities from the file defined at configuration time.
static int ExportGroup(const char *, XrdProofGroup *g, void *u)
Add a string describing group 'g' to a global string.
XrdProofdFile fPriorityFile
#define XrdSysMutexHelper
void Count(const char *usr, int n=1)
Modify the active count.
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 ...
int Active(const char *usr=0)
Return the number of active groups (usr = 0) or the number of active sessions for user 'usr'...
static int PrintGroup(const char *, XrdProofGroup *g, void *)
Print info describing group 'g' to stdout.
XrdProofGroup * Next()
Returns the instance of next group in the pseudo-iterator functionality.
~XrdProofGroup()
Destructor.
static char * Expand(char *p)
Expand path 'p' relative to: $HOME if begins with ~/ <user>'s $HOME if begins with ~<user>/ $PWD if d...
XrdOucString Export(const char *grp)
Return a string describing the group.
const char * Name() const
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.
int Config(const char *fn)
(Re-)configure the group info using the file 'fn'.
const char * Members() const
void Print(const char *grp)
Return a string describing the group.
static int CheckUser(const char *, XrdProofGroup *g, void *u)
Check if user 'u' is memmebr of group 'grp'.
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...