xrootd
Classes | Public Member Functions | Private Member Functions | Private Attributes
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]

List of all members.

Classes

struct  ChunkStatus

Public Member Functions

 XRootDMsgHandler (Message *msg, ResponseHandler *respHandler, const URL *url, SIDManager *sidMgr)
 ~XRootDMsgHandler ()
 Destructor.
virtual uint16_t Examine (Message *msg)
virtual void Process (Message *msg)
 Process the message if it was "taken" by the examine action.
virtual Status ReadMessageBody (Message *msg, int socket, uint32_t &bytesRead)
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.
virtual bool IsRaw () const
 Are we a raw writer or not?
virtual Status WriteMessageBody (int socket, uint32_t &bytesRead)
void WaitDone (time_t now)
void SetExpiration (time_t expiration)
 Set a timestamp after which we give up.
void SetRedirectAsAnswer (bool redirectAsAnswer)
const Message * GetRequest () const
 Get the request pointer.
void SetLoadBalancer (const HostInfo &loadBalancer)
 Set the load balancer.
void SetHostList (HostList *hostList)
 Set host list.
void SetChunkList (ChunkList *chunkList)
 Set the chunk list.
void SetRedirectCounter (uint16_t redirectCounter)
 Set the redirect counter.
- Public Member Functions inherited from XrdCl::IncomingMsgHandler
virtual ~IncomingMsgHandler ()
 Event types that the message handler may receive.
- Public Member Functions inherited from XrdCl::OutgoingMsgHandler
virtual ~OutgoingMsgHandler ()
virtual void OnReadyToSend (Message *msg, uint16_t streamNum)

Private Member Functions

Status ReadRawRead (Message *msg, int socket, uint32_t &bytesRead)
 Handle a kXR_read in raw mode.
Status ReadRawReadV (Message *msg, int socket, uint32_t &bytesRead)
 Handle a kXR_readv in raw mode.
Status ReadRawOther (Message *msg, int socket, uint32_t &bytesRead)
 Handle anything other than kXR_read and kXR_readv in raw mode.
Status ReadAsync (int socket, uint32_t &btesRead)
void HandleError (Status status, Message *msg=0)
 Recover error.
Status RetryAtServer (const URL &url)
 Retry the request at another server.
void HandleResponse ()
 Unpack the message and call the response handler.
XRootDStatus * ProcessStatus ()
 Extract the status information from the stuff that we got.
Status ParseResponse (AnyObject *&response)
Status RewriteRequestRedirect (const URL::ParamsMap &newCgi)
Status RewriteRequestWait ()
 Some requests need to be rewritten also after getting kXR_wait - sigh.
Status PostProcessReadV (VectorReadInfo *vReadInfo)
 Post process vector read.
Status UnPackReadVResponse (Message *msg)
 Unpack a single readv response.
void UpdateTriedCGI ()
 Update the "tried=" part of the CGI of the current message.
void SwitchOnRefreshFlag ()
 Switch on the refresh flag for some requests.

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
std::vector< ChunkStatus > pChunkStatus
uint16_t pRedirectCounter
uint32_t pAsyncOffset
uint32_t pAsyncReadSize
char * pAsyncReadBuffer
uint32_t pAsyncMsgSize
bool pReadRawStarted
uint32_t pReadRawCurrentOffset
uint32_t pReadVRawMsgOffset
bool pReadVRawChunkHeaderDone
bool pReadVRawChunkHeaderStarted
bool pReadVRawSizeError
int32_t pReadVRawChunkIndex
readahead_list pReadVRawChunkHeader
bool pReadVRawMsgDiscard
bool pOtherRawStarted

Additional Inherited Members

- Public Types inherited from XrdCl::IncomingMsgHandler
enum  Action {
  Take = 0x0001, Ignore = 0x0002, RemoveHandler = 0x0004, Raw = 0x0008,
  NoProcess = 0x0010
}
 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 occurred 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, pPostMaster, and pReadVRawChunkHeader.

XrdCl::XRootDMsgHandler::~XRootDMsgHandler ( )
inline

Destructor.

