25 #ifndef __XRD_CL_XROOTD_MSG_HANDLER_HH__
26 #define __XRD_CL_XROOTD_MSG_HANDLER_HH__
46 #include <arpa/inet.h>
59 class LocalFileHandler;
95 case EntryRedirect:
return "Redirected from: " + fromstr +
" to: "
99 "Falling back to virtual redirector: " + tostr;
103 case EntryWait:
return "Waited at server request. Resending: "
107 return "Failed at: " + fromstr +
", retrying at: " + tostr;
132 std::shared_ptr<SIDManager> sidMgr,
191 log->
Debug(
ExDbgMsg,
"[%s] MsgHandler created: 0x%x (message: %s ).",
200 ntohl( pgrdreq->
rlen ) ) );
239 virtual uint16_t
Examine( std::shared_ptr<Message> &msg );
280 uint32_t &bytesRead );
314 uint32_t &bytesWritten );
442 uint32_t &bytesRead );
448 uint32_t &bytesRead );
457 uint32_t btsRead = 0;
460 bytesRead += btsRead;
468 uint32_t toBeRead, uint32_t &bytesRead );
596 std::string &result );
614 inline static size_t NbPgPerRsp( uint64_t offset, uint32_t dlen )
@ kXR_readv
Definition: XProtocol.hh:137
@ kXR_pgread
Definition: XProtocol.hh:142
Definition: XrdClAnyObject.hh:33
Object for reading out data from the VectorRead response.
Definition: XrdClAsyncVectorReader.hh:33
Binary blob representation.
Definition: XrdClBuffer.hh:34
const char * GetBuffer(uint32_t offset=0) const
Get the message buffer.
Definition: XrdClBuffer.hh:72
static PostMaster * GetPostMaster()
Get default post master.
static Log * GetLog()
Get default log.
Definition: XrdClLocalFileHandler.hh:33
Handle diagnostics.
Definition: XrdClLog.hh:101
void Debug(uint64_t topic, const char *format,...)
Print a debug message.
The message representation used throughout the system.
Definition: XrdClMessage.hh:30
const std::string & GetDescription() const
Get the description of the message.
Definition: XrdClMessage.hh:95
uint64_t GetSessionId() const
Get the session ID the message is meant for.
Definition: XrdClMessage.hh:111
Message handler.
Definition: XrdClPostMasterInterfaces.hh:51
StreamEvent
Events that may have occurred to the stream.
Definition: XrdClPostMasterInterfaces.hh:79
A hub for dispatching and receiving messages.
Definition: XrdClPostMaster.hh:48
Handle an async response.
Definition: XrdClXRootDResponses.hh:1117
A network socket.
Definition: XrdClSocket.hh:43
URL representation.
Definition: XrdClURL.hh:31
std::string GetHostId() const
Get the host part of the URL (user:password@host:port)
Definition: XrdClURL.hh:94
std::string GetLocation() const
Get location (protocol://host:port/path)
bool IsValid() const
Is the url valid.
Handle/Process/Forward XRootD messages.
Definition: XrdClXRootDMsgHandler.hh:115
void SetRedirectCounter(uint16_t redirectCounter)
Set the redirect counter.
Definition: XrdClXRootDMsgHandler.hh:414
Status ReadFromBuffer(char *&buffer, size_t &buflen, std::string &result)
bool pDirListStarted
Definition: XrdClXRootDMsgHandler.hh:699
bool pHasLoadBalancer
Definition: XrdClXRootDMsgHandler.hh:647
XRootDStatus WriteMessageBody(Socket *socket, uint32_t &bytesWritten)
bool pMsgInFly
Definition: XrdClXRootDMsgHandler.hh:685
void SetFollowMetalink(bool followMetalink)
Definition: XrdClXRootDMsgHandler.hh:419
const Message * GetRequest() const
Get the request pointer.
Definition: XrdClXRootDMsgHandler.hh:360
bool pRspStatusBodyUnMarshaled
Definition: XrdClXRootDMsgHandler.hh:717
void SetChunkList(ChunkList *chunkList)
Set the chunk list.
Definition: XrdClXRootDMsgHandler.hh:387
uint32_t pAsyncReadSize
Definition: XrdClXRootDMsgHandler.hh:661
void SetHostList(HostList *hostList)
Set host list.
Definition: XrdClXRootDMsgHandler.hh:379
friend class HandleRspJob
Definition: XrdClXRootDMsgHandler.hh:116
uint16_t pNotAuthorizedCounter
Definition: XrdClXRootDMsgHandler.hh:656
ChunkList * pChunkList
Definition: XrdClXRootDMsgHandler.hh:651
std::unique_ptr< RedirectEntry > pRdirEntry
Definition: XrdClXRootDMsgHandler.hh:682
uint32_t pPgWrtCurrentPageOffset
Definition: XrdClXRootDMsgHandler.hh:672
virtual uint16_t InspectStatusRsp()
void SetCrc32cDigests(std::vector< uint32_t > &&crc32cDigests)
Definition: XrdClXRootDMsgHandler.hh:398
std::unique_ptr< AsyncVectorReader > pVectorReader
Definition: XrdClXRootDMsgHandler.hh:669
uint32_t pAsyncOffset
Definition: XrdClXRootDMsgHandler.hh:658
std::atomic< bool > pTimeoutFence
Definition: XrdClXRootDMsgHandler.hh:692
void HandleResponse()
Unpack the message and call the response handler.
static const size_t MaxSslErrRetry
Definition: XrdClXRootDMsgHandler.hh:612
static const size_t CksumSize
Definition: XrdClXRootDMsgHandler.hh:610
uint32_t pReadRawCurrentOffset
Definition: XrdClXRootDMsgHandler.hh:666
XRootDStatus * ProcessStatus()
Extract the status information from the stuff that we got.
HostInfo pLoadBalancer
Definition: XrdClXRootDMsgHandler.hh:648
void UpdateTriedCGI(uint32_t errNo=0)
Update the "tried=" part of the CGI of the current message.
bool pOtherRawStarted
Definition: XrdClXRootDMsgHandler.hh:675
LocalFileHandler * pLFileHandler
Definition: XrdClXRootDMsgHandler.hh:640
void SetLoadBalancer(const HostInfo &loadBalancer)
Set the load balancer.
Definition: XrdClXRootDMsgHandler.hh:368
static Status ReadBytesAsync(Socket *socket, char *&buffer, uint32_t toBeRead, uint32_t &bytesRead)
Read a buffer asynchronously.
void HandleLocalRedirect(URL *url)
Handle a redirect to a local file.
bool OmitWait(Message &request, const URL &url)
Status RewriteRequestWait()
Some requests need to be rewritten also after getting kXR_wait - sigh.
bool RetriableErrorResponse(const Status &status)
Status ReadAsync(Socket *socket, uint32_t &bytesRead)
Definition: XrdClXRootDMsgHandler.hh:454
static size_t NbPgPerRsp(uint64_t offset, uint32_t dlen)
Definition: XrdClXRootDMsgHandler.hh:614
void DumpRedirectTraceBack()
Dump the redirect-trace-back into the log file.
virtual uint16_t GetSid() const
Status ParseResponse(AnyObject *&response)
virtual void OnStatusReady(const Message *message, XRootDStatus status)
The requested action has been performed and the status is available.
URL * pEffectiveDataServerUrl
Definition: XrdClXRootDMsgHandler.hh:637
std::vector< ChunkStatus > pChunkStatus
Definition: XrdClXRootDMsgHandler.hh:654
bool pReadRawStarted
Definition: XrdClXRootDMsgHandler.hh:665
std::string pRedirectUrl
Definition: XrdClXRootDMsgHandler.hh:650
XRootDMsgHandler(Message *msg, ResponseHandler *respHandler, const URL *url, std::shared_ptr< SIDManager > sidMgr, LocalFileHandler *lFileHandler)
Definition: XrdClXRootDMsgHandler.hh:129
bool pOksofarAsAnswer
Definition: XrdClXRootDMsgHandler.hh:645
RedirectTraceBack pRedirectTraceBack
Definition: XrdClXRootDMsgHandler.hh:683
bool pDirListWithStat
Definition: XrdClXRootDMsgHandler.hh:700
void SwitchOnRefreshFlag()
Switch on the refresh flag for some requests.
Status ReadFromBuffer(char *&buffer, size_t &buflen, size_t size, std::string &result)
int pAggregatedWaitTime
Definition: XrdClXRootDMsgHandler.hh:680
std::shared_ptr< SIDManager > pSidMgr
Definition: XrdClXRootDMsgHandler.hh:639
~XRootDMsgHandler()
Destructor.
Definition: XrdClXRootDMsgHandler.hh:212
PostMaster * pPostMaster
Definition: XrdClXRootDMsgHandler.hh:638
std::unique_ptr< AsyncPageReader > pPageReader
Definition: XrdClXRootDMsgHandler.hh:668
void WaitDone(time_t now)
Status ReadRawRead(Socket *socket, uint32_t &bytesRead)
Handle a kXR_read in raw mode.
std::vector< uint32_t > pCrc32cDigests
Definition: XrdClXRootDMsgHandler.hh:652
size_t pSslErrCnt
Definition: XrdClXRootDMsgHandler.hh:711
Status RewriteRequestRedirect(const URL &newUrl)
void SetStateful(bool stateful)
Definition: XrdClXRootDMsgHandler.hh:424
bool pStateful
Definition: XrdClXRootDMsgHandler.hh:679
time_t GetExpiration()
Get a timestamp after which we give up.
Definition: XrdClXRootDMsgHandler.hh:334
std::shared_ptr< Message > pResponse
Definition: XrdClXRootDMsgHandler.hh:633
char * pAsyncReadBuffer
Definition: XrdClXRootDMsgHandler.hh:662
virtual uint8_t OnStreamEvent(StreamEvent event, XRootDStatus status)
XrdSys::KernelBuffer * pKBuff
Definition: XrdClXRootDMsgHandler.hh:653
bool pRspPgWrtRetrnsmReqUnMarshalled
Definition: XrdClXRootDMsgHandler.hh:718
bool pFollowMetalink
Definition: XrdClXRootDMsgHandler.hh:677
time_t pExpiration
Definition: XrdClXRootDMsgHandler.hh:643
Status RetryAtServer(const URL &url, RedirectEntry::Type entryType)
Retry the request at another server.
uint16_t pRedirectCounter
Definition: XrdClXRootDMsgHandler.hh:655
std::vector< std::shared_ptr< Message > > pPartialResps
Definition: XrdClXRootDMsgHandler.hh:634
Status ReadRawOther(Socket *socket, uint32_t &bytesRead)
Handle anything other than kXR_read and kXR_readv in raw mode.
Message * pRequest
Definition: XrdClXRootDMsgHandler.hh:632
static const size_t PageWithCksum
Definition: XrdClXRootDMsgHandler.hh:611
uint32_t pPgWrtCurrentPageNb
Definition: XrdClXRootDMsgHandler.hh:673
void SetOksofarAsAnswer(bool oksofarAsAnswer)
Definition: XrdClXRootDMsgHandler.hh:352
virtual XRootDStatus ReadMessageBody(Message *msg, Socket *socket, uint32_t &bytesRead)
void SetKernelBuffer(XrdSys::KernelBuffer *kbuff)
Set the kernel buffer.
Definition: XrdClXRootDMsgHandler.hh:406
bool pHasSessionId
Definition: XrdClXRootDMsgHandler.hh:649
uint32_t pAsyncMsgSize
Definition: XrdClXRootDMsgHandler.hh:663
virtual bool IsRaw() const
Are we a raw writer or not?
void HandleError(XRootDStatus status)
Recover error.
virtual uint16_t Examine(std::shared_ptr< Message > &msg)
URL pUrl
Definition: XrdClXRootDMsgHandler.hh:636
std::unique_ptr< HostList > pHosts
Definition: XrdClXRootDMsgHandler.hh:646
uint32_t pAsyncChunkOffset
Definition: XrdClXRootDMsgHandler.hh:659
Status ParseXAttrResponse(char *data, size_t len, AnyObject *&response)
XrdSysCondVar pCV
Definition: XrdClXRootDMsgHandler.hh:706
ResponseHandler * pResponseHandler
Definition: XrdClXRootDMsgHandler.hh:635
Status pLastError
Definition: XrdClXRootDMsgHandler.hh:642
XRootDStatus pStatus
Definition: XrdClXRootDMsgHandler.hh:641
std::list< std::unique_ptr< RedirectEntry > > RedirectTraceBack
Definition: XrdClXRootDMsgHandler.hh:608
void SetExpiration(time_t expiration)
Set a timestamp after which we give up.
Definition: XrdClXRootDMsgHandler.hh:326
bool pRedirectAsAnswer
Definition: XrdClXRootDMsgHandler.hh:644
Buffer pPgWrtCksumBuff
Definition: XrdClXRootDMsgHandler.hh:671
void SetRedirectAsAnswer(bool redirectAsAnswer)
Definition: XrdClXRootDMsgHandler.hh:343
uint32_t pAsyncChunkIndex
Definition: XrdClXRootDMsgHandler.hh:660
Status ReadFromBuffer(char *&buffer, size_t &buflen, T &result)
Request status.
Definition: XrdClXRootDResponses.hh:219
static int csNum(off_t offs, int count)
Compute the required size of a checksum vector based on offset & length.
Definition: XrdSysPthread.hh:79
Definition: XrdSysKernelBuffer.hh:46
Definition: XrdClAnyObject.hh:26
std::vector< HostInfo > HostList
Definition: XrdClXRootDResponses.hh:1111
const uint64_t ExDbgMsg
Definition: XrdClConstants.hh:44
std::vector< ChunkInfo > ChunkList
List of chunks.
Definition: XrdClXRootDResponses.hh:1046
static const int PageSize
Definition: XrdSysPageSize.hh:36
Definition: XProtocol.hh:501
kXR_int32 rlen
Definition: XProtocol.hh:506
kXR_int64 offset
Definition: XProtocol.hh:505
Definition: XProtocol.hh:155
kXR_unt16 requestid
Definition: XProtocol.hh:157
Definition: XrdClXRootDResponses.hh:1100
URL url
URL of the host.
Definition: XrdClXRootDResponses.hh:1108
Definition: XrdClXRootDMsgHandler.hh:66
Type type
Definition: XrdClXRootDMsgHandler.hh:83
RedirectEntry(const URL &from, const URL &to, Type type)
Definition: XrdClXRootDMsgHandler.hh:75
XRootDStatus status
Definition: XrdClXRootDMsgHandler.hh:84
URL from
Definition: XrdClXRootDMsgHandler.hh:81
std::string ToString(bool prevok=true)
Definition: XrdClXRootDMsgHandler.hh:86
URL to
Definition: XrdClXRootDMsgHandler.hh:82
Type
Definition: XrdClXRootDMsgHandler.hh:68
@ EntryRedirect
Definition: XrdClXRootDMsgHandler.hh:69
@ EntryRetry
Definition: XrdClXRootDMsgHandler.hh:71
@ EntryRedirectOnWait
Definition: XrdClXRootDMsgHandler.hh:70
@ EntryWait
Definition: XrdClXRootDMsgHandler.hh:72
Procedure execution status.
Definition: XrdClStatus.hh:114
Definition: XrdClXRootDMsgHandler.hh:602
ChunkStatus()
Definition: XrdClXRootDMsgHandler.hh:603
bool sizeError
Definition: XrdClXRootDMsgHandler.hh:604
bool done
Definition: XrdClXRootDMsgHandler.hh:605