Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-08 10:33:34

0001 #ifndef __SSICLUSTER__
0002 #define __SSICLUSTER__
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                      X r d S s i C l u s t e r . h h                       */
0006 /*                                                                            */
0007 /* (c) 2013 by the Board of Trustees of the Leland Stanford, Jr., University  */
0008 /*                            All Rights Reserved                             */
0009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
0010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
0011 /*                                                                            */
0012 /* This file is part of the XRootD software suite.                            */
0013 /*                                                                            */
0014 /* XRootD is free software: you can redistribute it and/or modify it under    */
0015 /* the terms of the GNU Lesser General Public License as published by the     */
0016 /* Free Software Foundation, either version 3 of the License, or (at your     */
0017 /* option) any later version.                                                 */
0018 /*                                                                            */
0019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
0020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
0021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
0022 /* License for more details.                                                  */
0023 /*                                                                            */
0024 /* You should have received a copy of the GNU Lesser General Public License   */
0025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
0026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
0027 /*                                                                            */
0028 /* The copyright holder's institutional names and contributor's names may not */
0029 /* be used to endorse or promote products derived from this software without  */
0030 /* specific prior written permission of the institution or contributor.       */
0031 /******************************************************************************/
0032 
0033 //------------------------------------------------------------------------------
0034 //! The XrdSsiCluster object provides methods to manage the names and resources
0035 //! of a server node relative to the cluster in which it resides. A pointer to
0036 //! object is passed to the XrdSsiServer object loaded as start-up. It remains
0037 //! valid for the duration of the program.
0038 //------------------------------------------------------------------------------
0039 
0040 class XrdSsiCluster
0041 {
0042 public:
0043 
0044 //------------------------------------------------------------------------------
0045 //! Notify the cluster of a newly added endpoint name or whose state has 
0046 //! changed on on this server node.
0047 //!
0048 //! @param  name  The logical name.
0049 //! @param  pend  When true, the name is scheduled to be present in the future.
0050 //------------------------------------------------------------------------------
0051 
0052 virtual void   Added(const char *name, bool pend=false) = 0;
0053 
0054 //------------------------------------------------------------------------------
0055 //! Determine whether or not the SSI plug-in is running in a data context.
0056 //!
0057 //! @return true  running in a data context (i.e. xrootd).
0058 //! @return false running is a meta context (i.e. cmsd).
0059 //------------------------------------------------------------------------------
0060 
0061 virtual bool          DataContext() = 0;
0062 
0063 //------------------------------------------------------------------------------
0064 //! Obtain the list of nodes that are managing this cluster.
0065 //!
0066 //! @param  mNum Place to put the number of managers in the returned array.
0067 //!
0068 //! @return The vector of nodes being used with mNum set to the number of
0069 //!         elements. The list is considered permanent and is not deleted.
0070 //------------------------------------------------------------------------------
0071 
0072 virtual
0073 const  char  * const *Managers(int &mNum) = 0;
0074 
0075 //------------------------------------------------------------------------------
0076 //! Notify the cluster that a name is no longer available on this server node.
0077 //!
0078 //! @param  name The logical name that is no longer available.
0079 //------------------------------------------------------------------------------
0080 
0081 virtual void   Removed(const char *name) = 0;
0082 
0083 //------------------------------------------------------------------------------
0084 //! Resume service after a suspension.
0085 //!
0086 //! @param  perm When true the resume persist across server restarts. Otherwise,
0087 //!              it is treated as a temporary request.
0088 //------------------------------------------------------------------------------
0089 
0090 virtual void   Resume (bool perm=true) = 0;
0091 
0092 //------------------------------------------------------------------------------
0093 //! Suspend service.
0094 //!
0095 //! @param  perm When true the suspend persist across server restarts.
0096 //!              Otherwise, it is treated as a temporary request.
0097 //------------------------------------------------------------------------------
0098 
0099 virtual void   Suspend(bool perm=true) = 0;
0100 
0101 //------------------------------------------------------------------------------
0102 //! Enable the Reserve() & Release() methods.
0103 //!
0104 //! @param  n  a positive integer that specifies the amount of resource units
0105 //!            that are available. It may be reset at any time.
0106 //!
0107 //! @return The previous resource value. This first call returns 0.
0108 //------------------------------------------------------------------------------
0109 
0110 virtual int    Resource(int n) = 0;
0111 
0112 //------------------------------------------------------------------------------
0113 //! Decrease the amount of resources available. When the available resources
0114 //! becomes non-positive, perform a temporary suspend to prevent additional
0115 //! clients from being dispatched to this server.
0116 //!
0117 //! @param  n  The value by which resources are decreased (default 1).
0118 //!
0119 //! @return The amount of resource left.
0120 //------------------------------------------------------------------------------
0121 
0122 virtual int    Reserve (int n=1) = 0;
0123 
0124 //------------------------------------------------------------------------------
0125 //! Increase the amount of resource available. When transitioning from a
0126 //! a non-positive to a positive resource amount, perform a resume so that
0127 //! additional clients may be dispatched to this server.
0128 //!
0129 //! @param  n  The value to add to the resources available (default 1). The
0130 //!            total amount is capped by the amount specified by Resource().
0131 //!
0132 //! @return The amount of resource left.
0133 //------------------------------------------------------------------------------
0134 
0135 virtual int    Release (int n=1) = 0;
0136 
0137 //------------------------------------------------------------------------------
0138 //! Report utilization of this server. This may be used in lieu of general
0139 //! performance metric reporting. For consistent results use only one method.
0140 //!
0141 //! @param  util  A value from 0 to 100 representing utilization. Values
0142 //!               greater than 100 are set to be 100.
0143 //! @param  alert When true the utilization is forcibly report to the
0144 //!               cluster managers. Otherwise, reporting is done only when
0145 //!               it will significantly change server selection.
0146 //------------------------------------------------------------------------------
0147 
0148 virtual void   Utilization(unsigned int util, bool alert=false) = 0;
0149 
0150 //------------------------------------------------------------------------------
0151 //! Destructor
0152 //------------------------------------------------------------------------------
0153 
0154                XrdSsiCluster() {}
0155 virtual       ~XrdSsiCluster() {}
0156 
0157 };
0158 #endif