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 //----------------------------------------------------------------------------- 00206 //----------------------------------------------------------------------------- 00207 00208 enum PRD_Xeq {PRD_Normal = 0, PRD_Hold = 1, PRD_HoldLcl = 2}; 00209 00210 virtual PRD_Xeq ProcessResponseData(const XrdSsiErrInfo &eInfo, char *buff, 00211 int blen, bool last) {return PRD_Normal;} 00212 00213 //----------------------------------------------------------------------------- 00217 //----------------------------------------------------------------------------- 00218 00219 void ReleaseRequestBuffer(); 00220 00221 //----------------------------------------------------------------------------- 00252 //----------------------------------------------------------------------------- 00253 00254 enum RDR_How {RDR_All=0, RDR_Hold, RDR_Immed, RDR_Query, RDR_One, RDR_Post}; 00255 00256 struct RDR_Info{int rCount; 00257 int qCount; 00258 int iAllow; 00259 int fAllow; 00260 00261 RDR_Info() : rCount(0), qCount(0), iAllow(0), fAllow(0) {} 00262 }; 00263 00264 static RDR_Info RestartDataResponse(RDR_How rhow, const char *reqid=0); 00265 00266 //----------------------------------------------------------------------------- 00275 //----------------------------------------------------------------------------- 00276 00277 XrdSsiRequest(const char *reqid=0, uint16_t tmo=0); 00278 00279 protected: 00280 00281 //----------------------------------------------------------------------------- 00293 //----------------------------------------------------------------------------- 00294 00295 virtual void Alert(XrdSsiRespInfoMsg &aMsg) {aMsg.RecycleMsg(false);} 00296 00297 //----------------------------------------------------------------------------- 00306 //----------------------------------------------------------------------------- 00307 00308 virtual void RelRequestBuffer() {} 00309 00310 //----------------------------------------------------------------------------- 00324 //----------------------------------------------------------------------------- 00325 00326 inline void SetDetachTTL(uint32_t dttl) {detTTL = dttl;} 00327 00328 //----------------------------------------------------------------------------- 00333 //----------------------------------------------------------------------------- 00334 00335 void SetTimeOut(uint16_t tmo) {tOut = tmo;} 00336 00337 //----------------------------------------------------------------------------- 00342 //----------------------------------------------------------------------------- 00343 00344 virtual ~XrdSsiRequest() {} 00345 00346 private: 00347 virtual void BindDone() {} 00348 void CleanUp(); 00349 bool CopyData(char *buff, int blen); 00350 virtual void Dispose() {} 00351 00352 const char *reqID; 00353 XrdSsiMutex *rrMutex; 00354 XrdSsiResponder *theRespond; // Set via XrdSsiResponder::BindRequest() 00355 XrdSsiRespInfo Resp; // Set via XrdSsiResponder::SetResponse() 00356 XrdSsiErrInfo errInfo; 00357 long long rsvd1; 00358 const char *epNode; 00359 uint32_t detTTL; 00360 uint16_t tOut; 00361 bool onClient; 00362 char rsvd2; 00363 }; 00364 #endif