XrdBwmPolicy.hh

Go to the documentation of this file.
00001 #ifndef __BWM_POLICY__
00002 #define __BWM_POLICY__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                       X r d B w m P o l i c y . h h                        */
00006 /*                                                                            */
00007 /* (c) 2008 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*                            All Rights Reserved                             */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012 
00013 //         $Id: XrdBwmPolicy.hh 24468 2008-06-22 16:47:03Z ganis $
00014 
00015 class XrdBwmPolicy
00016 {
00017 public:
00018 
00019 /* General note: Each request is to be identified by an int-sized handle.
00020                  The value of the handle is unique with respect to all of the
00021                  requests that are active and queued. Once a request leaves
00022                  the system (i.e., cancelled or released) the handle may be
00023                  re-used. Handle signs are immaterial. That is the property
00024                  "n == abs(-n) == <same request>" always must hold. Note that
00025                  Schedule() uses negative handles to merely indicate queuing.
00026 */
00027 
00028 /* Dispatch() returns the handle of the next request that may become active
00029    because the resources are now available or that must be terminated
00030    because resources are not available. The returned value must have the
00031    the following property: "Dispatch() == abs(Schedule()) == <same request>".
00032    Hence, the handle returned by Dispatch() must be one previously returned by
00033    Schedule() that was negative to indicate that the request was queued. The
00034    sign of the returned handle indicates success or failure:
00035 
00036    returns <  0: The associated previously scheduled request cannot obtain 
00037                  the resource. RespBuff, of size RespSize, should contain
00038                  null terminated text describing the failure. Done() will not
00039                  called for the returned handle.
00040    returns >= 0: The associated previously scheduled request can now be
00041                  dispatched as resources are available. RespBuff, of size
00042                  RespSize, should contain any visa information, as an
00043                  ASCII null terminated string to be sent to client. If none,
00044                  it should contain a null string (i.e., zero byte). Done()
00045                  will be called for the returned handle when the resource is no
00046                  longer needed.
00047 
00048    Dispatch() blocks until a request is ready or has failed.
00049 */
00050 
00051 virtual int  Dispatch(char *RespBuff, int RespSize) = 0;
00052 
00053 /* Done() indicates that the resources with a previous request associated with
00054    the handle, as returned by Dispatch() and Schedule(). When Done() is called
00055    with a handle referring to a queued request, the request should be cancelled
00056    and removed from the queue. If the handle refers to an active request (i.e.,
00057    a non-negative one that was returned by Dispatch()), the resources associated
00058    with the dispatched request are no longer needed and are to be made available
00059    to another request. The value returned by Done() indicates what happened:
00060 
00061    returns < 0: The queued request was cancelled.
00062    returns = 0: No request matching the handle was found.
00063    returns > 0: The resources associated with the dispatched request returned.
00064 
00065    The handle itself may be a positive or negative, as returned by Dispatch()
00066    and Schedule(). Note that "n == abs(-n) == <same request>", so the sign
00067    of the handle should be immaterial to Done(). Negative handles returned by
00068    Dispatch() indicate failure and thus Done() will not be called for such
00069    handles. Handles returned by Schedule() may be postive or negative.
00070 */
00071 
00072 virtual int  Done(int rHandle) = 0;
00073 
00074 /* Schedule() is invoked when the caller wishes to obtain resources controlled
00075    by the policy. The caller passes a pointer to a response buffer, RespBuff,
00076    of size contained in RespSize, to hold hold any response. Additionally. a
00077    reference to the SchedParms struct that contains information about the 
00078    nature of the request. Schedule() may choose to immediately allow the 
00079    resourse to be used, fail the request, or to defer the request. 
00080    This is indicated by the returned int, as follows:
00081 
00082    returns < 0: The request has been queued. The returned value is the handle
00083                 for the request and is to be used as the argument to Done() to
00084                 cancel the queued request.
00085 
00086    returns = 0: The request failed. The RespBuff should contain any error text
00087                 or a null byte if no text is present.
00088 
00089    returns > 0: The request succeeded and the resource can be used. The returned
00090                 value is the handle for the request and is to be used as the
00091                 argument to Done() to release the associated request resource.
00092 
00093                 RespBuff should contain any visa information, as an ASCII null
00094                          terminated string to be sent to client. If none, it
00095                          must contain a null string (i.e., zero byte).
00096 */
00097 enum Flow {Incomming = 0, Outgoing};
00098 
00099 struct SchedParms
00100 {
00101 const char  *Tident;     // In: -> Client's trace identity
00102       char  *Lfn;        // In: -> Logical File Name
00103       char  *LclNode;    // In: -> Local  node involved in the request
00104       char  *RmtNode;    // In: -> Remote node involved in the request
00105       Flow   Direction;  // In: -> Data flow relative to Lclpoint (see enum)
00106 };
00107 
00108 virtual int  Schedule(char *RespBuff, int RespSize, SchedParms &Parms) = 0;
00109 
00110 /* Status() returns the number of requests as three items via parameters:
00111             numqIn  - Number of incomming data requests queued
00112             numqOut - Number of outgoing  data requests queued
00113             numXeq  - Number of requests that are active (in or out).
00114 */
00115 
00116 virtual void Status(int &numqIn, int &numqOut, int &numXeq) = 0;
00117 
00118              XrdBwmPolicy() {}
00119 
00120 virtual     ~XrdBwmPolicy() {}
00121 };
00122   
00123 /******************************************************************************/
00124 /*                    X r d B w m P o l i c y O b j e c t                     */
00125 /******************************************************************************/
00126 
00127 class XrdSysLogger;
00128   
00129 /* XrdBwmPolicyObject() is called to obtain an instance of the policy object
00130    that will be used for all subsequent policy scheduling requests. If it 
00131    returns a null pointer; initialization fails and the program exits. 
00132    The args are:
00133 
00134    lp    -> XrdSysLogger to be tied to an XrdSysError object for messages
00135    cfn   -> The name of the configuration file
00136    parm  -> Parameters specified on the policy lib directive. If none it's zero.
00137 */
00138 
00139 extern "C" XrdBwmPolicy *XrdBwmPolicyObject(XrdSysLogger *lp,
00140                                             const char   *cfn,
00141                                             const char   *parm);
00142 #endif

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