00001 #ifndef __XRDSSIREQUEST_HH__ 00002 #define __XRDSSIREQUEST_HH__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d S s i R e q u e s t . h h */ 00006 /* */ 00007 /* (c) 2013 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00009 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00010 /* */ 00011 /* This file is part of the XRootD software suite. */ 00012 /* */ 00013 /* XRootD is free software: you can redistribute it and/or modify it under */ 00014 /* the terms of the GNU Lesser General Public License as published by the */ 00015 /* Free Software Foundation, either version 3 of the License, or (at your */ 00016 /* option) any later version. */ 00017 /* */ 00018 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00019 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00020 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00021 /* License for more details. */ 00022 /* */ 00023 /* You should have received a copy of the GNU Lesser General Public License */ 00024 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00025 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00026 /* */ 00027 /* The copyright holder's institutional names and contributor's names may not */ 00028 /* be used to endorse or promote products derived from this software without */ 00029 /* specific prior written permission of the institution or contributor. */ 00030 /******************************************************************************/ 00031 00032 #include <stdint.h> 00033 #include <stdlib.h> 00034 #include <string.h> 00035 00036 #include "XrdSsi/XrdSsiAtomics.hh" 00037 #include "XrdSsi/XrdSsiErrInfo.hh" 00038 #include "XrdSsi/XrdSsiRespInfo.hh" 00039 00040 //----------------------------------------------------------------------------- 00066 //----------------------------------------------------------------------------- 00067 00068 class XrdSsiResponder; 00069 00070 class XrdSsiRequest 00071 { 00072 public: 00073 friend class XrdSsiResponder; 00074 friend class XrdSsiRRAgent; 00075 00076 //----------------------------------------------------------------------------- 00089 //----------------------------------------------------------------------------- 00090 00091 bool Finished(bool cancel=false); 00092 00093 //----------------------------------------------------------------------------- 00099 //----------------------------------------------------------------------------- 00100 00101 inline uint32_t GetDetachTTL() {return detTTL;} 00102 00103 //----------------------------------------------------------------------------- 00109 //----------------------------------------------------------------------------- 00110 00111 std::string GetEndPoint(); 00112 00113 //----------------------------------------------------------------------------- 00123 //----------------------------------------------------------------------------- 00124 00125 const char *GetMetadata(int &dlen); 00126 00127 //----------------------------------------------------------------------------- 00136 //----------------------------------------------------------------------------- 00137 00138 virtual char *GetRequest(int &dlen) = 0; 00139 00140 //----------------------------------------------------------------------------- 00144 //----------------------------------------------------------------------------- 00145 00146 inline 00147 const char *GetRequestID() {return reqID;} 00148 00149 //----------------------------------------------------------------------------- 00158 //----------------------------------------------------------------------------- 00159 00160 void GetResponseData(char *buff, int blen); 00161 00162 //----------------------------------------------------------------------------- 00166 //----------------------------------------------------------------------------- 00167 00168 uint16_t GetTimeOut() {return tOut;} 00169 00170 //----------------------------------------------------------------------------- 00180 //----------------------------------------------------------------------------- 00181 00182 virtual bool ProcessResponse(const XrdSsiErrInfo &eInfo, 00183 const XrdSsiRespInfo &rInfo)=0; 00184 00185 //----------------------------------------------------------------------------- 00196 //----------------------------------------------------------------------------- 00197 00198 virtual void ProcessResponseData(const XrdSsiErrInfo &eInfo, char *buff, 00199 int blen, bool last) {} 00200 00201 //----------------------------------------------------------------------------- 00205 //----------------------------------------------------------------------------- 00206 00207 void ReleaseRequestBuffer(); 00208 00209 //----------------------------------------------------------------------------- 00218 //----------------------------------------------------------------------------- 00219 00220 XrdSsiRequest(const char *reqid=0, uint16_t tmo=0); 00221 00222 protected: 00223 00224 //----------------------------------------------------------------------------- 00236 //----------------------------------------------------------------------------- 00237 00238 virtual void Alert(XrdSsiRespInfoMsg &aMsg) {aMsg.RecycleMsg(false);} 00239 00240 //----------------------------------------------------------------------------- 00249 //----------------------------------------------------------------------------- 00250 00251 virtual void RelRequestBuffer() {} 00252 00253 //----------------------------------------------------------------------------- 00267 //----------------------------------------------------------------------------- 00268 00269 inline void SetDetachTTL(uint32_t dttl) {detTTL = dttl;} 00270 00271 //----------------------------------------------------------------------------- 00277 //----------------------------------------------------------------------------- 00278 00279 void SetRetry(bool onoff); 00280 00281 //----------------------------------------------------------------------------- 00286 //----------------------------------------------------------------------------- 00287 00288 void SetTimeOut(uint16_t tmo) {tOut = tmo;} 00289 00290 //----------------------------------------------------------------------------- 00295 //----------------------------------------------------------------------------- 00296 00297 virtual ~XrdSsiRequest() {} 00298 00299 private: 00300 virtual void BindDone() {} 00301 void CleanUp(); 00302 bool CopyData(char *buff, int blen); 00303 virtual void Dispose() {} 00304 00305 const char *reqID; 00306 XrdSsiMutex *rrMutex; 00307 XrdSsiResponder *theRespond; // Set via XrdSsiResponder::BindRequest() 00308 XrdSsiRespInfo Resp; // Set via XrdSsiResponder::SetResponse() 00309 XrdSsiErrInfo errInfo; 00310 long long rsvd1; 00311 const char *epNode; 00312 uint32_t detTTL; 00313 uint16_t tOut; 00314 bool onClient; 00315 char flags; 00316 static const int isaRetry = 1; 00317 }; 00318 #endif