XRootD
XrdSsiRequest Class Referenceabstract

#include <XrdSsiRequest.hh>

+ Inheritance diagram for XrdSsiRequest:
+ Collaboration diagram for XrdSsiRequest:

Public Member Functions

 XrdSsiRequest (const char *reqid=0, uint16_t tmo=0)
 
bool Finished (bool cancel=false)
 
uint32_t GetDetachTTL ()
 
std::string GetEndPoint ()
 
const char * GetMetadata (int &dlen)
 
virtual char * GetRequest (int &dlen)=0
 
const char * GetRequestID ()
 
void GetResponseData (char *buff, int blen)
 
uint16_t GetTimeOut ()
 
virtual bool ProcessResponse (const XrdSsiErrInfo &eInfo, const XrdSsiRespInfo &rInfo)=0
 
virtual void ProcessResponseData (const XrdSsiErrInfo &eInfo, char *buff, int blen, bool last)
 
void ReleaseRequestBuffer ()
 

Protected Member Functions

virtual ~XrdSsiRequest ()
 
virtual void Alert (XrdSsiRespInfoMsg &aMsg)
 Send or receive a server generated alert. More...
 
virtual void RelRequestBuffer ()
 
void SetDetachTTL (uint32_t dttl)
 Set the detached request time to live value. More...
 
void SetRetry (bool onoff)
 
void SetTimeOut (uint16_t tmo)
 

Friends

class XrdSsiResponder
 
class XrdSsiRRAgent
 

Detailed Description

Definition at line 70 of file XrdSsiRequest.hh.

Constructor & Destructor Documentation

◆ XrdSsiRequest()

XrdSsiRequest::XrdSsiRequest ( const char *  reqid = 0,
uint16_t  tmo = 0 
)

Constructor

Parameters
reqidPointer to a request ID that can be used to group requests. See ProcessResponseData() and RestartDataReponse(). If reqid is nil then held responses are placed in the global queue. The pointer must be valid for the life of this object.
tmoThe request initiation timeout value 0 equals default).

Definition at line 56 of file XrdSsiRequest.cc.

57  : reqID(reqid), rrMutex(&XrdSsi::ubMutex),
58  theRespond(0), rsvd1(0), epNode(0),
59  detTTL(0), tOut(0), onClient(true), flags(0) {}
XrdSsiMutex ubMutex(XrdSsiMutex::Recursive)

◆ ~XrdSsiRequest()

virtual XrdSsiRequest::~XrdSsiRequest ( )
inlineprotectedvirtual

Destructor. This object can only be deleted by the object creator. Once the object is passed to XrdSsiService::ProcessRequest() it may only be deleted after Finished() is called to allow the service to reclaim any resources allocated for the request object.

Definition at line 297 of file XrdSsiRequest.hh.

297 {}

Member Function Documentation

◆ Alert()

virtual void XrdSsiRequest::Alert ( XrdSsiRespInfoMsg aMsg)
inlineprotectedvirtual

Send or receive a server generated alert.

The Alert() method is used server-side to send one or more alerts before a response is posted (alerts afterwards are ignored). To avoid race conditions, server-side alerts should be sent via the Responder's Alert() method. Clients must implement this method in order to receive alerts.

Parameters
aMsgReference to the message object containing the alert message. Non-positive alert lengths cause the alert call to be ignored. You should call the message RecycleMsg() method once you have consumed the message to release its resources.

Reimplemented in XrdSsiFileReq.

Definition at line 238 of file XrdSsiRequest.hh.

238 {aMsg.RecycleMsg(false);}
virtual void RecycleMsg(bool sent=true)=0

References XrdSsiRespInfoMsg::RecycleMsg().

Referenced by XrdSsiRRAgent::Alert(), and XrdSsiResponder::Alert().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Finished()

bool XrdSsiRequest::Finished ( bool  cancel = false)

Indicate that request processing has been finished. This method calls XrdSsiResponder::Finished() on the associated responder object.

Note: This method locks the object's recursive mutex.

Parameters
cancelFalse -> the request/response sequence completed normally. True -> the request/response sequence aborted because of an error or the client cancelled the request.
Returns
true Finish accepted. Request object may be reclaimed.
false Finish cannot be accepted because this request object is not bound to a responder. This indicates a logic error.

Definition at line 115 of file XrdSsiRequest.cc.

116 {
117  XrdSsiResponder *respP;
118 
119 // Obtain the responder
120 //
121  rrMutex->Lock();
122  respP = theRespond;
123  theRespond = 0;
124  rrMutex->UnLock();
125 
126 // Tell any responder we are finished (we might not have one)
127 //
128  if (respP) respP->Finished(*this, Resp, cancel);
129 
130 // We are done. The object will be reiniialized when UnBindRequest() is
131 // called which will call UnBind() in this object. Since the timing is not
132 // known we can't touch anthing in this object at this point.
133 // Return false if there was no responder associated with this request.
134 //
135  return respP != 0;
136 }
virtual void Finished(XrdSsiRequest &rqstR, const XrdSsiRespInfo &rInfo, bool cancel=false)=0