References pHasSessionId, pPartialResps, pRequest, and pResponse.


Member Function Documentation

uint16_t XrdCl::XRootDMsgHandler::Examine ( Message *  msg)
virtual
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
bool XrdCl::XRootDMsgHandler::IsRaw ( ) const
virtual
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
Status XrdCl::XRootDMsgHandler::PostProcessReadV ( VectorReadInfo *  vReadInfo)
private
void XrdCl::XRootDMsgHandler::Process ( Message *  msg)
virtual

Process the message if it was "taken" by the examine action.

Process the message if it was "taken" by the examine action

Parameters:
msgthe message to be processed

Reimplemented from XrdCl::IncomingMsgHandler.

References XrdCl::Buffer::Append(), 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, ServerResponseBody_Wait::infomsg, XrdCl::Status::IsOK(), XrdCl::URL::IsValid(), kXR_attn, kXR_attrMeta, kXR_error, kXR_isManager, kXR_ok, kXR_redirect, kXR_wait, kXR_waitresp, pHasLoadBalancer, pHosts, pLoadBalancer, ServerResponseBody_Redirect::port, pPostMaster, pRedirectAsAnswer, pRedirectCgi, pRedirectCounter, pRequest, pResponse, XrdCl::XRootDQuery::ProtocolVersion, pStatus, pUrl, XrdCl::PostMaster::QueryTransport(), ServerResponse::redirect, XrdCl::TaskManager::RegisterTask(), 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, XrdCl::suXRDRedirect, XrdCl::XRootDTransport::UnMarshallBody(), XrdCl::XRootDTransport::UnMarshallHeader(), XrdCl::HostInfo::url, ServerResponse::wait, ServerResponse::waitresp, and XrdCl::XRootDMsg.

XRootDStatus * XrdCl::XRootDMsgHandler::ProcessStatus ( )
private
Status XrdCl::XRootDMsgHandler::ReadAsync ( int  socket,
uint32_t &  btesRead 
)
private

Read a buffer asynchronously - depends on pAsyncBuffer, pAsyncSize and pAsyncOffset

References XrdCl::errSocketError, pAsyncOffset, pAsyncReadBuffer, pAsyncReadSize, read(), XrdCl::stError, XrdCl::stOK, XrdCl::suDone, and XrdCl::suRetry.

Referenced by ReadRawOther(), ReadRawRead(), and ReadRawReadV().

Status XrdCl::XRootDMsgHandler::ReadMessageBody ( Message *  msg,
int  socket,
uint32_t &  bytesRead 
)
virtual

Read message body directly from a socket - called if Examine returns Raw flag - only socket related errors may be returned here

Parameters:
msgthe corresponding message header
socketthe socket to read from
bytesReadnumber of bytes read by the method
Returns:
stOK & suDone if the whole body has been processed stOK & suRetry if more data is needed stError on failure

Reimplemented from XrdCl::IncomingMsgHandler.

References XrdCl::Buffer::GetBuffer(), ClientRequest::header, kXR_read, kXR_readv, pRequest, ReadRawOther(), ReadRawRead(), ReadRawReadV(), and ClientRequestHdr::requestid.

Status XrdCl::XRootDMsgHandler::ReadRawOther ( Message *  msg,
int  socket,
uint32_t &  bytesRead 
)
private

Handle anything other than kXR_read and kXR_readv in raw mode.

References XrdCl::Status::code, XrdCl::Status::IsOK(), pAsyncMsgSize, pAsyncOffset, pAsyncReadBuffer, pAsyncReadSize, pOtherRawStarted, ReadAsync(), and XrdCl::suRetry.

Referenced by ReadMessageBody(), and ReadRawRead().

Status XrdCl::XRootDMsgHandler::ReadRawRead ( Message *  msg,
int  socket,
uint32_t &  bytesRead 
)
private
Status XrdCl::XRootDMsgHandler::ReadRawReadV ( Message *  msg,
int  socket,
uint32_t &  bytesRead 
)
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(), Process(), 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, and pChunkStatus.

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 counter.

References pRedirectCounter.

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

