Logo ROOT   6.12/07
Reference Guide
XrdProofdPriorityMgr.h
Go to the documentation of this file.
1 // @(#)root/proofd:$Id$
2 // Author: G. Ganis Feb 2008
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_XrdProofdPriorityMgr
13 #define ROOT_XrdProofdPriorityMgr
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // XrdProofdPriorityMgr //
18 // //
19 // Author: G. Ganis, CERN, 2007 //
20 // //
21 // Class managing session priorities. //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 #include <list>
25 
26 #include "XpdSysPthread.h"
27 
28 #include "XrdOuc/XrdOucHash.hh"
29 #include "XrdOuc/XrdOucString.hh"
30 
31 #include "XrdProofdConfig.h"
32 
33 class XrdProofdDirective;
34 class XrdProofdManager;
35 
36 //
37 // Small class to describe an active session
38 //
39 #define XPPM_NOPRIORITY 999999
41 public:
42  XrdOucString fUser;
43  XrdOucString fGroup;
44  int fPid;
46  int fPriority;
47  float fFracEff; // Resource fraction in % (effective)
48 
49  XrdProofdSessionEntry(const char *u, const char *g, int pid);
50  virtual ~XrdProofdSessionEntry();
51 
52  int SetPriority(int priority = XPPM_NOPRIORITY);
53 };
54 
56 
57  XrdSysRecMutex fMutex; // Atomize this instance
58 
60  XrdOucHash<XrdProofdSessionEntry> fSessions; // list of active sessions (keyed by "pid")
61  XrdOucHash<XrdProofdPriority> fPriorities; // list of {users, priority change}
62 
64 
65  int fSchedOpt; // Worker sched option
66  int fPriorityMax; // Max session priority [1,40], [20]
67  int fPriorityMin; // Min session priority [1,40], [1]
68 
69  void RegisterDirectives();
70  int DoDirectivePriority(char *, XrdOucStream *, bool);
71  int DoDirectiveSchedOpt(char *, XrdOucStream *, bool);
72 
73 public:
74  XrdProofdPriorityMgr(XrdProofdManager *mgr, XrdProtocol_Config *pi, XrdSysError *e);
75  virtual ~XrdProofdPriorityMgr() { }
76 
77  enum PMProtocol { kChangeStatus = 0, kSetGroupPriority = 1 };
78 
79  int Config(bool rcf = 0);
80  int DoDirective(XrdProofdDirective *d,
81  char *val, XrdOucStream *cfg, bool rcf);
82 
83  inline XrdProofdPipe *Pipe() { return &fPipe; }
84 
85  int AddSession(const char *u, const char *g, int pid);
86  int RemoveSession(int pid);
87  void SetGroupPriority(const char *grp, int priority);
88 
89  // Scheduling
90  bool IsSchedOn() { return ((fSchedOpt != kXPD_sched_off) ? 1 : 0); }
91  int SetNiceValues(int opt = 0);
92  void SetSchedOpt(int opt) { XrdSysMutexHelper mhp(&fMutex);
93  fSchedOpt = opt; }
94  int SetProcessPriority(int pid, const char *usr, int &dp);
95 };
96 
97 #endif
static constexpr double pi
#define XrdSysRecMutex
Definition: XrdSysToOuc.h:18
XrdOucHash< XrdProofdPriority > fPriorities
#define XPPM_NOPRIORITY
XrdProofdManager * fMgr
XrdProofdPipe * Pipe()
#define XrdSysMutexHelper
Definition: XrdSysToOuc.h:17
#define XrdSysError
Definition: XpdSysError.h:8
XrdProofdSessionEntry(const char *u, const char *g, int pid)
Constructor.
int SetPriority(int priority=XPPM_NOPRIORITY)
Change process priority.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
XrdOucHash< XrdProofdSessionEntry > fSessions
virtual ~XrdProofdSessionEntry()
Destructor.
static constexpr double g