XrdProofSched.h

Go to the documentation of this file.
00001 // @(#)root/proofd:$Id: XrdProofSched.h 27270 2009-01-28 07:44:26Z ganis $
00002 // Author: G. Ganis  Jun 2007
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_XrdProofSched
00013 #define ROOT_XrdProofSched
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 // XrdProofSched                                                        //
00018 //                                                                      //
00019 // Authors: G. Ganis, CERN, 2007                                        //
00020 //                                                                      //
00021 // Interface for a PROOF scheduler.                                     //
00022 // Alternative scheduler implementations should be provided as shared   //
00023 // library containing an implementation of this class. The library      //
00024 // must also provide a function to load an instance of this class       //
00025 // with the following signature (see commented example in               //
00026 // XrdProofSched.cxx):                                                  //
00027 // extern "C" {                                                         //
00028 //    XrdProofSched *XrdgetProofSched(const char *cfg,                  //
00029 //                                    XrdProofdManager *mgr,            //
00030 //                                    XrdProofGroupMgr *grpmgr,         //
00031 //                                    XrdSysError *edest);              //
00032 // }                                                                    //
00033 // Here 'cfg' is the xrootd config file where directives to configure   //
00034 // the scheduler are specified, 'mgr' is the instance of the cluster    //
00035 // manager from where the scheduler can get info about the available    //
00036 // workers and their status, 'grpmgr' is the instance of the group      //
00037 // bringing the definition of the groups for this run, and 'edest' is   //
00038 // instance of the error logger to be used.                             //
00039 // The scheduler is identified by a name of max 16 chars.               //
00040 //                                                                      //
00041 //////////////////////////////////////////////////////////////////////////
00042 
00043 #include <list>
00044 
00045 #include "XrdProofdAux.h"
00046 #include "XrdOuc/XrdOucHash.hh"
00047 #include "XrdOuc/XrdOucString.hh"
00048 #ifdef OLDXRDOUC
00049 #  include "XrdSysToOuc.h"
00050 #endif
00051 
00052 #include "XrdProofdConfig.h"
00053 
00054 #define kXPSMXNMLEN 17
00055 
00056 class XrdProofdManager;
00057 class XrdProofGroupMgr;
00058 class XrdProofdProofServ;
00059 class XrdProofWorker;
00060 class XrdSysError;
00061 class XrdOucStream;
00062 
00063 class XrdProofSched : public XrdProofdConfig {
00064 
00065 public:
00066    XrdProofSched(const char *name,
00067                  XrdProofdManager *mgr, XrdProofGroupMgr *grpmgr,
00068                  const char *cfn, XrdSysError *e = 0);
00069    virtual ~XrdProofSched() { }
00070 
00071    // Returns list of workers to be used by session 'xps'.
00072    // The return code must be one of the following:
00073    //  -1     Some failure occured; cannot continue
00074    //   0     A new list has been assigned to the session 'xps' and
00075    //         returned in 'wrks'
00076    //   1     The list currently assigned to the session is the one
00077    //         to be used
00078    //   2     No worker could be assigned now; session should be queued
00079    virtual int GetWorkers(XrdProofdProofServ *xps,
00080                           std::list<XrdProofWorker *> */*wrks*/,
00081                           const char *);
00082 
00083    // To be called after some nodes become free
00084    virtual int Reschedule();
00085 
00086    // Update info about a session
00087    virtual int UpdateSession(XrdProofdProofServ *, int = 0, void * = 0) { return 0; }
00088 
00089    // Max number of essions we are allowed to start
00090    virtual int MaxSessions() const { return fMaxSessions; }
00091 
00092    // Update group properties according to the current state
00093    virtual int UpdateProperties() { return 0; }
00094 
00095    virtual int ExportInfo(XrdOucString &);
00096 
00097    virtual bool IsValid() { return fValid; }
00098 
00099    const char *Name() const { return (const char *) &fName[0]; }
00100 
00101    virtual int ProcessDirective(XrdProofdDirective *d,
00102                                 char *val, XrdOucStream *cfg, bool rcf);
00103    virtual int Enqueue(XrdProofdProofServ *xps, XrdProofQuery *query);
00104    virtual void DumpQueues(const char *prefix = 0);
00105 
00106    virtual XrdProofdProofServ *FirstSession();
00107 
00108    int         CheckFrequency() const { return fCheckFrequency; }
00109    inline XrdProofdPipe *Pipe() { return &fPipe; }
00110 
00111    virtual int Config(bool rcf = 0);
00112    virtual int DoDirective(XrdProofdDirective *d,
00113                                  char *val, XrdOucStream *cfg, bool rcf);
00114 
00115    enum SchedProtocol { kReschedule = 0 };
00116 
00117 protected:
00118    char              fName[kXPSMXNMLEN];   // Name of this protocol
00119    bool              fValid;  // TRUE if the scheduler is usable
00120    XrdProofdManager *fMgr;    // Cluster manager
00121    XrdProofGroupMgr *fGrpMgr;  // Groups manager
00122 
00123    int               fMaxSessions; // max number of sessions
00124    int               fMaxRunning;  // max number of running sessions
00125    int               fWorkerMax;   // max number or workers per user
00126    int               fWorkerSel;   // selection option
00127    int               fNextWrk;     // Reference index for RR sel option
00128    int               fOptWrksPerUnit; // optimal # of workers per CPU/HD
00129    int               fMinForQuery; // Minimal number of workers for a query
00130    double            fNodesFraction; // the fraction of free units to assign
00131                                      // to a query.
00132    bool              fUseFIFO;    // use FIFO or refuse if overloaded 
00133    std::list<XrdProofdProofServ *> fQueue; // the queue with sessions (jobs);
00134 
00135    XrdOucHash<XrdProofdDirective> fConfigDirectives; // Config directives
00136 
00137    int               fCheckFrequency;
00138    XrdProofdPipe     fPipe;
00139 
00140    XrdSysError      *fEDest;      // Error message handler
00141 
00142 
00143    virtual void      RegisterDirectives();
00144    virtual int       DoDirectiveSchedParam(char *, XrdOucStream *, bool);
00145    virtual int       DoDirectiveResource(char *, XrdOucStream *, bool);
00146 
00147    virtual int       GetNumWorkers(XrdProofdProofServ *xps);
00148    virtual void      ResetParameters();
00149 };
00150 
00151 
00152 // Plugin loader handle
00153 typedef XrdProofSched *(*XrdProofSchedLoader_t)(const char *, XrdProofdManager *,
00154                                                 XrdProofGroupMgr *, const char *,
00155                                                 XrdSysError *);
00156 
00157 #endif

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