Logo ROOT   6.18/05
Reference Guide
XrdProofGroup.h
Go to the documentation of this file.
1// @(#)root/proofd:$Id$
2// Author: Gerardo Ganis June 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_XrdProofGroup
13#define ROOT_XrdProofGroup
14
15//////////////////////////////////////////////////////////////////////////
16// //
17// XrdProofGroup //
18// //
19// Authors: G. Ganis, CERN, 2007 //
20// //
21// Class describing groups //
22// //
23//////////////////////////////////////////////////////////////////////////
24
25#include "XpdSysPthread.h"
26
27#include "XrdOuc/XrdOucHash.hh"
28#include "XrdOuc/XrdOucString.hh"
29#include "XrdProofdAux.h"
30
31//
32// Group Member class
33//
35private:
36 XrdOucString fName; // Name of the member
37 int fActive; // Number of member's active sessions
38
39public:
40 XrdProofGroupMember(const char *n) : fName(n) { fActive = 0; }
42
43 int Active() const { return fActive; }
44 void Count(int n) { fActive += n; }
45 const char *Name() const { return fName.c_str(); }
46};
47
49friend class XrdProofGroupMgr;
50private:
51 XrdOucString fName; // group name
52
53 XrdOucString fMembers; // comma-separated list of members
54 int fSize; // Number of members
55 XrdOucHash<XrdProofGroupMember> fActives; // Keeps track of members having active sessions
56
57 // Properties
58 float fPriority; // Arbitrary number indicating the priority of this group
59 int fFraction; // Resource fraction in % (nominal)
60 float fFracEff; // Resource fraction in % (effective)
61
62 XrdSysRecMutex *fMutex; // Local mutex
63
64 void AddMember(const char *usr) { XrdSysMutexHelper mhp(fMutex);
65 fMembers += usr; fMembers += ","; fSize++; }
66 XrdProofGroup(const char *n, const char *m = 0);
67
68public:
70
71 int Active(const char *usr = 0);
72 bool HasMember(const char *usr);
73
74 inline const char *Members() const { XrdSysMutexHelper mhp(fMutex); return fMembers.c_str(); }
75 inline const char *Name() const { XrdSysMutexHelper mhp(fMutex); return fName.c_str(); }
76 inline int Size() const { XrdSysMutexHelper mhp(fMutex); return fSize; }
77
78 inline int Fraction() const { XrdSysMutexHelper mhp(fMutex); return fFraction; }
79 inline float FracEff() const { XrdSysMutexHelper mhp(fMutex); return fFracEff; }
80 inline float Priority() const { XrdSysMutexHelper mhp(fMutex); return fPriority; }
81 void SetFracEff(float f) { XrdSysMutexHelper mhp(fMutex); fFracEff = f; }
83 void SetPriority(float p) { XrdSysMutexHelper mhp(fMutex); fPriority = p; }
84
85 void Count(const char *usr, int n = 1);
86 void Print();
87};
88
89
90//
91// Group Manager class
92//
94private:
95 XrdOucString fIterator; // Keeps track of groups already processed
96 XrdOucHash<XrdProofGroup> fGroups; // Keeps track of groups managed by this instance
97 XrdSysRecMutex fMutex; // Mutex to protect access to fGroups
98
99 XrdProofdFile fCfgFile; // Last used group configuration file
100 XrdProofdFile fPriorityFile; // Last used file with priorities
101
102 int ParseInfoFrom(const char *fn);
103
104public:
105 XrdProofGroupMgr(const char *fn = 0);
107
108 int Config(const char *fn);
109
110 int ReadPriorities();
111 int SetEffectiveFractions(bool optprio);
112
113 XrdProofGroup *Apply(int (*f)(const char *, XrdProofGroup *, void *), void *arg);
114
115 XrdOucString Export(const char *grp);
116 int Num() { return fGroups.Num(); }
117 void Print(const char *grp);
118
119 XrdProofGroup *GetGroup(const char *grp);
120 XrdProofGroup *GetUserGroup(const char *usr, const char *grp = 0);
121
122 const char *GetCfgFile() const { return fCfgFile.fName.c_str(); }
123
124 // Pseudo-iterator functionality
125 void ResetIter() { fIterator = "getnextgrp:"; }
127};
128
129// Auc structures for scan through operations
130typedef struct {
131 float prmax;
132 float prmin;
134 float totfrac;
136
137typedef struct {
138 int opt;
140 float cut;
141 float norm;
143
144#endif
#define f(i)
Definition: RSha256.hxx:104
#define XrdSysMutexHelper
Definition: XrdSysToOuc.h:17
#define XrdSysRecMutex
Definition: XrdSysToOuc.h:18
XrdProofGroupMember(const char *n)
Definition: XrdProofGroup.h:40
XrdOucString fName
Definition: XrdProofGroup.h:36
virtual ~XrdProofGroupMember()
Definition: XrdProofGroup.h:41
int Active() const
Definition: XrdProofGroup.h:43
const char * Name() const
Definition: XrdProofGroup.h:45
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.
XrdOucString fIterator
Definition: XrdProofGroup.h:95
XrdOucHash< XrdProofGroup > fGroups
Definition: XrdProofGroup.h:96
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.
XrdProofdFile fCfgFile
Definition: XrdProofGroup.h:99
int SetEffectiveFractions(bool optprio)
Go through the list of active groups (those having at least a non-idle member) and determine the effe...
XrdSysRecMutex fMutex
Definition: XrdProofGroup.h:97
int ReadPriorities()
Read update priorities from the file defined at configuration time.
const char * GetCfgFile() const
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
const char * Members() const
Definition: XrdProofGroup.h:74
int Size() const
Definition: XrdProofGroup.h:76
int Fraction() const
Definition: XrdProofGroup.h:78
float FracEff() const
Definition: XrdProofGroup.h:79
~XrdProofGroup()
Destructor.
void SetFraction(int f)
Definition: XrdProofGroup.h:82
XrdOucString fMembers
Definition: XrdProofGroup.h:53
const char * Name() const
Definition: XrdProofGroup.h:75
void AddMember(const char *usr)
Definition: XrdProofGroup.h:64
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.
XrdOucString fName
Definition: XrdProofGroup.h:51
XrdProofGroup(const char *n, const char *m=0)
Constructor.
void SetFracEff(float f)
Definition: XrdProofGroup.h:81
float Priority() const
Definition: XrdProofGroup.h:80
XrdOucHash< XrdProofGroupMember > fActives
Definition: XrdProofGroup.h:55
XrdSysRecMutex * fMutex
Definition: XrdProofGroup.h:62
void Print()
Dump group content.
void SetPriority(float p)
Definition: XrdProofGroup.h:83
XrdOucString fName
Definition: XrdProofdAux.h:73
const Int_t n
Definition: legend1.C:16
XpdGroupGlobal_t * glo
auto * m
Definition: textangle.C:8