Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef __XRDSSISERVICE_HH__
0002 #define __XRDSSISERVICE_HH__
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                      X r d S s i S e r v i c e . 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 #include <cstdint>
0033 #include <string>
0034   
0035 //-----------------------------------------------------------------------------
0036 //! The XrdSsiService object is used by the Scalable Service Interface to
0037 //! process client requests.
0038 //!
0039 //! There may be many client-side service objects, as needed. However, only
0040 //! one such object is obtained server-side. The object is used to effect all
0041 //! service requests and handle responses.
0042 //!
0043 //! Client-side: the service object is obtained via the object pointed to by
0044 //!              XrdSsiProviderClient defined in libXrdSsi.so
0045 //!
0046 //! Server-side: the service object is obtained via the object pointed to by
0047 //!              XrdSsiProviderServer defined in the plugin shared library.
0048 //-----------------------------------------------------------------------------
0049 
0050 class XrdSsiErrInfo;
0051 class XrdSsiRequest;
0052 class XrdSsiResource;
0053 
0054 class XrdSsiService
0055 {
0056 public:
0057 
0058 //-----------------------------------------------------------------------------
0059 //! Obtain the version of the abstract class used by underlying implementation.
0060 //! The version returned must match the version compiled in the loading library.
0061 //! If it does not, initialization fails.
0062 //-----------------------------------------------------------------------------
0063 
0064 static const int SsiVersion = 0x00020000;
0065 
0066        int     GetVersion() {return SsiVersion;}
0067 
0068 //-----------------------------------------------------------------------------
0069 //! @brief Attach to a backgrounded request.
0070 //!
0071 //! When a client calls Attach() the server-side Attach() is invoked to
0072 //! indicate that the backgrounded request is now a foreground request. Many
0073 //! times such notification is not needed so a default nil implementation is
0074 //! provided. Server-side Attach() calls are always passed the original request
0075 //! object reference so that it can pair up the request with the attach.
0076 //!
0077 //! @param  eInfo    Reference to an error info object which will contain the
0078 //!                  error describing why the attach failed (i.e. return false).
0079 //!
0080 //! @param  handle   Reference to the handle provided to the callback method
0081 //!                  XrdSsiRequest::ProcessResponse() via isHandle response type.
0082 //!                  This is always an empty string on server-side calls.
0083 //!
0084 //! @param  reqRef   Reference to the request object that is to attach to the
0085 //!                  backgrounded request. It need not be the original request
0086 //!                  object (client-side) but it always is the original request
0087 //!                  object server-side.
0088 //!
0089 //! @param  resP     A pointer to the resource object describing the request
0090 //!                  resources. This is meaningless for client calls and should
0091 //!                  not be specified. For server-side calls, it can be used to
0092 //!                  reauthorize the request since the client performing the
0093 //!                  attach may be different from the client that actually
0094 //!                  started the request.
0095 //!
0096 //! @return true     Continue normally, no issues detected.
0097 //!         false    An exception occurred, the eInfo object has the reason. For
0098 //!                  server side calls this provides the service the ability to
0099 //!                  reject request reattachment.
0100 //-----------------------------------------------------------------------------
0101 
0102 virtual bool   Attach(      XrdSsiErrInfo  &eInfo,
0103                       const std::string    &handle,
0104                             XrdSsiRequest  &reqRef,
0105                             XrdSsiResource *resP=0
0106                      ) {return true;}
0107 
0108 //-----------------------------------------------------------------------------
0109 //! @brief Prepare for processing subsequent resource request.
0110 //!
0111 //! This method is meant to be used server-side to optimize subsequent request
0112 //! processing, perform authorization, and allow a service to stall or redirect
0113 //! requests. It is optional and a default implementation is provided that
0114 //! simply asks the provider if the resource exists on the server. Clients need
0115 //! not call or implement this method.
0116 //!
0117 //! @param  eInfo    The object where error information is to be placed.
0118 //! @param  rDesc    Reference to the resource object that describes the
0119 //!                  resource subsequent requests will use.
0120 //!
0121 //! @return true     Continue normally, no issues detected.
0122 //!         false    An exception occurred, the eInfo object has the reason.
0123 //!
0124 //! Special notes for server-side processing:
0125 //!
0126 //! 1) Two special errors are recognized that allow for a client retry:
0127 //!
0128 //!    resP->eInfo.eNum = EAGAIN (client should retry elsewhere)
0129 //!    resP->eInfo.eMsg = the host name where the client is redirected
0130 //!    resP->eInfo.eArg = the port number to be used by the client
0131 //!
0132 //!    resP->eInfo.eNum = EBUSY  (client should wait and then retry).
0133 //!    resP->eInfo.eMsg = an optional reason for the wait.
0134 //!    resP->eInfo.eArg = the number of seconds the client should wait.
0135 //-----------------------------------------------------------------------------
0136 
0137 virtual bool   Prepare(XrdSsiErrInfo &eInfo, const XrdSsiResource &rDesc);
0138 
0139 //-----------------------------------------------------------------------------
0140 //! @brief Process a request; client-side or server-side.
0141 //!
0142 //! When a client calls ProcessRequest() the same method is called server-side
0143 //! with the same parameters that the client specified except for timeOut which
0144 //! is always set to zero server-side.
0145 //!
0146 //! @param  reqRef   Reference to the Request  object that describes the
0147 //!                  request.
0148 //!
0149 //! @param  resRef   Reference to the Resource object that describes the
0150 //!                  resource that the request will be using.
0151 //!
0152 //! All results are returned via the request object callback methods.
0153 //! For background queries, the XrdSsiRequest::ProcessResponse() is 
0154 //! called with a response type of isHandle when the request is handed
0155 //! off to the endpoint for execution (see XrdSsiRequest::SetDetachTTL).
0156 //-----------------------------------------------------------------------------
0157 
0158 virtual void   ProcessRequest(XrdSsiRequest  &reqRef,
0159                               XrdSsiResource &resRef
0160                              ) = 0;
0161 
0162 //-----------------------------------------------------------------------------
0163 //! @brief Stop the client-side service. This is never called server-side.
0164 //!
0165 //! @param  immed    When true, the service is only stopped if here are no
0166 //!                  active requests. Otherwise, after all requests have
0167 //!                  finished. the service object is deleted.
0168 //!
0169 //! @return true     Service has been stopped. Once all requests have been
0170 //!                  completed, the service object will be deleted.
0171 //! @return false    Service cannot be stopped because there are still active
0172 //!                  foreground requests and the immed parameter was true.
0173 //-----------------------------------------------------------------------------
0174 
0175 virtual bool   Stop(bool immed=false) {return !immed;}
0176 
0177 //-----------------------------------------------------------------------------
0178 //! Constructor
0179 //-----------------------------------------------------------------------------
0180 
0181                XrdSsiService() {}
0182 protected:
0183 
0184 //-----------------------------------------------------------------------------
0185 //! Destructor. The service object cannot be explicitly deleted. Use Stop().
0186 //-----------------------------------------------------------------------------
0187 
0188 virtual       ~XrdSsiService() {}
0189 };
0190 #endif