Logo ROOT   6.12/07
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 //
35 private:
36  XrdOucString fName; // Name of the member
37  int fActive; // Number of member's active sessions
38 
39 public:
40  XrdProofGroupMember(const char *n) : fName(n) { fActive = 0; }
41  virtual ~XrdProofGroupMember() { }
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 
49 friend class XrdProofGroupMgr;
50 private:
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 
68 public:
69  ~XrdProofGroup();
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; }
82  void SetFraction(int f) { XrdSysMutexHelper mhp(fMutex); fFraction = 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 //
94 private:
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 
104 public:
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:"; }
126  XrdProofGroup *Next();
127 };
128 
129 // Auc structures for scan through operations
130 typedef struct {
131  float prmax;
132  float prmin;
133  int nofrac;
134  float totfrac;
136 
137 typedef struct {
138  int opt;
140  float cut;
141  float norm;
142 } XpdGroupEff_t;
143 
144 #endif
const char * Name() const
Definition: XrdProofGroup.h:75
XrdOucString fName
Definition: XrdProofdAux.h:76
auto * m
Definition: textangle.C:8
void AddMember(const char *usr)
Definition: XrdProofGroup.h:64
XrdOucHash< XrdProofGroup > fGroups
Definition: XrdProofGroup.h:96
#define XrdSysRecMutex
Definition: XrdSysToOuc.h:18
int Active() const
Definition: XrdProofGroup.h:43
XpdGroupGlobal_t * glo
virtual ~XrdProofGroupMember()
Definition: XrdProofGroup.h:41
void SetPriority(float p)
Definition: XrdProofGroup.h:83
const char * GetCfgFile() const
XrdOucHash< XrdProofGroupMember > fActives
Definition: XrdProofGroup.h:55
XrdSysRecMutex * fMutex
Definition: XrdProofGroup.h:62
XrdProofGroupMember(const char *n)
Definition: XrdProofGroup.h:40
XrdOucString fIterator
Definition: XrdProofGroup.h:95
int Fraction() const
Definition: XrdProofGroup.h:78
XrdProofdFile fPriorityFile
XrdOucString fName
Definition: XrdProofGroup.h:36
const char * Members() const
Definition: XrdProofGroup.h:74
XrdOucString fName
Definition: XrdProofGroup.h:51
void SetFraction(int f)
Definition: XrdProofGroup.h:82
float Priority() const
Definition: XrdProofGroup.h:80
#define XrdSysMutexHelper
Definition: XrdSysToOuc.h:17
XrdProofdFile fCfgFile
Definition: XrdProofGroup.h:99
XrdSysRecMutex fMutex
Definition: XrdProofGroup.h:97
int Size() const
Definition: XrdProofGroup.h:76
void SetFracEff(float f)
Definition: XrdProofGroup.h:81
void Print(std::ostream &os, const OptionType &opt)
float FracEff() const
Definition: XrdProofGroup.h:79
XrdOucString fMembers
Definition: XrdProofGroup.h:53
const char * Name() const
Definition: XrdProofGroup.h:45
const Int_t n
Definition: legend1.C:16