xrootd
Public Member Functions | Private Member Functions | Private Attributes | List of all members
XrdCl::XRootDMsgHandler Class Reference

Handle/Process/Forward XRootD messages. More...

#include <XrdClXRootDMsgHandler.hh>

Inheritance diagram for XrdCl::XRootDMsgHandler:
Inheritance graph
[legend]
Collaboration diagram for XrdCl::XRootDMsgHandler:
Collaboration graph
[legend]

Public Member Functions

 XRootDMsgHandler (Message *msg, ResponseHandler *respHandler, const URL *url, SIDManager *sidMgr)
 
 ~XRootDMsgHandler ()
 Destructor. More...
 
virtual uint8_t OnIncoming (Message *msg)
 
virtual uint8_t OnStreamEvent (StreamEvent event, uint16_t streamNum, Status status)
 
virtual void OnStatusReady (const Message *message, Status status)
 The requested action has been performed and the status is available. More...
 
void WaitDone (time_t now)
 
void SetExpiration (time_t expiration)
 Set a timestamp after which we give up. More...
 
void SetRedirectAsAnswer (bool redirectAsAnswer)
 
const Message * GetRequest () const
 Get the request pointer. More...
 
void SetLoadBalancer (const HostInfo &loadBalancer)
 Set the load balancer. More...
 
void SetHostList (HostList *hostList)
 Set host list. More...
 
void SetChunkList (ChunkList *chunkList)
 Set the chunk list. More...
 
void SetRedirectCounter (uint16_t redirectCounter)
 Set the redirect coutner. More...
 
- Public Member Functions inherited from XrdCl::IncomingMsgHandler
virtual ~IncomingMsgHandler ()
 Event types that the message handler may receive. More...
 
- Public Member Functions inherited from XrdCl::OutgoingMsgHandler
virtual ~OutgoingMsgHandler ()
 
virtual void OnReadyToSend (Message *msg, uint16_t streamNum)
 

Private Member Functions

void HandleError (Status status, Message *msg=0)
 Recover error. More...
 
Status RetryAtServer (const URL &url)
 Retry the request at another server. More...
 
void HandleResponse ()
 Unpack the message and call the response handler. More...
 
XRootDStatus * ProcessStatus ()
 Extract the status information from the stuff that we got. More...
 
Status ParseResponse (AnyObject *&response)
 
Status RewriteRequestRedirect (const URL::ParamsMap &newCgi)
 
Status RewriteRequestWait ()
 Some requests need to be rewriten also after getting kXR_wait - sigh. More...
 
Status UnpackVectorRead (VectorReadInfo *vReadInfo, ChunkList *list, char *sourceBuffer, uint32_t sourceBufferSize)
 Unpack vector read. More...
 
void UpdateTriedCGI ()
 Update the "tried=" part of the CGI of the current message. More...
 
void SwitchOnRefreshFlag ()
 Switch on the refresh flag for some requests. More...
 

Private Attributes

Message * pRequest
 
Message * pResponse
 
std::vector< Message * > pPartialResps
 
ResponseHandler * pResponseHandler
 
URL pUrl
 
PostMaster * pPostMaster
 
SIDManager * pSidMgr
 
Status pStatus
 
time_t pExpiration
 
bool pRedirectAsAnswer
 
HostList * pHosts
 
bool pHasLoadBalancer
 
HostInfo pLoadBalancer
 
bool pHasSessionId
 
std::string pRedirectCgi
 
ChunkList * pChunkList
 
uint16_t pRedirectCounter
 

Additional Inherited Members

- Public Types inherited from XrdCl::IncomingMsgHandler
enum  Action { Take = 0x01, Ignore = 0x02, RemoveHandler = 0x04 }
 Actions to be taken after a message is processed by the handler. More...
 
enum  StreamEvent { Ready = 1, Broken = 2, Timeout = 3, FatalError = 4 }
 Events that may have occured to the stream. More...
 

Detailed Description

Handle/Process/Forward XRootD messages.

Constructor & Destructor Documentation

XrdCl::XRootDMsgHandler::XRootDMsgHandler ( Message *  msg,
ResponseHandler *  respHandler,
const URL *  url,
SIDManager *  sidMgr 
)
inline

Constructor

Parameters
msgmessage that has been sent out
respHandlerresponse handler to be called then the final final response arrives
urlthe url the message has been sent to
sidMgrthe sid manager used to allocate SID for the initial message

