25 #ifndef __XRD_CL_XROOTD_MSG_HANDLER_HH__ 26 #define __XRD_CL_XROOTD_MSG_HANDLER_HH__ 41 #include <arpa/inet.h> 54 class LocalFileHandler;
90 case EntryRedirect:
return "Redirected from: " + fromstr +
" to: " 94 "Falling back to virtual redirector: " + tostr;
98 case EntryWait:
return "Waited at server request. Resending: " 102 return "Failed at: " + fromstr +
", retrying at: " + tostr;
128 std::shared_ptr<SIDManager> sidMgr,
190 log->
Debug(
ExDbgMsg,
"[%s] MsgHandler created: 0x%x (message: %s ).",
212 std::vector<Message *>::iterator it;
258 virtual uint16_t
GetSid()
const;
280 uint32_t &bytesRead );
301 virtual bool IsRaw()
const;
314 uint32_t &bytesWritten );
427 uint32_t &bytesRead );
434 uint32_t &bytesRead );
441 uint32_t &bytesRead );
448 uint32_t &bytesRead );
457 uint32_t btsRead = 0;
460 bytesRead += btsRead;
471 while( toBeRead > 0 )
473 uint32_t btsRead = 0;
476 bytesRead += btsRead;
493 uint32_t toBeRead, uint32_t &bytesRead );
631 std::string &result );
657 inline void Copy( uint32_t offchlst,
char *buffer,
size_t length )
663 char *dstbuf =
nullptr;
667 if( offchlst < itr->offset ||
668 offchlst >= itr->offset + itr->length )
670 size_t dstoff = offchlst - itr->offset;
671 dstbuf =
reinterpret_cast<char*
>( itr->buffer ) + dstoff;
672 cplen = itr->length - cplen;
676 if( cplen > length ) cplen = length;
677 memcpy( dstbuf, buffer, cplen );
769 #endif // __XRD_CL_XROOTD_MSG_HANDLER_HH__ Status ParseXAttrResponse(char *data, size_t len, AnyObject *&response)
uint32_t pAsyncChunkIndex
Definition: XrdClXRootDMsgHandler.hh:710
bool pOtherRawStarted
Definition: XrdClXRootDMsgHandler.hh:729
void HandleError(XRootDStatus status, Message *msg=0)
Recover error.
std::vector< Message * > pPartialResps
Definition: XrdClXRootDMsgHandler.hh:685
Definition: XrdClAnyObject.hh:32
URL to
Definition: XrdClXRootDMsgHandler.hh:77
Status ReadRawReadV(Message *msg, Socket *socket, uint32_t &bytesRead)
Handle a kXR_readv in raw mode.
void UpdateTriedCGI(uint32_t errNo=0)
Update the "tried=" part of the CGI of the current message.
virtual uint16_t GetSid() const
const uint64_t ExDbgMsg
Definition: XrdClConstants.hh:44
std::vector< ChunkInfo > ChunkList
List of chunks.
Definition: XrdClXRootDResponses.hh:980
Status RetryAtServer(const URL &url, RedirectEntry::Type entryType)
Retry the request at another server.
PostMaster * pPostMaster
Definition: XrdClXRootDMsgHandler.hh:689
void Copy(uint32_t offchlst, char *buffer, size_t length)
Definition: XrdClXRootDMsgHandler.hh:657
Status RewriteRequestWait()
Some requests need to be rewritten also after getting kXR_wait - sigh.
Definition: XProtocol.hh:651
The message representation used throughout the system.
Definition: XrdClMessage.hh:29
ChunkStatus()
Definition: XrdClXRootDMsgHandler.hh:638
bool RetriableErrorResponse(const Status &status)
const char * GetBuffer(uint32_t offset=0) const
Get the message buffer.
Definition: XrdClBuffer.hh:72
Status ReadPagesAsync(Socket *socket, uint32_t &bytesRead)
Definition: XrdClXRootDMsgHandler.hh:468
void SetRedirectCounter(uint16_t redirectCounter)
Set the redirect counter.
Definition: XrdClXRootDMsgHandler.hh:400
bool pReadRawStarted
Definition: XrdClXRootDMsgHandler.hh:715
~XRootDMsgHandler()
Destructor.
Definition: XrdClXRootDMsgHandler.hh:205
std::atomic< bool > pTimeoutFence
Definition: XrdClXRootDMsgHandler.hh:746
void SetFollowMetalink(bool followMetalink)
Definition: XrdClXRootDMsgHandler.hh:405
RedirectTraceBack pRedirectTraceBack
Definition: XrdClXRootDMsgHandler.hh:737
static const size_t PageWithCksum
Definition: XrdClXRootDMsgHandler.hh:647
URL from
Definition: XrdClXRootDMsgHandler.hh:76
LocalFileHandler * pLFileHandler
Definition: XrdClXRootDMsgHandler.hh:691
uint16_t pNotAuthorizedCounter
Definition: XrdClXRootDMsgHandler.hh:706
std::string ToString(bool prevok=true)
Definition: XrdClXRootDMsgHandler.hh:81
const std::string & GetDescription() const
Get the description of the message.
Definition: XrdClMessage.hh:74
virtual XRootDStatus ReadMessageBody(Message *msg, Socket *socket, uint32_t &bytesRead)
std::vector< ChunkStatus > pChunkStatus
Definition: XrdClXRootDMsgHandler.hh:704
std::string GetLocation() const
Get location (protocol://host:port/path)
kXR_unt16 requestid
Definition: XProtocol.hh:156
Definition: XrdClXRootDMsgHandler.hh:636
uint16_t code
Error type, or additional hints on what to do.
Definition: XrdClStatus.hh:145
XRootDMsgHandler(Message *msg, ResponseHandler *respHandler, const URL *url, std::shared_ptr< SIDManager > sidMgr, LocalFileHandler *lFileHandler)
Definition: XrdClXRootDMsgHandler.hh:125
kXR_int32 rlen
Definition: XProtocol.hh:505
bool IsOK() const
We're fine.
Definition: XrdClStatus.hh:122
uint32_t pReadVRawMsgOffset
Definition: XrdClXRootDMsgHandler.hh:721
friend class HandleRspJob
Definition: XrdClXRootDMsgHandler.hh:112
void SetKernelBuffer(XrdSys::KernelBuffer *kbuff)
Set the kernel buffer.
Definition: XrdClXRootDMsgHandler.hh:392
static Status ReadBytesAsync(Socket *socket, char *&buffer, uint32_t toBeRead, uint32_t &bytesRead)
Read a buffer asynchronously.
bool pReadVRawChunkHeaderDone
Definition: XrdClXRootDMsgHandler.hh:722
Status ParseResponse(AnyObject *&response)
StreamEvent
Events that may have occurred to the stream.
Definition: XrdClPostMasterInterfaces.hh:98
std::string GetHostId() const
Get the host part of the URL (user:password@host:port)
Definition: XrdClURL.hh:94
bool pFollowMetalink
Definition: XrdClXRootDMsgHandler.hh:731
Status ReadFromBuffer(char *&buffer, size_t &buflen, T &result)
bool done
Definition: XrdClXRootDMsgHandler.hh:640
Procedure execution status.
Definition: XrdClStatus.hh:112
static const size_t CksumSize
Definition: XrdClXRootDMsgHandler.hh:646
Status RewriteRequestRedirect(const URL &newUrl)
Status ReadRawPgRead(Message *msg, Socket *socket, uint32_t &bytesRead)
Handle a kXR_pgread in raw mode.
URL pUrl
Definition: XrdClXRootDMsgHandler.hh:687
virtual void Process(Message *msg)
Status ReadRawRead(Message *msg, Socket *socket, uint32_t &bytesRead)
Handle a kXR_read in raw mode.
virtual void OnStatusReady(const Message *message, XRootDStatus status)
The requested action has been performed and the status is available.
Message * pRequest
Definition: XrdClXRootDMsgHandler.hh:683
Status UnPackReadVResponse(Message *msg)
Unpack a single readv response.
Definition: XrdClXRootDMsgHandler.hh:65
time_t pExpiration
Definition: XrdClXRootDMsgHandler.hh:694
void SetExpiration(time_t expiration)
Set a timestamp after which we give up.
Definition: XrdClXRootDMsgHandler.hh:326
uint16_t pRedirectCounter
Definition: XrdClXRootDMsgHandler.hh:705
static const size_t PageSize
Definition: XrdClXRootDMsgHandler.hh:645
std::shared_ptr< SIDManager > pSidMgr
Definition: XrdClXRootDMsgHandler.hh:690
static Log * GetLog()
Get default log.
XRootDStatus WriteMessageBody(Socket *socket, uint32_t &bytesWritten)
bool pHasSessionId
Definition: XrdClXRootDMsgHandler.hh:700
ChunkList * pChunkList
Definition: XrdClXRootDMsgHandler.hh:702
Definition: XrdClXRootDResponses.hh:1033
char * pAsyncReadBuffer
Definition: XrdClXRootDMsgHandler.hh:712
Definition: XProtocol.hh:500
std::vector< HostInfo > HostList
Definition: XrdClXRootDResponses.hh:1045
virtual uint16_t Examine(Message *msg)
bool pOksofarAsAnswer
Definition: XrdClXRootDMsgHandler.hh:696
static const size_t MaxSslErrRetry
Definition: XrdClXRootDMsgHandler.hh:648
Status ReadRawOther(Message *msg, Socket *socket, uint32_t &bytesRead)
Handle anything other than kXR_read and kXR_readv in raw mode.
bool pDirListWithStat
Definition: XrdClXRootDMsgHandler.hh:754
std::list< std::unique_ptr< RedirectEntry > > RedirectTraceBack
Definition: XrdClXRootDMsgHandler.hh:643
uint64_t GetSessionId() const
Get the session ID the message is meant for.
Definition: XrdClMessage.hh:90
Definition: XrdSysPthread.hh:78
XrdSys::KernelBuffer * pKBuff
Definition: XrdClXRootDMsgHandler.hh:703
std::vector< uint32_t > pPgReadCksums
Definition: XrdClXRootDMsgHandler.hh:719
bool pReadVRawMsgDiscard
Definition: XrdClXRootDMsgHandler.hh:727
static const int PageSize
Definition: XrdSysPageSize.hh:36
Message * pResponse
Definition: XrdClXRootDMsgHandler.hh:684
RedirectEntry(const URL &from, const URL &to, Type type)
Definition: XrdClXRootDMsgHandler.hh:70
bool IsValid() const
Is the url valid.
static size_t NbPages(uint32_t dlen)
Definition: XrdClXRootDMsgHandler.hh:650
XRootDStatus pStatus
Definition: XrdClXRootDMsgHandler.hh:692
XRootDStatus status
Definition: XrdClXRootDMsgHandler.hh:79
Request status.
Definition: XrdClXRootDResponses.hh:218
URL * pEffectiveDataServerUrl
Definition: XrdClXRootDMsgHandler.hh:688
Definition: XrdClAnyObject.hh:25
Status ReadPageAsync(Socket *socket, uint32_t &bytesRead)
void TakeDownTimeoutFence()
Take down the timeout fence after oksofar response has been handled.
Status PostProcessReadV(VectorReadInfo *vReadInfo)
Post process vector read.
Message handler.
Definition: XrdClPostMasterInterfaces.hh:71
Type type
Definition: XrdClXRootDMsgHandler.hh:78
int pAggregatedWaitTime
Definition: XrdClXRootDMsgHandler.hh:734
void SwitchOnRefreshFlag()
Switch on the refresh flag for some requests.
void SetChunkList(ChunkList *chunkList)
Set the chunk list.
Definition: XrdClXRootDMsgHandler.hh:380
bool pDirListStarted
Definition: XrdClXRootDMsgHandler.hh:753
void SetRedirectAsAnswer(bool redirectAsAnswer)
Definition: XrdClXRootDMsgHandler.hh:335
Definition: XProtocol.hh:141
std::string pRedirectUrl
Definition: XrdClXRootDMsgHandler.hh:701
Definition: XrdSysKernelBuffer.hh:45
URL url
URL of the host.
Definition: XrdClXRootDResponses.hh:1042
Definition: XProtocol.hh:154
bool sizeError
Definition: XrdClXRootDMsgHandler.hh:639
bool pRedirectAsAnswer
Definition: XrdClXRootDMsgHandler.hh:695
bool pStateful
Definition: XrdClXRootDMsgHandler.hh:733
void HandleLocalRedirect(URL *url)
Handle a redirect to a local file.
Vector read info.
Definition: XrdClXRootDResponses.hh:985
Handle an async response.
Definition: XrdClXRootDResponses.hh:1050
void SetStateful(bool stateful)
Definition: XrdClXRootDMsgHandler.hh:410
Definition: XrdClLocalFileHandler.hh:32
uint32_t pAsyncMsgSize
Definition: XrdClXRootDMsgHandler.hh:713
const Message * GetRequest() const
Get the request pointer.
Definition: XrdClXRootDMsgHandler.hh:352
virtual bool IsRaw() const
Are we a raw writer or not?
uint32_t pAsyncReadSize
Definition: XrdClXRootDMsgHandler.hh:711
URL representation.
Definition: XrdClURL.hh:30
uint32_t pAsyncOffset
Definition: XrdClXRootDMsgHandler.hh:708
bool OmitWait(Message *request, const URL &url)
bool pReadVRawSizeError
Definition: XrdClXRootDMsgHandler.hh:724
std::unique_ptr< RedirectEntry > pRdirEntry
Definition: XrdClXRootDMsgHandler.hh:736
HostList * pHosts
Definition: XrdClXRootDMsgHandler.hh:697
int32_t pReadVRawChunkIndex
Definition: XrdClXRootDMsgHandler.hh:725
Definition: XrdClXRootDMsgHandler.hh:64
void WaitDone(time_t now)
size_t pSslErrCnt
Definition: XrdClXRootDMsgHandler.hh:765
virtual uint8_t OnStreamEvent(StreamEvent event, XRootDStatus status)
XRootDStatus * ProcessStatus()
Extract the status information from the stuff that we got.
std::array< char, 4 > pPgReadCksumBuff
Definition: XrdClXRootDMsgHandler.hh:718
Status pLastError
Definition: XrdClXRootDMsgHandler.hh:693
uint32_t pReadRawCurrentOffset
Definition: XrdClXRootDMsgHandler.hh:716
Message status handler.
Definition: XrdClPostMasterInterfaces.hh:184
const uint16_t suRetry
Definition: XrdClStatus.hh:40
Definition: XrdClXRootDMsgHandler.hh:67
A hub for dispatching and receiving messages.
Definition: XrdClPostMaster.hh:47
Type
Definition: XrdClXRootDMsgHandler.hh:62
bool pReadVRawChunkHeaderStarted
Definition: XrdClXRootDMsgHandler.hh:723
HostInfo pLoadBalancer
Definition: XrdClXRootDMsgHandler.hh:699
static PostMaster * GetPostMaster()
Get default post master.
Handle/Process/Forward XRootD messages.
Definition: XrdClXRootDMsgHandler.hh:109
XrdSysCondVar pCV
Definition: XrdClXRootDMsgHandler.hh:760
bool IsRetriable(Message *request)
void Debug(uint64_t topic, const char *format,...)
Print a debug message.
void HandleResponse()
Unpack the message and call the response handler.
bool pHasLoadBalancer
Definition: XrdClXRootDMsgHandler.hh:698
ResponseHandler * pResponseHandler
Definition: XrdClXRootDMsgHandler.hh:686
Definition: XrdClXRootDMsgHandler.hh:60
bool pMsgInFly
Definition: XrdClXRootDMsgHandler.hh:739
Status ReadAsync(Socket *socket, uint32_t &bytesRead)
Definition: XrdClXRootDMsgHandler.hh:454
A network socket.
Definition: XrdClSocket.hh:41
void SetOksofarAsAnswer(bool oksofarAsAnswer)
Definition: XrdClXRootDMsgHandler.hh:344
void DumpRedirectTraceBack()
Dump the redirect-trace-back into the log file.
virtual uint16_t InspectStatusRsp(Message *msg)
Handle diagnostics.
Definition: XrdClLog.hh:100
void SetLoadBalancer(const HostInfo &loadBalancer)
Set the load balancer.
Definition: XrdClXRootDMsgHandler.hh:360
uint32_t pAsyncChunkOffset
Definition: XrdClXRootDMsgHandler.hh:709
Definition: XrdClXRootDMsgHandler.hh:66
readahead_list pReadVRawChunkHeader
Definition: XrdClXRootDMsgHandler.hh:726
void SetHostList(HostList *hostList)
Set host list.
Definition: XrdClXRootDMsgHandler.hh:371