References XrdSsiResponder::Finished(), XrdSsiMutex::Lock(), and XrdSsiMutex::UnLock().

+ Here is the call graph for this function:

◆ GetDetachTTL()

uint32_t XrdSsiRequest::GetDetachTTL ( )
inline

Obtain the detached request time to live value. If the value is non-zero, the request is detached. Otherwise, it is an attached request and requires a live TCP connection during it execution.

Returns
The detached time to live value in seconds.

Definition at line 101 of file XrdSsiRequest.hh.

101 {return detTTL;}

◆ GetEndPoint()

std::string XrdSsiRequest::GetEndPoint ( )

Obtain the endpoint host name.

Returns
A string containing the endpoint host name. If a null string is returned, the endpoint has not yet been determined. Generally, the endpoint is available on the first callback to this object.

Definition at line 142 of file XrdSsiRequest.cc.

143 {
144  XrdSsiMutexMon lck(rrMutex);
145  std::string epName(epNode ? epNode : "");
146  return epName;
147 }

◆ GetMetadata()

const char * XrdSsiRequest::GetMetadata ( int &  dlen)

Obtain the metadata associated with a response.

Note: This method locks the object's recursive mutex.

Parameters
dlenholds the length of the metadata after the call.
Returns
=0 No metadata available, dlen has been set to zero.
!0 Pointer to the buffer holding the metadata, dlen has the length

Definition at line 153 of file XrdSsiRequest.cc.

154 {
155  XrdSsiMutexMon lck(rrMutex);
156  if ((dlen = Resp.mdlen)) return Resp.mdata;
157  return 0;
158 }
int mdlen
Metadata length.
const char * mdata
-> Metadata about response.

References XrdSsiRespInfo::mdata, and XrdSsiRespInfo::mdlen.

◆ GetRequest()

virtual char* XrdSsiRequest::GetRequest ( int &  dlen)
pure virtual

Obtain the request data sent by a client.

This method is duplicated in XrdSsiResponder to allow calling consistency.

Parameters
dlenholds the length of the request after the call.
Returns
=0 No request data available, dlen has been set to zero.
!0 Pointer to the buffer holding the request, dlen has the length

Implemented in XrdSsiFileReq.

Referenced by XrdSsiResponder::GetRequest(), and XrdSsiTaskReal::SendRequest().

+ Here is the caller graph for this function:

◆ GetRequestID()

const char* XrdSsiRequest::GetRequestID ( )
inline

Get the request ID established at object creation time.

Returns
Pointer to the request ID or nil if there is none.

Definition at line 147 of file XrdSsiRequest.hh.

147 {return reqID;}

Referenced by XrdSsiTaskReal::RequestID().

+ Here is the caller graph for this function:

◆ GetResponseData()

void XrdSsiRequest::GetResponseData ( char *  buff,
int  blen 
)

Asynchronously obtain response data. This is a helper method that allows a client to deal with a passive stream response. This method also handles data response, albeit inefficiently by copying the data response. However, this allows for uniform response processing regardless of response type.

Parameters
buffpointer to the buffer to receive the data. The buffer must remain valid until ProcessResponseData() is called.
blenthe length of the buffer (i.e. maximum that can be returned).

Definition at line 164 of file XrdSsiRequest.cc.

165 {
166  XrdSsiMutexMon mHelper(rrMutex);
167 
168 // If this is really a stream then just call the stream object to get the data.
169 // In the degenrate case, it's actually a data response, then we must copy it.
170 //
171  if (Resp.rType == XrdSsiRespInfo::isStream)
172  {if (Resp.strmP->SetBuff(errInfo, buff, blen)) return;}
173  else if (Resp.rType == XrdSsiRespInfo::isData)
174  {if (CopyData(buff, blen)) return;}
175  else errInfo.Set("Not a stream", ENODATA);
176 
177 // If we got here then an error occurred during the setup, reflect the error
178 // via the callback (in the future we will schedule a new thread).
179 //
180  ProcessResponseData(errInfo, buff, -1, true);
181 }
#define ENODATA
void Set(const char *eMsg=0, int eNum=0, int eArg=0)
virtual void ProcessResponseData(const XrdSsiErrInfo &eInfo, char *buff, int blen, bool last)

References ENODATA, XrdSsiRespInfo::isData, XrdSsiRespInfo::isStream, ProcessResponseData(), XrdSsiRespInfo::rType, and XrdSsiErrInfo::Set().

+ Here is the call graph for this function:

◆ GetTimeOut()

uint16_t XrdSsiRequest::GetTimeOut ( )
inline

