00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_XrdProofdPriorityMgr
00013 #define ROOT_XrdProofdPriorityMgr
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <list>
00025
00026 #ifdef OLDXRDOUC
00027 # include "XrdSysToOuc.h"
00028 # include "XrdOuc/XrdOucPthread.hh"
00029 #else
00030 # include "XrdSys/XrdSysPthread.hh"
00031 #endif
00032 #include "XrdOuc/XrdOucHash.hh"
00033 #include "XrdOuc/XrdOucString.hh"
00034
00035 #include "XrdProofdConfig.h"
00036
00037 class XrdProofdDirective;
00038 class XrdProofdManager;
00039
00040
00041
00042
00043 #define XPPM_NOPRIORITY 999999
00044 class XrdProofdSessionEntry {
00045 public:
00046 XrdOucString fUser;
00047 XrdOucString fGroup;
00048 int fPid;
00049 int fDefaultPriority;
00050 int fPriority;
00051 float fFracEff;
00052
00053 XrdProofdSessionEntry(const char *u, const char *g, int pid);
00054 virtual ~XrdProofdSessionEntry();
00055
00056 int SetPriority(int priority = XPPM_NOPRIORITY);
00057 };
00058
00059 class XrdProofdPriorityMgr : public XrdProofdConfig {
00060
00061 XrdSysRecMutex fMutex;
00062
00063 XrdProofdManager *fMgr;
00064 XrdOucHash<XrdProofdSessionEntry> fSessions;
00065 XrdOucHash<XrdProofdPriority> fPriorities;
00066
00067 XrdProofdPipe fPipe;
00068
00069 int fSchedOpt;
00070 int fPriorityMax;
00071 int fPriorityMin;
00072
00073 void RegisterDirectives();
00074 int DoDirectivePriority(char *, XrdOucStream *, bool);
00075 int DoDirectiveSchedOpt(char *, XrdOucStream *, bool);
00076
00077 public:
00078 XrdProofdPriorityMgr(XrdProofdManager *mgr, XrdProtocol_Config *pi, XrdSysError *e);
00079 virtual ~XrdProofdPriorityMgr() { }
00080
00081 enum PMProtocol { kChangeStatus = 0, kSetGroupPriority = 1 };
00082
00083 int Config(bool rcf = 0);
00084 int DoDirective(XrdProofdDirective *d,
00085 char *val, XrdOucStream *cfg, bool rcf);
00086
00087 inline XrdProofdPipe *Pipe() { return &fPipe; }
00088
00089 int AddSession(const char *u, const char *g, int pid);
00090 int RemoveSession(int pid);
00091 void SetGroupPriority(const char *grp, int priority);
00092
00093
00094 bool IsSchedOn() { return ((fSchedOpt != kXPD_sched_off) ? 1 : 0); }
00095 int SetNiceValues(int opt = 0);
00096 void SetSchedOpt(int opt) { XrdSysMutexHelper mhp(&fMutex);
00097 fSchedOpt = opt; }
00098 int SetProcessPriority(int pid, const char *usr, int &dp);
00099 };
00100
00101 #endif