XrdProofdPriorityMgr.h

Go to the documentation of this file.
00001 // @(#)root/proofd:$Id: XrdProofdPriorityMgr.h 26447 2008-11-25 11:11:39Z ganis $
00002 // Author: G. Ganis Feb 2008
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_XrdProofdPriorityMgr
00013 #define ROOT_XrdProofdPriorityMgr
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 // XrdProofdPriorityMgr                                                 //
00018 //                                                                      //
00019 // Author: G. Ganis, CERN, 2007                                         //
00020 //                                                                      //
00021 // Class managing session priorities.                                   //
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 // Small class to describe an active session
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;  // Resource fraction in % (effective)
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;          // Atomize this instance
00062 
00063    XrdProofdManager *fMgr;
00064    XrdOucHash<XrdProofdSessionEntry> fSessions; // list of active sessions (keyed by "pid")
00065    XrdOucHash<XrdProofdPriority> fPriorities; // list of {users, priority change}
00066 
00067    XrdProofdPipe     fPipe;
00068 
00069    int               fSchedOpt;       // Worker sched option
00070    int               fPriorityMax;    // Max session priority [1,40], [20]
00071    int               fPriorityMin;    // Min session priority [1,40], [1]
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    // Scheduling
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

Generated on Tue Jul 5 14:51:45 2011 for ROOT_528-00b_version by  doxygen 1.5.1