XRootD
XrdSsiRequest.hh
Go to the documentation of this file.
1 #ifndef __XRDSSIREQUEST_HH__
2 #define __XRDSSIREQUEST_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d S s i R e q u e s t . h h */
6 /* */
7 /* (c) 2013 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* Produced by Andrew Hanushevsky for Stanford University under contract */
9 /* DE-AC02-76-SFO0515 with the Department of Energy */
10 /* */
11 /* This file is part of the XRootD software suite. */
12 /* */
13 /* XRootD is free software: you can redistribute it and/or modify it under */
14 /* the terms of the GNU Lesser General Public License as published by the */
15 /* Free Software Foundation, either version 3 of the License, or (at your */
16 /* option) any later version. */
17 /* */
18 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21 /* License for more details. */
22 /* */
23 /* You should have received a copy of the GNU Lesser General Public License */
24 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26 /* */
27 /* The copyright holder's institutional names and contributor's names may not */
28 /* be used to endorse or promote products derived from this software without */
29 /* specific prior written permission of the institution or contributor. */
30 /******************************************************************************/
31 
32 #include <cstdint>
33 #include <cstdlib>
34 #include <cstring>
35 
36 #include "XrdSsi/XrdSsiAtomics.hh"
37 #include "XrdSsi/XrdSsiErrInfo.hh"
38 #include "XrdSsi/XrdSsiRespInfo.hh"
39 
40 //-----------------------------------------------------------------------------
66 //-----------------------------------------------------------------------------
67 
68 class XrdSsiResponder;
69 
71 {
72 public:
73 friend class XrdSsiResponder;
74 friend class XrdSsiRRAgent;
75 
76 //-----------------------------------------------------------------------------
89 //-----------------------------------------------------------------------------
90 
91  bool Finished(bool cancel=false);
92 
93 //-----------------------------------------------------------------------------
99 //-----------------------------------------------------------------------------
100 
101 inline uint32_t GetDetachTTL() {return detTTL;}
102 
103 //-----------------------------------------------------------------------------
109 //-----------------------------------------------------------------------------
110 
111 std::string GetEndPoint();
112 
113 //-----------------------------------------------------------------------------
123 //-----------------------------------------------------------------------------
124 
125 const char *GetMetadata(int &dlen);
126 
127 //-----------------------------------------------------------------------------
136 //-----------------------------------------------------------------------------
137 
138 virtual char *GetRequest(int &dlen) = 0;
139 
140 //-----------------------------------------------------------------------------
144 //-----------------------------------------------------------------------------
145 
146 inline
147 const char *GetRequestID() {return reqID;}
148 
149 //-----------------------------------------------------------------------------
158 //-----------------------------------------------------------------------------
159 
160  void GetResponseData(char *buff, int blen);
161 
162 //-----------------------------------------------------------------------------
166 //-----------------------------------------------------------------------------
167 
168  uint16_t GetTimeOut() {return tOut;}
169 
170 //-----------------------------------------------------------------------------
180 //-----------------------------------------------------------------------------
181 
182 virtual bool ProcessResponse(const XrdSsiErrInfo &eInfo,
183  const XrdSsiRespInfo &rInfo)=0;
184 
185 //-----------------------------------------------------------------------------
196 //-----------------------------------------------------------------------------
197 
198 virtual void ProcessResponseData(const XrdSsiErrInfo &eInfo, char *buff,
199  int blen, bool last) {}
200 
201 //-----------------------------------------------------------------------------
205 //-----------------------------------------------------------------------------
206 
207  void ReleaseRequestBuffer();
208 
209 //-----------------------------------------------------------------------------
218 //-----------------------------------------------------------------------------
219 
220  XrdSsiRequest(const char *reqid=0, uint16_t tmo=0);
221 
222 protected:
223 
224 //-----------------------------------------------------------------------------
236 //-----------------------------------------------------------------------------
237 
238 virtual void Alert(XrdSsiRespInfoMsg &aMsg) {aMsg.RecycleMsg(false);}
239 
240 //-----------------------------------------------------------------------------
249 //-----------------------------------------------------------------------------
250 
251 virtual void RelRequestBuffer() {}
252 
253 //-----------------------------------------------------------------------------
267 //-----------------------------------------------------------------------------
268 
269 inline void SetDetachTTL(uint32_t dttl) {detTTL = dttl;}
270 
271 //-----------------------------------------------------------------------------
277 //-----------------------------------------------------------------------------
278 
279  void SetRetry(bool onoff);
280 
281 //-----------------------------------------------------------------------------
286 //-----------------------------------------------------------------------------
287 
288  void SetTimeOut(uint16_t tmo) {tOut = tmo;}
289 
290 //-----------------------------------------------------------------------------
295 //-----------------------------------------------------------------------------
296 
297 virtual ~XrdSsiRequest() {}
298 
299 private:
300 virtual void BindDone() {}
301  void CleanUp();
302  bool CopyData(char *buff, int blen);
303 virtual void Dispose() {}
304 
305 const char *reqID;
306 XrdSsiMutex *rrMutex;
307 XrdSsiResponder *theRespond; // Set via XrdSsiResponder::BindRequest()
308 XrdSsiRespInfo Resp; // Set via XrdSsiResponder::SetResponse()
309 XrdSsiErrInfo errInfo;
310 long long rsvd1;
311 const char *epNode;
312 uint32_t detTTL;
313 uint16_t tOut;
314 bool onClient;
315 char flags;
316 static const int isaRetry = 1;
317 };
318 #endif
static void Dispose(XrdSsiRequest &reqR)
static bool isaRetry(XrdSsiRequest *rP, bool reset=false)
static void CleanUp(XrdSsiRequest &reqR)
std::string GetEndPoint()
virtual ~XrdSsiRequest()
uint16_t GetTimeOut()
const char * GetMetadata(int &dlen)
bool Finished(bool cancel=false)
XrdSsiRequest(const char *reqid=0, uint16_t tmo=0)
const char * GetRequestID()
virtual bool ProcessResponse(const XrdSsiErrInfo &eInfo, const XrdSsiRespInfo &rInfo)=0
virtual void RelRequestBuffer()
virtual void Alert(XrdSsiRespInfoMsg &aMsg)
Send or receive a server generated alert.
void ReleaseRequestBuffer()
void SetDetachTTL(uint32_t dttl)
Set the detached request time to live value.
void SetRetry(bool onoff)
virtual void ProcessResponseData(const XrdSsiErrInfo &eInfo, char *buff, int blen, bool last)
void SetTimeOut(uint16_t tmo)
void GetResponseData(char *buff, int blen)
uint32_t GetDetachTTL()
virtual char * GetRequest(int &dlen)=0
virtual void RecycleMsg(bool sent=true)=0