void XrdCl::XRootDMsgHandler::SwitchOnRefreshFlag ( )
private
Status XrdCl::XRootDMsgHandler::UnPackReadVResponse ( Message *  msg)
private
void XrdCl::XRootDMsgHandler::UpdateTriedCGI ( )
private

Update the "tried=" part of the CGI of the current message.

References AppendCGI(), XrdCl::URL::GetHostName(), XrdCl::XRootDTransport::MarshallRequest(), pRequest, pUrl, and XrdCl::XRootDTransport::UnMarshallRequest().

Referenced by HandleError().

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().

Status XrdCl::XRootDMsgHandler::WriteMessageBody ( int  socket,
uint32_t &  bytesRead 
)
virtual

Write message body directly to a socket - called if IsRaw returns true - only socket related errors may be returned here

Parameters:
socketthe socket to read from
bytesReadnumber of bytes read by the method
Returns:
stOK & suDone if the whole body has been processed stOK & suRetry if more data needs to be written stError on failure

Reimplemented from XrdCl::OutgoingMsgHandler.

References XrdCl::errSocketError, pAsyncOffset, pChunkList, XrdCl::stError, XrdCl::stOK, XrdCl::suRetry, and write().


Member Data Documentation

uint32_t XrdCl::XRootDMsgHandler::pAsyncMsgSize
private
uint32_t XrdCl::XRootDMsgHandler::pAsyncOffset
private
char* XrdCl::XRootDMsgHandler::pAsyncReadBuffer
private
uint32_t XrdCl::XRootDMsgHandler::pAsyncReadSize
private
ChunkList* XrdCl::XRootDMsgHandler::pChunkList
private
std::vector<ChunkStatus> XrdCl::XRootDMsgHandler::pChunkStatus
private
time_t XrdCl::XRootDMsgHandler::pExpiration
private
bool XrdCl::XRootDMsgHandler::pHasLoadBalancer
private

Referenced by Process(), and SetLoadBalancer().

bool XrdCl::XRootDMsgHandler::pHasSessionId
private
HostList* XrdCl::XRootDMsgHandler::pHosts
private
HostInfo XrdCl::XRootDMsgHandler::pLoadBalancer
private
bool XrdCl::XRootDMsgHandler::pOtherRawStarted
private

Referenced by ReadRawOther(), and ReadRawRead().

std::vector<Message *> XrdCl::XRootDMsgHandler::pPartialResps
private
PostMaster* XrdCl::XRootDMsgHandler::pPostMaster
private
uint32_t XrdCl::XRootDMsgHandler::pReadRawCurrentOffset
private

Referenced by Examine(), and ReadRawRead().

bool XrdCl::XRootDMsgHandler::pReadRawStarted
private

Referenced by Examine(), and ReadRawRead().

readahead_list XrdCl::XRootDMsgHandler::pReadVRawChunkHeader
private

Referenced by ReadRawReadV(), and XRootDMsgHandler().

bool XrdCl::XRootDMsgHandler::pReadVRawChunkHeaderDone
private

Referenced by ReadRawReadV().

bool XrdCl::XRootDMsgHandler::pReadVRawChunkHeaderStarted
private

Referenced by ReadRawReadV().

int32_t XrdCl::XRootDMsgHandler::pReadVRawChunkIndex
private

Referenced by ReadRawReadV().

bool XrdCl::XRootDMsgHandler::pReadVRawMsgDiscard
private

Referenced by ReadRawReadV().

uint32_t XrdCl::XRootDMsgHandler::pReadVRawMsgOffset
private

Referenced by Examine(), and ReadRawReadV().

bool XrdCl::XRootDMsgHandler::pReadVRawSizeError
private
bool XrdCl::XRootDMsgHandler::pRedirectAsAnswer
private
std::string XrdCl::XRootDMsgHandler::pRedirectCgi
private

Referenced by ParseResponse(), and Process().

uint16_t XrdCl::XRootDMsgHandler::pRedirectCounter
private

Referenced by Process(), 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

Referenced by HandleError(), Process(), and ProcessStatus().

URL XrdCl::XRootDMsgHandler::pUrl
private

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