References XrdCl::DefaultEnv::GetPostMaster(), XrdCl::Message::GetSessionId(), pHasSessionId, and pPostMaster.

XrdCl::XRootDMsgHandler::~XRootDMsgHandler ( )
inline

Destructor.

References pHasSessionId, pPartialResps, pRequest, and pResponse.

Member Function Documentation

const Message* XrdCl::XRootDMsgHandler::GetRequest ( ) const
inline

Get the request pointer.

References pRequest.

void XrdCl::XRootDMsgHandler::HandleError ( Status  status,
Message *  msg = 0 
)
private
void XrdCl::XRootDMsgHandler::HandleResponse ( )
private
uint8_t XrdCl::XRootDMsgHandler::OnIncoming ( Message *  msg)
virtual

Examine an incomming message, and decide on the action to be taken

Parameters
msgthe message, may be zero if receive failed
Returns
action type that needs to be take wrt the message and the handler

Implements XrdCl::IncomingMsgHandler.

References ServerResponseBody_Attn::actnum, XrdCl::Buffer::Append(), ServerResponse::attn, ServerResponse::body, ServerResponseHeader::dlen, XrdCl::Log::Dump(), XrdCl::errErrorResponse, XrdCl::errInvalidRedirectURL, XrdCl::errInvalidResponse, ServerResponseBody_Error::errmsg, ServerResponseBody_Error::errnum, XrdCl::Log::Error(), ServerResponse::error, XrdCl::errRedirectLimit, XrdCl::AnyObject::Get(), XrdCl::Buffer::GetBuffer(), XrdCl::Message::GetDescription(), XrdCl::URL::GetHostId(), XrdCl::DefaultEnv::GetLog(), XrdCl::URL::GetParams(), XrdCl::PostMaster::GetTaskManager(), HandleError(), HandleResponse(), ServerResponse::hdr, ClientRequest::header, ServerResponseBody_Redirect::host, XrdCl::IncomingMsgHandler::Ignore, ServerResponseBody_Wait::infomsg, XrdCl::Status::IsOK(), XrdCl::URL::IsValid(), kXR_asynresp, kXR_attn, kXR_attrMeta, kXR_error, kXR_isManager, kXR_ok, kXR_oksofar, kXR_redirect, kXR_wait, kXR_waitresp, pHasLoadBalancer, pHosts, pLoadBalancer, ServerResponseBody_Redirect::port, pPartialResps, pPostMaster, pRedirectAsAnswer, pRedirectCgi, pRedirectCounter, pRequest, pResponse, XrdCl::XRootDQuery::ProtocolVersion, pStatus, pUrl, XrdCl::PostMaster::QueryTransport(), ServerResponse::redirect, XrdCl::TaskManager::RegisterTask(), XrdCl::IncomingMsgHandler::RemoveHandler, ClientRequestHdr::requestid, RetryAtServer(), RewriteRequestRedirect(), RewriteRequestWait(), ServerResponseBody_Wait::seconds, ServerResponseBody_Waitresp::seconds, XrdCl::XRootDQuery::ServerFlags, XrdCl::Utils::splitString(), ServerResponseHeader::status, XrdCl::stError, XrdCl::stFatal, XrdCl::stOK, ClientRequestHdr::streamid, ServerResponseHeader::streamid, XrdCl::suXRDRedirect, XrdCl::IncomingMsgHandler::Take, XrdCl::XRootDTransport::UnMarshallBody(), XrdCl::XRootDTransport::UnMarshallHeader(), XrdCl::HostInfo::url, ServerResponse::wait, ServerResponse::waitresp, and XrdCl::XRootDMsg.

void XrdCl::XRootDMsgHandler::OnStatusReady ( const Message *  message,
Status  status 
)
virtual
uint8_t XrdCl::XRootDMsgHandler::OnStreamEvent ( StreamEvent  event,
uint16_t  streamNum,
Status  status 
)
virtual

Handle an event other that a message arrival

Parameters
eventtype of the event
streamNumstream concerned
statusstatus info

Reimplemented from XrdCl::IncomingMsgHandler.

References XrdCl::Log::Dump(), XrdCl::Message::GetDescription(), XrdCl::URL::GetHostId(), XrdCl::DefaultEnv::GetLog(), HandleError(), pRequest, pUrl, XrdCl::IncomingMsgHandler::Ready, XrdCl::IncomingMsgHandler::RemoveHandler, and XrdCl::XRootDMsg.

