Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
35
36//
37// Small class to describe an active session
38//
39#define XPPM_NOPRIORITY 999999
41public:
42 XrdOucString fUser;
43 XrdOucString fGroup;
44 int fPid;
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
73public:
74 XrdProofdPriorityMgr(XrdProofdManager *mgr, XrdProtocol_Config *pi, XrdSysError *e);
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
#define d(i)
Definition RSha256.hxx:102
#define g(i)
Definition RSha256.hxx:105
#define e(i)
Definition RSha256.hxx:103
@ kXPD_sched_off
#define XPPM_NOPRIORITY
void RegisterDirectives()
Register directives for configuration.
int SetProcessPriority(int pid, const char *usr, int &dp)
Change priority of process pid belonging to user, if needed.
int SetNiceValues(int opt=0)
Recalculate nice values taking into account all active users and their priorities.
int Config(bool rcf=0)
Run configuration and parse the entered config directives.
int DoDirective(XrdProofdDirective *d, char *val, XrdOucStream *cfg, bool rcf)
Update the priorities of the active sessions.
int AddSession(const char *u, const char *g, int pid)
Add to the active list a session with ID pid.
XrdOucHash< XrdProofdSessionEntry > fSessions
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
int DoDirectivePriority(char *, XrdOucStream *, bool)
Process 'priority' directive.
int RemoveSession(int pid)
Remove from the active list the session with ID pid.
XrdProofdManager * fMgr
virtual ~XrdProofdSessionEntry()
Destructor.
int SetPriority(int priority=XPPM_NOPRIORITY)
Change process priority.