#include <XrdSsiRequest.hh>
Classes | |
struct | RDR_Info |
Public Types | |
enum | PRD_Xeq { PRD_Normal = 0, PRD_Hold = 1, PRD_HoldLcl = 2 } |
enum | RDR_How { RDR_All = 0, RDR_Hold, RDR_Immed, RDR_Query, RDR_One, RDR_Post } |
Public Member Functions | |
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 PRD_Xeq | ProcessResponseData (const XrdSsiErrInfo &eInfo, char *buff, int blen, bool last) |
void | ReleaseRequestBuffer () |
XrdSsiRequest (const char *reqid=0, uint16_t tmo=0) | |
Static Public Member Functions | |
static RDR_Info | RestartDataResponse (RDR_How rhow, const char *reqid=0) |
Protected Member Functions | |
virtual void | Alert (XrdSsiRespInfoMsg &aMsg) |
Send or receive a server generated alert. | |
virtual void | RelRequestBuffer () |
void | SetDetachTTL (uint32_t dttl) |
Set the detached request time to live value. | |
void | SetTimeOut (uint16_t tmo) |
virtual | ~XrdSsiRequest () |
Private Member Functions | |
virtual void | BindDone () |
void | CleanUp () |
bool | CopyData (char *buff, int blen) |
virtual void | Dispose () |
Private Attributes | |
const char * | reqID |
XrdSsiMutex * | rrMutex |
XrdSsiResponder * | theRespond |
XrdSsiRespInfo | Resp |
XrdSsiErrInfo | errInfo |
long long | rsvd1 |
const char * | epNode |
uint32_t | detTTL |
uint16_t | tOut |
bool | onClient |
char | rsvd2 |
Friends | |
class | XrdSsiResponder |
class | XrdSsiRRAgent |
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.
eInfo | Error information. You can check if an error occurred using eInfo.hasError() or eInfo.isOK(). | |
buff | Pointer to the buffer given to XrdSsiStream::SetBuff(). | |
blen | The number of bytes in buff or an error indication if blen < 0. | |
last | true This is the last stream segment, no more data remains. | |
false | More data may remain in the stream. |
Restart a ProcessResponseData() call for a request that was previously held (see return enums on ProcessResponseData method). This is a client-side only call and is ignored server-side. When a data response is restarted, ProcessResponseData() is called again when the same parameters as existed when the call resulted in a hold action.
rhow | An enum (see below) that specifies the action to be taken. RDR_All - runs all queued responses and then deletes the queue identified by reqid, unless it is nil. RDR_Hold - sets the allowed restart count to zero and does not restart any queued responses. RDR_Immed - restarts one response if it is queued. The allowed count is left unchanged. RDR_Query - returns information about the queue but otherwise does not restart any queued responses. RDR_One - Sets the allowed restart count to one. If a response is queued, it is restarted and the count is set to zero. RDR_Post - Adds one to the allowed restart count. If a response is queued, it is restarted and one is subtracted from the allowed restart count. | |
reqid | Points to the requestID associated with a hold queue. When not specified, then the global queue is used to restart responses. Note that the memory associated with the named queue may be lost if the queue is left with an allowed value > 0.To avoid this issue the call with RDR_All to clean it up when it is no longer needed (this will avoid having hung responses). |
XrdSsiRequest::XrdSsiRequest | ( | const char * | reqid = 0 , |
|
uint16_t | tmo = 0 | |||
) |
Constructor
reqid | Pointer 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. | |
tmo | The request initiation timeout value 0 equals default). |
virtual XrdSsiRequest::~XrdSsiRequest | ( | ) | [inline, protected, virtual] |
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.
virtual void XrdSsiRequest::Alert | ( | XrdSsiRespInfoMsg & | aMsg | ) | [inline, protected, virtual] |
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.
aMsg | Reference 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.
References XrdSsiRespInfoMsg::RecycleMsg().
Referenced by XrdSsiRRAgent::Alert().
virtual void XrdSsiRequest::BindDone | ( | ) | [inline, private, virtual] |
Reimplemented in XrdSsiFileReq.
void XrdSsiRequest::CleanUp | ( | ) | [private] |
Referenced by XrdSsiRRAgent::CleanUp().
bool XrdSsiRequest::CopyData | ( | char * | buff, | |
int | blen | |||
) | [private] |
virtual void XrdSsiRequest::Dispose | ( | ) | [inline, private, virtual] |
Reimplemented in XrdSsiFileReq.
Referenced by XrdSsiRRAgent::Dispose().
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.
cancel | False -> the request/response sequence completed normally. True -> the request/response sequence aborted because of an error or the client cancelled the request. |
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.
References detTTL.
std::string XrdSsiRequest::GetEndPoint | ( | ) |
Obtain the endpoint host name.
const char* XrdSsiRequest::GetMetadata | ( | int & | dlen | ) |
Obtain the metadata associated with a response.
Note: This method locks the object's recursive mutex.
dlen | holds the length of the metadata after the call. |
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.
dlen | holds the length of the request after the call. |
Implemented in XrdSsiFileReq.
const char* XrdSsiRequest::GetRequestID | ( | ) | [inline] |
Get the request ID established at object creation time.
References reqID.
Referenced by XrdSsiTaskReal::RequestID().
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.
buff | pointer to the buffer to receive the data. The buffer must remain valid until ProcessResponseData() is called. | |
blen | the length of the buffer (i.e. maximum that can be returned). |
uint16_t XrdSsiRequest::GetTimeOut | ( | ) | [inline] |
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.
eInfo | Error information. You can check if an error occurred using eInfo.hasError() or eInfo.isOK(). | |
rInfo | Raw response information. |
Implemented in XrdSsiFileReq.
virtual PRD_Xeq XrdSsiRequest::ProcessResponseData | ( | const XrdSsiErrInfo & | eInfo, | |
char * | buff, | |||
int | blen, | |||
bool | last | |||
) | [inline, virtual] |
References PRD_Normal.
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.
virtual void XrdSsiRequest::RelRequestBuffer | ( | ) | [inline, protected, virtual] |
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.
static RDR_Info XrdSsiRequest::RestartDataResponse | ( | RDR_How | rhow, | |
const char * | reqid = 0 | |||
) | [static] |
void XrdSsiRequest::SetDetachTTL | ( | uint32_t | dttl | ) | [inline, protected] |
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().
detttl | The detach time to live value. |
References detTTL.
void XrdSsiRequest::SetTimeOut | ( | uint16_t | tmo | ) | [inline, protected] |
Set timeout for initiating the request. If a non-default value is desired, it must be set prior to calling XrdSsiService::ProcessRequest().
tmo | The timeout value. |
References tOut.
friend class XrdSsiResponder [friend] |
friend class XrdSsiRRAgent [friend] |
uint32_t XrdSsiRequest::detTTL [private] |
Referenced by GetDetachTTL(), and SetDetachTTL().
const char* XrdSsiRequest::epNode [private] |
Referenced by XrdSsiRRAgent::SetNode().
XrdSsiErrInfo XrdSsiRequest::errInfo [private] |
Referenced by XrdSsiRRAgent::ErrInfoRef().
bool XrdSsiRequest::onClient [private] |
Referenced by XrdSsiRRAgent::onServer().
const char* XrdSsiRequest::reqID [private] |
Reimplemented in XrdSsiFileReq.
Referenced by GetRequestID().
XrdSsiRespInfo XrdSsiRequest::Resp [private] |
Referenced by XrdSsiRRAgent::RespP().
XrdSsiMutex* XrdSsiRequest::rrMutex [private] |
Referenced by XrdSsiRRAgent::SetMutex().
long long XrdSsiRequest::rsvd1 [private] |
char XrdSsiRequest::rsvd2 [private] |
XrdSsiResponder* XrdSsiRequest::theRespond [private] |
uint16_t XrdSsiRequest::tOut [private] |
Referenced by GetTimeOut(), and SetTimeOut().