|
|
|||
File indexing completed on 2026-01-08 10:33:34
0001 #ifndef __XRDSSIPROVIDER_HH__ 0002 #define __XRDSSIPROVIDER_HH__ 0003 /******************************************************************************/ 0004 /* */ 0005 /* X r d S s i P r o v i d e r . h h */ 0006 /* */ 0007 /* (c) 2015 by the Board of Trustees of the Leland Stanford, Jr., University */ 0008 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 0009 /* DE-AC02-76-SFO0515 with the Department of Energy */ 0010 /* */ 0011 /* This file is part of the XRootD software suite. */ 0012 /* */ 0013 /* XRootD is free software: you can redistribute it and/or modify it under */ 0014 /* the terms of the GNU Lesser General Public License as published by the */ 0015 /* Free Software Foundation, either version 3 of the License, or (at your */ 0016 /* option) any later version. */ 0017 /* */ 0018 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 0019 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 0020 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 0021 /* License for more details. */ 0022 /* */ 0023 /* You should have received a copy of the GNU Lesser General Public License */ 0024 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 0025 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 0026 /* */ 0027 /* The copyright holder's institutional names and contributor's names may not */ 0028 /* be used to endorse or promote products derived from this software without */ 0029 /* specific prior written permission of the institution or contributor. */ 0030 /******************************************************************************/ 0031 0032 //----------------------------------------------------------------------------- 0033 //! The XrdSsiProvider object is used by the Scalable Service Interface 0034 //! for two purposes: 0035 //! 1) To ascertain the availability of a resource on a server node in an SSI 0036 //! cluster. 0037 //! 2) To obtain a service object that can process one or more requests. 0038 //! 0039 //! Client-side: A provider object is predefined in libXrdSsi.so and must be 0040 //! used by the client code to get service objects, as follows: 0041 //! 0042 //! extern XrdSsiProvider *XrdSsiProviderClient; 0043 //! XrdSsiService *ClientService = XrdSsiProviderClient-> 0044 //! GetService("hostname:port"); 0045 //! 0046 //! 0047 //! Server-side: the provider object is obtained from the plugin library which 0048 //! should have the XrdSsiProviderLookup and XrdSsiProviderServer 0049 //! pointer symbols defined at file level (i.e. static global). 0050 //! 0051 //! The object pointed to by XrdSsiProviderLookup is used to obtain 0052 //! resource availability information via QueryResource() and a 0053 //! service object is never obtained (i.e. no call to GetService). 0054 //! 0055 //! The object pointed to by XrdSsiProviderServer is used to effect 0056 //! service requests and thus *does* obtain a service object via 0057 //! a GetService() call. 0058 //! 0059 //! These pointers are typically defined, as follows: 0060 //! 0061 //! XrdSsiProvider *XrdSsiProviderLookup 0062 //! = new MyLookupProvider(....); 0063 //! XrdSsiProvider *XrdSsiProviderServer 0064 //! = new MyServerProvider(....); 0065 //! 0066 //! where MyLookupProvider and MyServerProvider objects must 0067 //! inherit class XrdSsiProvider. 0068 //! 0069 //! You use the following directives to configure the 0070 //! service provider for only the process that runs the cmsd: 0071 //! 0072 //! all.role server 0073 //! all.manager <redirector-cmsd>:<port> 0074 //! oss.statlib -2 <path>/libXrdSsi.so 0075 //! 0076 //! Warning! All methods (except Init()) in this class must be thread-safe. 0077 //----------------------------------------------------------------------------- 0078 0079 #include <cerrno> 0080 0081 #include "XrdSsi/XrdSsiErrInfo.hh" 0082 #include "XrdSsi/XrdSsiResource.hh" 0083 0084 class XrdSsiCluster; 0085 class XrdSsiLogger; 0086 class XrdSsiService; 0087 0088 class XrdSsiProvider 0089 { 0090 public: 0091 0092 //----------------------------------------------------------------------------- 0093 //! Issue a control operation (future). 0094 //! 0095 //! @param cmd The control command. 0096 //! @param argP The operational argument cast to a void pointer. 0097 //! @param resP A reference to the pointer to hold the operational 0098 //! result object if any. 0099 //! 0100 //! @return Upon success 0 is returned and if a resutt is returned is must 0101 //! cast to te correct pointer type and deleted,when no longer needed. 0102 //! Upon failure, -errno is returned. 0103 //----------------------------------------------------------------------------- 0104 0105 enum CTL_Cmd {CTL_None = 0}; 0106 0107 virtual int Control(CTL_Cmd cmd, const void *argP, void *&resP) 0108 {(void)cmd; (void)argP; (void)resP; 0109 return (cmd == CTL_None ? 0 : -ENOTSUP); 0110 } 0111 0112 //----------------------------------------------------------------------------- 0113 //! Obtain a service object (client-side or server-side). 0114 //! 0115 //! @param eInfo the object where error status is to be placed. 0116 //! @param contact the point of first contact when processing a request. 0117 //! The contact may be "host:port" where "host" is a DNS name, 0118 //! an IPV4 address (i.e. d.d.d.d), or an IPV6 address 0119 //! (i.e. [x:x:x:x:x:x]), and "port" is either a numeric port 0120 //! number or the service name assigned to the port number. 0121 //! You may specify more than one contact by separating each 0122 //! with a comma (e.g. host1:port,host2:port,...). Each host 0123 //! must be equivalent with respect to request processing. 0124 //! This is a null string if the call is being made server-side. 0125 //! Note that only one service object is obtained by a server. 0126 //! @param oHold the maximum number of request objects that should be held 0127 //! in reserve for future calls. 0128 //! 0129 //! @return =0 A service object could not be created, eInfo has the reason. 0130 //! @return !0 Pointer to a service object. 0131 //----------------------------------------------------------------------------- 0132 0133 virtual 0134 XrdSsiService *GetService(XrdSsiErrInfo &eInfo, 0135 const std::string &contact, 0136 int oHold=256 0137 ) {eInfo.Set("Service not implemented!", ENOTSUP); 0138 return 0; 0139 } 0140 0141 //----------------------------------------------------------------------------- 0142 //! Obtain the version of the abstract class used by underlying implementation. 0143 //! The version returned must match the version compiled in the loading library. 0144 //! If it does not, initialization fails. 0145 //----------------------------------------------------------------------------- 0146 0147 static const int SsiVersion = 0x00010000; 0148 0149 int GetVersion() {return SsiVersion;} 0150 0151 //----------------------------------------------------------------------------- 0152 //! Initialize server-side processing. This method is invoked prior to any 0153 //! other method in the XrdSsiProvider object. 0154 //! 0155 //! @param logP pointer to the logger object for message routing. 0156 //! @param clsP pointer to the cluster management object. This pointer is nil 0157 //! when a service object is being obtained by an unclustered 0158 //! system (i.e. a stand-alone server). 0159 //! @param cfgFn file path to the the conifiguration file. 0160 //! @param parms conifiguration parameters, if any. 0161 //! @param argc The count of command line arguments (always >= 1). 0162 //! @param argv Pointer to a null terminated array of tokenized command line 0163 //! arguments. These arguments are taken from the command line 0164 //! after the "-+xrdssi" option (see invoking xrootd), if present. 0165 //! The first argument is always the same as argv[0] in main(). 0166 //! 0167 //! @return true Initialization succeeded. 0168 //! @return =0 Initialization failed. The method should include an error 0169 //! message in the log indicating why initialization failed. 0170 //----------------------------------------------------------------------------- 0171 0172 virtual bool Init(XrdSsiLogger *logP, 0173 XrdSsiCluster *clsP, 0174 std::string cfgFn, 0175 std::string parms, 0176 int argc, 0177 char **argv 0178 ) = 0; 0179 0180 //----------------------------------------------------------------------------- 0181 //! Obtain the status of a resource. 0182 //! Client-side: This method can be called to obtain the availability of a 0183 //! resource relative to a particular endpoint. 0184 //! Server-Side: When configured via oss.statlib directive, this is called 0185 //! server-side by the XrdSsiCluster object to see if the resource 0186 //! can be provided by the providor via a service object. This 0187 //! method is also used server-side to determine resource status. 0188 //! 0189 //! @param rName Pointer to the resource name. 0190 //! @param contact the point of first contact that would be used to process 0191 //! the request relative to the resource (see ProcessRequest()). 0192 //! A nil pointer indicates a query for availibity at the 0193 //! local node (e.g. a query for local resource availability). 0194 //! 0195 //! @return One of the rStat enums, as follows: 0196 //! notPresent - resource not present on this node. 0197 //! isPresent - resource is present and can be 0198 //! immediately used, if necessary. 0199 //! isPending - resource is present but is not in an 0200 //! immediately usable state, access may wait. 0201 //----------------------------------------------------------------------------- 0202 0203 enum rStat {notPresent = 0, isPresent, isPending}; 0204 0205 virtual rStat QueryResource(const char *rName, 0206 const char *contact=0 0207 ) = 0; 0208 0209 //----------------------------------------------------------------------------- 0210 //! Notify provider that a resource was added to this node. This method is 0211 //! called by the cmsd process in response to calling XrdSsiCluster::Added() 0212 //! in the xrootd process. This method only is invoked on resource storage 0213 //! nodes (i.e. all.role server). 0214 //! 0215 //! @param rName Pointer to the resource name that was added. 0216 //----------------------------------------------------------------------------- 0217 0218 virtual void ResourceAdded(const char *rName) {} 0219 0220 //----------------------------------------------------------------------------- 0221 //! Notify provider that a resource was removed from this node. This method is 0222 //! called by the cmsd process in response to calling XrdSsiCluster::Removed() 0223 //! in the xrootd process. This method only is invoked on resource storage 0224 //! nodes (i.e. all.role server). 0225 //! 0226 //! @param rName Pointer to the resource name that was removed. 0227 //----------------------------------------------------------------------------- 0228 0229 virtual void ResourceRemoved(const char *rName) {} 0230 0231 //----------------------------------------------------------------------------- 0232 //! Set thread values. This call is deprecated. You should use SetConfig(). 0233 //! This method has no meaning server-side and is ignored. 0234 //! 0235 //! @param cbNum Equivalent to SetConfig("cbThreads", cbNum). 0236 //! @param ntNum Equivalent to SetConfig("netThreads", ntNum). 0237 //----------------------------------------------------------------------------- 0238 0239 virtual void SetCBThreads(int cbNum, int ntNum=0) {(void)cbNum; (void)ntNum;} 0240 0241 //----------------------------------------------------------------------------- 0242 //! Set a configuration option for execution behaviour. 0243 //! 0244 //! @param eInfo The object where error status is to be placed. 0245 //! @param optname The name of the option (see table below). 0246 //! @param optvalue The value to be set for the option. 0247 //! 0248 //! @return true Option set. 0249 //! @return false Option not set, eInfo holds the reason. 0250 //! 0251 //! @note All calls to SetConfig() must occur before GetService() is called. 0252 //----------------------------------------------------------------------------- 0253 0254 /*! The following table list the currently supported keynames and what the 0255 value actually does. These options only apply to the client. The options 0256 must be set before calling GetService(). 0257 0258 cbThreads The maximum number of threads to be used for callbacks and 0259 sets the maximum number of active callbacks (default 300). 0260 set a value between 1 and 32767. Note: the nproc ulimit 0261 is final arbiter of the actual number of threads to use. 0262 hiResTime enables the use of a high resolution timer in log message 0263 timestamps. The optvalue is immaterial as this simply sets 0264 feature on and once set on cannot be set off. 0265 netThreads The maximum number of threads to be used to handle network 0266 traffic. The minimum is 3, the default is 10% of cbThreads 0267 but no more than 100. 0268 pollers The number network interrupt pollers to run. Larger values 0269 allow the initial fielding of more interrupts. Care must 0270 be taken to not overrun netThreads. The default is 3. The 0271 suggested maximum is the number of cores. 0272 reqDispatch Request dispatch algorithm to use when contact has multiple 0273 endpoints. Choose one of: 0274 < 0: Random choice each time. 0275 = 0: Use DNS order. 0276 > 0: Round robbin (the default). 0277 */ 0278 0279 virtual bool SetConfig(XrdSsiErrInfo &eInfo, 0280 std::string &optname, 0281 int optvalue) 0282 {(void)optname; (void)optvalue; return 0;} 0283 0284 //----------------------------------------------------------------------------- 0285 //! Set the client-size request spread size. 0286 //! @param ssz The spread value which may be <0, -0, or >0: 0287 //! >0 The maximum number of connections to use to to handle 0288 //! requests. No more or less are used until reset. 0289 //! =0 Turns on auto-tuning using curent setting. The initial 0290 //! default is 4. The size is automatically increased to 0291 //! accomodate the number of simultaeous requests. 0292 //! <0 Turns on auto-tuning using curent setting using the 0293 //! abs(sval) as the new spread value. The size is 0294 //! The size is automatically increased to accomodate the 0295 //! number of simultaeous requests. 0296 //! 0297 //! @note This method may be called at any time. An abs(ssz) value > 1024 0298 //! is set to 1024. Auto-tuning must be requested; it's not the default. 0299 //----------------------------------------------------------------------------- 0300 0301 virtual void SetSpread(short ssz) {(void)ssz;} 0302 0303 //----------------------------------------------------------------------------- 0304 //! Set default global timeouts. By default, all timeouts are set to infinity. 0305 //! 0306 //! @param what One of the enums below specifying the timeout is to be set. 0307 //! @param tmoval The timeout valid in seconds. A value of <= 0 is ignored. 0308 //----------------------------------------------------------------------------- 0309 0310 enum tmoType {connect_N=0, //!< Number of times to try connection (client) 0311 connect_T, //!< Time to wait for a connection (client) 0312 idleClose, //!< Time before an idle socket is closed (client) 0313 request_T, //!< Time to wait for a request to finsish(client) 0314 response_T, //!< Time for client to wait for a resp (Server) 0315 stream_T //!< Time to wait for socket activity (Client) 0316 }; 0317 0318 virtual void SetTimeout(tmoType what, int tmoval) {(void)what; (void)tmoval;} 0319 0320 //----------------------------------------------------------------------------- 0321 //! Constructor 0322 //----------------------------------------------------------------------------- 0323 0324 XrdSsiProvider() {} 0325 protected: 0326 0327 //----------------------------------------------------------------------------- 0328 //! Destructor. The providor object cannot be and never is explicitly deleted. 0329 //----------------------------------------------------------------------------- 0330 0331 virtual ~XrdSsiProvider() {} 0332 }; 0333 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|