Get timeout for initiating the request.

Returns
The timeout value.

Definition at line 168 of file XrdSsiRequest.hh.

168 {return tOut;}

Referenced by XrdSsiSessReal::Provision().

+ Here is the caller graph for this function:

◆ ProcessResponse()

virtual bool XrdSsiRequest::ProcessResponse ( const XrdSsiErrInfo eInfo,
const XrdSsiRespInfo rInfo 
)
pure virtual

Notify request that a response is ready to be processed. This method must be supplied by the request object's implementation.

Parameters
eInfoError information. You can check if an error occurred using eInfo.hasError() or eInfo.isOK().
rInfoRaw response information.
Returns
true Response processed.
false Response could not be processed, the request is not active.

Implemented in XrdSsiFileReq.

◆ ProcessResponseData()

virtual void XrdSsiRequest::ProcessResponseData ( const XrdSsiErrInfo eInfo,
char *  buff,
int  blen,
bool  last 
)
inlinevirtual

Handle incoming async stream data or error. This method is called by a stream object after a successful GetResponseData() or an asynchronous stream SetBuff() call.

Parameters
eInfoError information. You can check if an error occurred using eInfo.hasError() or eInfo.isOK().
buffPointer to the buffer given to XrdSsiStream::SetBuff().
blenThe number of bytes in buff or an error indication if blen < 0.
lasttrue This is the last stream segment, no more data remains. false More data may remain in the stream.

Definition at line 198 of file XrdSsiRequest.hh.

199  {}

Referenced by GetResponseData().

+ Here is the caller graph for this function:

◆ ReleaseRequestBuffer()

void XrdSsiRequest::ReleaseRequestBuffer ( )

Release the request buffer of the request bound to this object. This method duplicates the protected method RelRequestBuffer() and exists here for calling safety and consistency relative to the responder.

Definition at line 187 of file XrdSsiRequest.cc.

188 {
189  XrdSsiMutexMon lck(rrMutex);
191 }
virtual void RelRequestBuffer()

References RelRequestBuffer().

Referenced by XrdSsiResponder::ReleaseRequestBuffer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RelRequestBuffer()

virtual void XrdSsiRequest::RelRequestBuffer ( )
inlineprotectedvirtual

Release the request buffer. Use this method to optimize storage use; this is especially relevant for long-running requests. If the request buffer has been consumed and is no longer needed, early return of the buffer will minimize memory usage. This method is also invoked via XrdSsiResponder.

Note: This method is called with the object's recursive mutex locked when it is invoked via XrdSsiResponder's ReleaseRequestBuffer().

Reimplemented in XrdSsiFileReq.

Definition at line 251 of file XrdSsiRequest.hh.

251 {}

Referenced by ReleaseRequestBuffer().

+ Here is the caller graph for this function:

◆ SetDetachTTL()

void XrdSsiRequest::SetDetachTTL ( uint32_t  dttl)
inlineprotected

Set the detached request time to live value.

By default, requests are executed in the foreground (i.e. during its execution, if the TCP connection drops, the request is automatically cancelled. When a non-zero time to live is set, the request is executed in the background (i.e. detached) and no persistent TCP connection is required. You must use the XrdSsiService::Attach() method to foreground such a request within the number of seconds specified for dttl or the request is automatically cancelled. The value must be set before passing the request to XrdSsiService::ProcessRequest(). Once the request is started, a request handle is returned which can be passed to XrdSsiService::Attach().

Parameters
dttlThe detach time to live value.

Definition at line 269 of file XrdSsiRequest.hh.

269 {detTTL = dttl;}

◆ SetRetry()

void XrdSsiRequest::SetRetry ( bool  onoff)
protected

Set request retry notification. If a non-default value is desired, it must be set prior to calling XrdSsiService::ProcessRequest(). This is a one-time request and retry mode is turned off in the request object afterwards.

Parameters
onoffTrue to turn retry on and false to turn it off.

Definition at line 197 of file XrdSsiRequest.cc.

198 {
199 
200 // Set flag as needed
201 //
202 if (onoff) flags |= isaRetry;
203  else flags &= ~isaRetry;
204 }

◆ SetTimeOut()

void XrdSsiRequest::SetTimeOut ( uint16_t  tmo)
inlineprotected

Set timeout for initiating the request. If a non-default value is desired, it must be set prior to calling XrdSsiService::ProcessRequest().

Parameters
tmoThe timeout value.

Definition at line 288 of file XrdSsiRequest.hh.

288 {tOut = tmo;}

Friends And Related Function Documentation

◆ XrdSsiResponder

friend class XrdSsiResponder
friend

Definition at line 73 of file XrdSsiRequest.hh.

◆ XrdSsiRRAgent

friend class XrdSsiRRAgent
friend

Definition at line 74 of file XrdSsiRequest.hh.


The documentation for this class was generated from the following files: