Logo ROOT  
Reference Guide
XrdProofSched.h
Go to the documentation of this file.
1// @(#)root/proofd:$Id$
2// Author: G. Ganis Jun 2007
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_XrdProofSched
13#define ROOT_XrdProofSched
14
15//////////////////////////////////////////////////////////////////////////
16// //
17// XrdProofSched //
18// //
19// Authors: G. Ganis, CERN, 2007 //
20// //
21// Interface for a PROOF scheduler. //
22// Alternative scheduler implementations should be provided as shared //
23// library containing an implementation of this class. The library //
24// must also provide a function to load an instance of this class //
25// with the following signature (see commented example in //
26// XrdProofSched.cxx): //
27// extern "C" { //
28// XrdProofSched *XrdgetProofSched(const char *cfg, //
29// XrdProofdManager *mgr, //
30// XrdProofGroupMgr *grpmgr, //
31// XrdSysError *edest); //
32// } //
33// Here 'cfg' is the xrootd config file where directives to configure //
34// the scheduler are specified, 'mgr' is the instance of the cluster //
35// manager from where the scheduler can get info about the available //
36// workers and their status, 'grpmgr' is the instance of the group //
37// bringing the definition of the groups for this run, and 'edest' is //
38// instance of the error logger to be used. //
39// The scheduler is identified by a name of max 16 chars. //
40// //
41//////////////////////////////////////////////////////////////////////////
42
43#include <list>
44
45#include "XrdProofdAux.h"
46#include "XrdOuc/XrdOucHash.hh"
47#include "XrdOuc/XrdOucString.hh"
48
49#include "XrdSysToOuc.h"
50
51#include "XrdProofdConfig.h"
52
53#define kXPSMXNMLEN 17
54
58class XrdProofWorker;
59class XrdSysError;
60class XrdOucStream;
61
63
64public:
65 XrdProofSched(const char *name,
67 const char *cfn, XrdSysError *e = 0);
68 virtual ~XrdProofSched() { }
69
70 // Returns list of workers to be used by session 'xps'.
71 // The return code must be one of the following:
72 // -1 Some failure occured; cannot continue
73 // 0 A new list has been assigned to the session 'xps' and
74 // returned in 'wrks'
75 // 1 The list currently assigned to the session is the one
76 // to be used
77 // 2 No worker could be assigned now; session should be queued
78 virtual int GetWorkers(XrdProofdProofServ *xps,
79 std::list<XrdProofWorker *> */*wrks*/,
80 const char *);
81
82 // To be called after some nodes become free
83 virtual int Reschedule();
84
85 // Update info about a session
86 virtual int UpdateSession(XrdProofdProofServ *, int = 0, void * = 0) { return 0; }
87
88 // Max number of essions we are allowed to start
89 virtual int MaxSessions() const { return fMaxSessions; }
90
91 // Update group properties according to the current state
92 virtual int UpdateProperties() { return 0; }
93
94 virtual int ExportInfo(XrdOucString &);
95
96 virtual bool IsValid() { return fValid; }
97
98 const char *Name() const { return (const char *) &fName[0]; }
99
101 char *val, XrdOucStream *cfg, bool rcf);
102 virtual int Enqueue(XrdProofdProofServ *xps, XrdProofQuery *query);
103 virtual void DumpQueues(const char *prefix = 0);
104
106
107 int CheckFrequency() const { return fCheckFrequency; }
108 inline XrdProofdPipe *Pipe() { return &fPipe; }
109
110 virtual int Config(bool rcf = 0);
111 virtual int DoDirective(XrdProofdDirective *d,
112 char *val, XrdOucStream *cfg, bool rcf);
113
115
116protected:
117 char fName[kXPSMXNMLEN]; // Name of this protocol
118 bool fValid; // TRUE if the scheduler is usable
119 XrdProofdManager *fMgr; // Cluster manager
120 XrdProofGroupMgr *fGrpMgr; // Groups manager
121
122 int fMaxSessions; // max number of sessions
123 int fMaxRunning; // max number of running sessions
124 int fWorkerMax; // max number or workers per user
125 int fWorkerSel; // selection option
126 int fNextWrk; // Reference index for RR sel option
127 int fOptWrksPerUnit; // optimal # of workers per CPU/HD
128 int fMinForQuery; // Minimal number of workers for a query
129 double fNodesFraction; // the fraction of free units to assign
130 // to a query.
131 bool fUseFIFO; // use FIFO or refuse if overloaded
132 std::list<XrdProofdProofServ *> fQueue; // the queue with sessions (jobs);
133
134 XrdOucHash<XrdProofdDirective> fConfigDirectives; // Config directives
135
138
139 XrdSysError *fEDest; // Error message handler
140
141
142 virtual void RegisterDirectives();
143 virtual int DoDirectiveSchedParam(char *, XrdOucStream *, bool);
144 virtual int DoDirectiveResource(char *, XrdOucStream *, bool);
145
146 virtual int GetNumWorkers(XrdProofdProofServ *xps);
147 virtual void ResetParameters();
148};
149
150
151// Plugin loader handle
152typedef XrdProofSched *(*XrdProofSchedLoader_t)(const char *, XrdProofdManager *,
153 XrdProofGroupMgr *, const char *,
154 XrdSysError *);
155
156#endif
#define d(i)
Definition: RSha256.hxx:102
#define e(i)
Definition: RSha256.hxx:103
char name[80]
Definition: TGX11.cxx:109
#define XrdSysError
Definition: XpdSysError.h:8
#define kXPSMXNMLEN
Definition: XrdProofSched.h:53
virtual int DoDirectiveResource(char *, XrdOucStream *, bool)
Process 'resource' directive.
virtual int GetWorkers(XrdProofdProofServ *xps, std::list< XrdProofWorker * > *, const char *)
Get a list of workers that can be used by session 'xps'.
virtual int MaxSessions() const
Definition: XrdProofSched.h:89
virtual int ExportInfo(XrdOucString &)
Fill sbuf with some info about our current status.
virtual int ProcessDirective(XrdProofdDirective *d, char *val, XrdOucStream *cfg, bool rcf)
Update the priorities of the active sessions.
virtual int Reschedule()
Consider starting some query from the queue.
virtual void RegisterDirectives()
Register directives for configuration.
char fName[kXPSMXNMLEN]
XrdSysError * fEDest
virtual int Enqueue(XrdProofdProofServ *xps, XrdProofQuery *query)
Queue a query in the session; if this is the first querym enqueue also the session.
XrdProofdPipe * Pipe()
XrdOucHash< XrdProofdDirective > fConfigDirectives
virtual int UpdateProperties()
Definition: XrdProofSched.h:92
double fNodesFraction
virtual int DoDirective(XrdProofdDirective *d, char *val, XrdOucStream *cfg, bool rcf)
Update the priorities of the active sessions.
std::list< XrdProofdProofServ * > fQueue
int CheckFrequency() const
virtual XrdProofdProofServ * FirstSession()
Get first valid session.
XrdProofSched(const char *name, XrdProofdManager *mgr, XrdProofGroupMgr *grpmgr, const char *cfn, XrdSysError *e=0)
Constructor.
virtual void DumpQueues(const char *prefix=0)
Dump the content of the waiting sessions queue.
XrdProofGroupMgr * fGrpMgr
virtual int Config(bool rcf=0)
Configure this instance using the content of file 'cfn'.
const char * Name() const
Definition: XrdProofSched.h:98
virtual void ResetParameters()
Reset values for the configurable parameters.
virtual int GetNumWorkers(XrdProofdProofServ *xps)
Calculate the number of workers to be used given the state of the cluster.
XrdProofdPipe fPipe
virtual int DoDirectiveSchedParam(char *, XrdOucStream *, bool)
Process 'schedparam' directive.
virtual ~XrdProofSched()
Definition: XrdProofSched.h:68
virtual int UpdateSession(XrdProofdProofServ *, int=0, void *=0)
Definition: XrdProofSched.h:86
XrdProofdManager * fMgr
virtual bool IsValid()
Definition: XrdProofSched.h:96