Status XrdCl::XRootDMsgHandler::ParseResponse ( AnyObject *&  response)
private
XRootDStatus * XrdCl::XRootDMsgHandler::ProcessStatus ( )
private
Status XrdCl::XRootDMsgHandler::RetryAtServer ( const URL &  url)
private

Retry the request at another server.

References pExpiration, pHosts, pPostMaster, pRequest, pUrl, and XrdCl::PostMaster::Send().

Referenced by HandleError(), OnIncoming(), and WaitDone().

Status XrdCl::XRootDMsgHandler::RewriteRequestRedirect ( const URL::ParamsMap &  newCgi)
private
Status XrdCl::XRootDMsgHandler::RewriteRequestWait ( )
private
void XrdCl::XRootDMsgHandler::SetChunkList ( ChunkList *  chunkList)
inline

Set the chunk list.

References pChunkList.

Referenced by XrdCl::MessageUtils::SendMessage().

void XrdCl::XRootDMsgHandler::SetExpiration ( time_t  expiration)
inline

Set a timestamp after which we give up.

References pExpiration.

Referenced by XrdCl::MessageUtils::SendMessage().

void XrdCl::XRootDMsgHandler::SetHostList ( HostList *  hostList)
inline

Set host list.

References pHosts.

Referenced by XrdCl::MessageUtils::SendMessage().

void XrdCl::XRootDMsgHandler::SetLoadBalancer ( const HostInfo &  loadBalancer)
inline
void XrdCl::XRootDMsgHandler::SetRedirectAsAnswer ( bool  redirectAsAnswer)
inline

Treat the kXR_redirect response as a valid answer to the message and notify the handler with the URL as a response

References pRedirectAsAnswer.

Referenced by XrdCl::MessageUtils::SendMessage().

void XrdCl::XRootDMsgHandler::SetRedirectCounter ( uint16_t  redirectCounter)
inline

Set the redirect coutner.

References pRedirectCounter.

Referenced by XrdCl::MessageUtils::SendMessage().

void XrdCl::XRootDMsgHandler::SwitchOnRefreshFlag ( )
private
Status XrdCl::XRootDMsgHandler::UnpackVectorRead ( VectorReadInfo *  vReadInfo,
ChunkList *  list,
char *  sourceBuffer,
uint32_t  sourceBufferSize 
)
private
void XrdCl::XRootDMsgHandler::UpdateTriedCGI ( )
private
void XrdCl::XRootDMsgHandler::WaitDone ( time_t  now)

Called after the wait time for kXR_wait has elapsed

Parameters
nowcurrent timestamp

References HandleError(), pUrl, and RetryAtServer().

Member Data Documentation

ChunkList* XrdCl::XRootDMsgHandler::pChunkList
private

Referenced by ParseResponse(), and SetChunkList().

time_t XrdCl::XRootDMsgHandler::pExpiration
private
bool XrdCl::XRootDMsgHandler::pHasLoadBalancer
private

Referenced by OnIncoming(), and SetLoadBalancer().

bool XrdCl::XRootDMsgHandler::pHasSessionId
private
HostList* XrdCl::XRootDMsgHandler::pHosts
private
HostInfo XrdCl::XRootDMsgHandler::pLoadBalancer
private
std::vector<Message *> XrdCl::XRootDMsgHandler::pPartialResps
private
PostMaster* XrdCl::XRootDMsgHandler::pPostMaster
private
bool XrdCl::XRootDMsgHandler::pRedirectAsAnswer
private
std::string XrdCl::XRootDMsgHandler::pRedirectCgi
private

Referenced by OnIncoming(), and ParseResponse().

uint16_t XrdCl::XRootDMsgHandler::pRedirectCounter
private

Referenced by OnIncoming(), and SetRedirectCounter().

Message* XrdCl::XRootDMsgHandler::pRequest
private
Message* XrdCl::XRootDMsgHandler::pResponse
private
ResponseHandler* XrdCl::XRootDMsgHandler::pResponseHandler
private

Referenced by HandleResponse().

SIDManager* XrdCl::XRootDMsgHandler::pSidMgr
private
Status XrdCl::XRootDMsgHandler::pStatus
private
URL XrdCl::XRootDMsgHandler::pUrl
private

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