ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
78 
79  int Config(bool rcf = 0);
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
int RemoveSession(int pid)
Remove from the active list the session with ID pid.
const double pi
int SetNiceValues(int opt=0)
Recalculate nice values taking into account all active users and their priorities.
XrdProofdPriorityMgr(XrdProofdManager *mgr, XrdProtocol_Config *pi, XrdSysError *e)
Constructor.
#define XrdSysRecMutex
Definition: XrdSysToOuc.h:18
void SetGroupPriority(const char *grp, int priority)
Change group priority. Used when a master pushes a priority to a worker.
int DoDirectiveSchedOpt(char *, XrdOucStream *, bool)
Process 'schedopt' directive.
XrdOucHash< XrdProofdPriority > fPriorities
#define XPPM_NOPRIORITY
XrdProofdManager * fMgr
int d
Definition: tornado.py:11
int SetProcessPriority(int pid, const char *usr, int &dp)
Change priority of process pid belonging to user, if needed.
int DoDirectivePriority(char *, XrdOucStream *, bool)
Process 'priority' directive.
int DoDirective(XrdProofdDirective *d, char *val, XrdOucStream *cfg, bool rcf)
Update the priorities of the active sessions.
XrdProofdPipe * Pipe()
#define XrdSysMutexHelper
Definition: XrdSysToOuc.h:17
#define XrdSysError
Definition: XpdSysError.h:8
int AddSession(const char *u, const char *g, int pid)
Add to the active list a session with ID pid.
XrdProofdSessionEntry(const char *u, const char *g, int pid)
Constructor.
int SetPriority(int priority=XPPM_NOPRIORITY)
Change process priority.
int Config(bool rcf=0)
Run configuration and parse the entered config directives.
XrdOucHash< XrdProofdSessionEntry > fSessions
virtual ~XrdProofdSessionEntry()
Destructor.
void RegisterDirectives()
Register directives for configuration.