Handle/Process/Forward XRootD messages. More...
#include <XrdClXRootDMsgHandler.hh>
Classes | |
struct | ChunkStatus |
Public Member Functions | |
XRootDMsgHandler (Message *msg, ResponseHandler *respHandler, const URL *url, std::shared_ptr< SIDManager > sidMgr, LocalFileHandler *lFileHandler) | |
~XRootDMsgHandler () | |
Destructor. | |
virtual uint16_t | Examine (Message *msg) |
virtual uint16_t | GetSid () const |
virtual void | Process (Message *msg) |
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? | |
Status | WriteMessageBody (int socket, uint32_t &bytesRead) |
ChunkList * | GetMessageBody (uint32_t *&asyncOffset) |
void | WaitDone (time_t now) |
void | SetExpiration (time_t expiration) |
Set a timestamp after which we give up. | |
void | SetRedirectAsAnswer (bool redirectAsAnswer) |
void | SetOksofarAsAnswer (bool oksofarAsAnswer) |
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. | |
void | SetFollowMetalink (bool followMetalink) |
void | SetStateful (bool stateful) |
void | TakeDownTimeoutFence () |
Take down the timeout fence after oksofar response has been handled. | |
Private Types | |
typedef std::list < std::unique_ptr < RedirectEntry > > | RedirectTraceBack |
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, RedirectEntry::Type entryType) |
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 &newUrl) |
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 (uint32_t errNo=0) |
Update the "tried=" part of the CGI of the current message. | |
void | SwitchOnRefreshFlag () |
Switch on the refresh flag for some requests. | |
void | HandleRspOrQueue () |
void | HandleLocalRedirect (URL *url) |
Handle a redirect to a local file. | |
bool | IsRetriable (Message *request) |
bool | OmitWait (Message *request, const URL &url) |
bool | RetriableErrorResponse (const Status &status) |
void | DumpRedirectTraceBack () |
Dump the redirect-trace-back into the log file. | |
Private Attributes | |
Message * | pRequest |
Message * | pResponse |
std::vector< Message * > | pPartialResps |
ResponseHandler * | pResponseHandler |
URL | pUrl |
URL * | pEffectiveDataServerUrl |
PostMaster * | pPostMaster |
std::shared_ptr< SIDManager > | pSidMgr |
LocalFileHandler * | pLFileHandler |
Status | pStatus |
Status | pLastError |
time_t | pExpiration |
bool | pRedirectAsAnswer |
bool | pOksofarAsAnswer |
HostList * | pHosts |
bool | pHasLoadBalancer |
HostInfo | pLoadBalancer |
bool | pHasSessionId |
std::string | pRedirectUrl |
ChunkList * | pChunkList |
std::vector< ChunkStatus > | pChunkStatus |
uint16_t | pRedirectCounter |
uint16_t | pNotAuthorizedCounter |
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 |
bool | pFollowMetalink |
bool | pStateful |
int | pAggregatedWaitTime |
std::unique_ptr< RedirectEntry > | pRdirEntry |
RedirectTraceBack | pRedirectTraceBack |
bool | pMsgInFly |
bool | pTimeoutFence |
bool | pDirListStarted |
bool | pDirListWithStat |
XrdSysCondVar | pCV |
Friends | |
class | HandleRspJob |
Handle/Process/Forward XRootD messages.
typedef std::list<std::unique_ptr<RedirectEntry> > XrdCl::XRootDMsgHandler::RedirectTraceBack [private] |
XrdCl::XRootDMsgHandler::XRootDMsgHandler | ( | Message * | msg, | |
ResponseHandler * | respHandler, | |||
const URL * | url, | |||
std::shared_ptr< SIDManager > | sidMgr, | |||
LocalFileHandler * | lFileHandler | |||
) | [inline] |
Constructor
msg | message that has been sent out | |
respHandler | response handler to be called then the final final response arrives | |
url | the url the message has been sent to | |
sidMgr | the sid manager used to allocate SID for the initial message |
References XrdCl::Log::Debug(), XrdCl::ExDbgMsg, XrdCl::Message::GetDescription(), XrdCl::URL::GetHostId(), XrdCl::DefaultEnv::GetLog(), XrdCl::DefaultEnv::GetPostMaster(), XrdCl::Message::GetSessionId(), pHasSessionId, pPostMaster, pReadVRawChunkHeader, pRequest, and pUrl.
XrdCl::XRootDMsgHandler::~XRootDMsgHandler | ( | ) | [inline] |
void XrdCl::XRootDMsgHandler::DumpRedirectTraceBack | ( | ) | [private] |
Dump the redirect-trace-back into the log file.
Referenced by ~XRootDMsgHandler().
virtual uint16_t XrdCl::XRootDMsgHandler::Examine | ( | Message * | msg | ) | [virtual] |
Examine an incoming message, and decide on the action to be taken
msg | the message, may be zero if receive failed |
Implements XrdCl::IncomingMsgHandler.
ChunkList* XrdCl::XRootDMsgHandler::GetMessageBody | ( | uint32_t *& | asyncOffset | ) | [inline] |
Get message body - called if IsRaw returns true
asyncOffset | : the current async offset |
References pAsyncOffset, and pChunkList.
const Message* XrdCl::XRootDMsgHandler::GetRequest | ( | ) | const [inline] |
Get the request pointer.
References pRequest.
virtual uint16_t XrdCl::XRootDMsgHandler::GetSid | ( | ) | const [virtual] |
Get handler sid
return sid of the corresponding request, otherwise 0
Implements XrdCl::IncomingMsgHandler.
Recover error.
void XrdCl::XRootDMsgHandler::HandleLocalRedirect | ( | URL * | url | ) | [private] |
Handle a redirect to a local file.
void XrdCl::XRootDMsgHandler::HandleResponse | ( | ) | [private] |
Unpack the message and call the response handler.
void XrdCl::XRootDMsgHandler::HandleRspOrQueue | ( | ) | [private] |
If the current thread is a worker thread from our thread-pool handle the response, otherwise submit a new task to the thread-pool
virtual bool XrdCl::XRootDMsgHandler::IsRaw | ( | ) | const [virtual] |
Are we a raw writer or not?
Reimplemented from XrdCl::OutgoingMsgHandler.
bool XrdCl::XRootDMsgHandler::IsRetriable | ( | Message * | request | ) | [private] |
Check if it is OK to retry this request
reuqest | : the request in question |
Check if for given request and Metalink redirector it is OK to omit the kXR_wait and proceed stright to the next entry in the Metalink file
reuqest | : the request in question | |
url | : metalink URL |
virtual void XrdCl::XRootDMsgHandler::OnStatusReady | ( | const Message * | message, | |
Status | status | |||
) | [virtual] |
The requested action has been performed and the status is available.
Implements XrdCl::OutgoingMsgHandler.
virtual uint8_t XrdCl::XRootDMsgHandler::OnStreamEvent | ( | StreamEvent | event, | |
uint16_t | streamNum, | |||
Status | status | |||
) | [virtual] |
Handle an event other that a message arrival
event | type of the event | |
streamNum | stream concerned | |
status | status info |
Reimplemented from XrdCl::IncomingMsgHandler.
Parse the response and put it in an object that could be passed to the user
Status XrdCl::XRootDMsgHandler::PostProcessReadV | ( | VectorReadInfo * | vReadInfo | ) | [private] |
Post process vector read.
virtual void XrdCl::XRootDMsgHandler::Process | ( | Message * | msg | ) | [virtual] |
Process the message if it was "taken" by the examine action
msg | the message to be processed |
Reimplemented from XrdCl::IncomingMsgHandler.
XRootDStatus* XrdCl::XRootDMsgHandler::ProcessStatus | ( | ) | [private] |
Extract the status information from the stuff that we got.
Status XrdCl::XRootDMsgHandler::ReadAsync | ( | int | socket, | |
uint32_t & | btesRead | |||
) | [private] |
Read a buffer asynchronously - depends on pAsyncBuffer, pAsyncSize and pAsyncOffset
virtual 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
msg | the corresponding message header | |
socket | the socket to read from | |
bytesRead | number of bytes read by the method |
Reimplemented from XrdCl::IncomingMsgHandler.
Status XrdCl::XRootDMsgHandler::ReadRawOther | ( | Message * | msg, | |
int | socket, | |||
uint32_t & | bytesRead | |||
) | [private] |
Handle anything other than kXR_read and kXR_readv in raw mode.
Status XrdCl::XRootDMsgHandler::ReadRawRead | ( | Message * | msg, | |
int | socket, | |||
uint32_t & | bytesRead | |||
) | [private] |
Handle a kXR_read in raw mode.
Status XrdCl::XRootDMsgHandler::ReadRawReadV | ( | Message * | msg, | |
int | socket, | |||
uint32_t & | bytesRead | |||
) | [private] |
Handle a kXR_readv in raw mode.
bool XrdCl::XRootDMsgHandler::RetriableErrorResponse | ( | const Status & | status | ) | [private] |
Checks if the given error returned by server is retriable.
status | : the status returned by the server |
Status XrdCl::XRootDMsgHandler::RetryAtServer | ( | const URL & | url, | |
RedirectEntry::Type | entryType | |||
) | [private] |
Retry the request at another server.
Perform the changes to the original request needed by the redirect procedure - allocate new streamid, append redirection data and such
Status XrdCl::XRootDMsgHandler::RewriteRequestWait | ( | ) | [private] |
Some requests need to be rewritten also after getting kXR_wait - sigh.
void XrdCl::XRootDMsgHandler::SetChunkList | ( | ChunkList * | chunkList | ) | [inline] |
Set the chunk list.
References pChunkList, and pChunkStatus.
void XrdCl::XRootDMsgHandler::SetExpiration | ( | time_t | expiration | ) | [inline] |
Set a timestamp after which we give up.
References pExpiration.
void XrdCl::XRootDMsgHandler::SetFollowMetalink | ( | bool | followMetalink | ) | [inline] |
References pFollowMetalink.
void XrdCl::XRootDMsgHandler::SetHostList | ( | HostList * | hostList | ) | [inline] |
Set host list.
References pHosts.
void XrdCl::XRootDMsgHandler::SetLoadBalancer | ( | const HostInfo & | loadBalancer | ) | [inline] |
Set the load balancer.
References XrdCl::URL::IsValid(), pHasLoadBalancer, pLoadBalancer, and XrdCl::HostInfo::url.
void XrdCl::XRootDMsgHandler::SetOksofarAsAnswer | ( | bool | oksofarAsAnswer | ) | [inline] |
Treat the kXR_oksofar response as a valid answer to the message and notify the handler with the URL as a response
References pOksofarAsAnswer.
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.
void XrdCl::XRootDMsgHandler::SetRedirectCounter | ( | uint16_t | redirectCounter | ) | [inline] |
Set the redirect counter.
References pRedirectCounter.
void XrdCl::XRootDMsgHandler::SetStateful | ( | bool | stateful | ) | [inline] |
References pStateful.
void XrdCl::XRootDMsgHandler::SwitchOnRefreshFlag | ( | ) | [private] |
Switch on the refresh flag for some requests.
void XrdCl::XRootDMsgHandler::TakeDownTimeoutFence | ( | ) |
Take down the timeout fence after oksofar response has been handled.
Unpack a single readv response.
void XrdCl::XRootDMsgHandler::UpdateTriedCGI | ( | uint32_t | errNo = 0 |
) | [private] |
Update the "tried=" part of the CGI of the current message.
void XrdCl::XRootDMsgHandler::WaitDone | ( | time_t | now | ) |
Called after the wait time for kXR_wait has elapsed
now | current timestamp |
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
socket | the socket to read from | |
bytesRead | number of bytes read by the method |
Reimplemented from XrdCl::OutgoingMsgHandler.
friend class HandleRspJob [friend] |
int XrdCl::XRootDMsgHandler::pAggregatedWaitTime [private] |
uint32_t XrdCl::XRootDMsgHandler::pAsyncMsgSize [private] |
uint32_t XrdCl::XRootDMsgHandler::pAsyncOffset [private] |
Referenced by GetMessageBody().
char* XrdCl::XRootDMsgHandler::pAsyncReadBuffer [private] |
uint32_t XrdCl::XRootDMsgHandler::pAsyncReadSize [private] |
ChunkList* XrdCl::XRootDMsgHandler::pChunkList [private] |
Referenced by GetMessageBody(), SetChunkList(), and ~XRootDMsgHandler().
std::vector<ChunkStatus> XrdCl::XRootDMsgHandler::pChunkStatus [private] |
Referenced by SetChunkList().
XrdSysCondVar XrdCl::XRootDMsgHandler::pCV [private] |
bool XrdCl::XRootDMsgHandler::pDirListStarted [private] |
bool XrdCl::XRootDMsgHandler::pDirListWithStat [private] |
Referenced by ~XRootDMsgHandler().
time_t XrdCl::XRootDMsgHandler::pExpiration [private] |
Referenced by SetExpiration().
bool XrdCl::XRootDMsgHandler::pFollowMetalink [private] |
Referenced by SetFollowMetalink().
bool XrdCl::XRootDMsgHandler::pHasLoadBalancer [private] |
Referenced by SetLoadBalancer().
bool XrdCl::XRootDMsgHandler::pHasSessionId [private] |
Referenced by XRootDMsgHandler(), and ~XRootDMsgHandler().
HostList* XrdCl::XRootDMsgHandler::pHosts [private] |
Referenced by SetHostList(), and ~XRootDMsgHandler().
Status XrdCl::XRootDMsgHandler::pLastError [private] |
Referenced by ~XRootDMsgHandler().
Referenced by SetLoadBalancer().
bool XrdCl::XRootDMsgHandler::pMsgInFly [private] |
uint16_t XrdCl::XRootDMsgHandler::pNotAuthorizedCounter [private] |
bool XrdCl::XRootDMsgHandler::pOksofarAsAnswer [private] |
Referenced by SetOksofarAsAnswer().
bool XrdCl::XRootDMsgHandler::pOtherRawStarted [private] |
std::vector<Message *> XrdCl::XRootDMsgHandler::pPartialResps [private] |
Referenced by ~XRootDMsgHandler().
PostMaster* XrdCl::XRootDMsgHandler::pPostMaster [private] |
Referenced by XRootDMsgHandler(), and ~XRootDMsgHandler().
std::unique_ptr<RedirectEntry> XrdCl::XRootDMsgHandler::pRdirEntry [private] |
uint32_t XrdCl::XRootDMsgHandler::pReadRawCurrentOffset [private] |
bool XrdCl::XRootDMsgHandler::pReadRawStarted [private] |
Referenced by XRootDMsgHandler().
bool XrdCl::XRootDMsgHandler::pReadVRawChunkHeaderDone [private] |
bool XrdCl::XRootDMsgHandler::pReadVRawChunkHeaderStarted [private] |
int32_t XrdCl::XRootDMsgHandler::pReadVRawChunkIndex [private] |
bool XrdCl::XRootDMsgHandler::pReadVRawMsgDiscard [private] |
uint32_t XrdCl::XRootDMsgHandler::pReadVRawMsgOffset [private] |
bool XrdCl::XRootDMsgHandler::pReadVRawSizeError [private] |
bool XrdCl::XRootDMsgHandler::pRedirectAsAnswer [private] |
Referenced by SetRedirectAsAnswer().
uint16_t XrdCl::XRootDMsgHandler::pRedirectCounter [private] |
Referenced by SetRedirectCounter().
std::string XrdCl::XRootDMsgHandler::pRedirectUrl [private] |
Message* XrdCl::XRootDMsgHandler::pRequest [private] |
Referenced by GetRequest(), XRootDMsgHandler(), and ~XRootDMsgHandler().
Message* XrdCl::XRootDMsgHandler::pResponse [private] |
Referenced by ~XRootDMsgHandler().
Referenced by ~XRootDMsgHandler().
std::shared_ptr<SIDManager> XrdCl::XRootDMsgHandler::pSidMgr [private] |
bool XrdCl::XRootDMsgHandler::pStateful [private] |
Referenced by SetStateful().
Status XrdCl::XRootDMsgHandler::pStatus [private] |
bool XrdCl::XRootDMsgHandler::pTimeoutFence [private] |
URL XrdCl::XRootDMsgHandler::pUrl [private] |
Referenced by XRootDMsgHandler(), and ~XRootDMsgHandler().