XRootD
XrdCl::MetalinkReadHandler Class Reference
+ Inheritance diagram for XrdCl::MetalinkReadHandler:
+ Collaboration diagram for XrdCl::MetalinkReadHandler:

Public Member Functions

 MetalinkReadHandler (MetalinkRedirector *mr, ResponseHandler *userHandler, const std::string &content="")
 
virtual ~MetalinkReadHandler ()
 
char * GetBuffer ()
 
virtual void HandleResponse (XRootDStatus *status, AnyObject *response)
 
- Public Member Functions inherited from XrdCl::ResponseHandler
virtual ~ResponseHandler ()
 
virtual void HandleResponseWithHosts (XRootDStatus *status, AnyObject *response, HostList *hostList)
 

Additional Inherited Members

- Static Public Member Functions inherited from XrdCl::ResponseHandler
static ResponseHandlerWrap (std::function< void(XRootDStatus &, AnyObject &)> func)
 
static ResponseHandlerWrap (std::function< void(XRootDStatus *, AnyObject *)> func)
 

Detailed Description

Definition at line 47 of file XrdClMetalinkRedirector.cc.

Constructor & Destructor Documentation

◆ MetalinkReadHandler()

XrdCl::MetalinkReadHandler::MetalinkReadHandler ( MetalinkRedirector mr,
ResponseHandler userHandler,
const std::string &  content = "" 
)
inline

Definition at line 53 of file XrdClMetalinkRedirector.cc.

54  :
55  pRedirector( mr ), pUserHandler( userHandler ), pBuffer(
56  new char[DefaultCPChunkSize] ), pContent( content )
57  {
58  }
const int DefaultCPChunkSize

Referenced by HandleResponse().

+ Here is the caller graph for this function:

◆ ~MetalinkReadHandler()

virtual XrdCl::MetalinkReadHandler::~MetalinkReadHandler ( )
inlinevirtual

Definition at line 63 of file XrdClMetalinkRedirector.cc.

64  {
65  delete[] pBuffer;
66  }

Member Function Documentation

◆ GetBuffer()

char* XrdCl::MetalinkReadHandler::GetBuffer ( )
inline

Definition at line 138 of file XrdClMetalinkRedirector.cc.

139  {
140  return pBuffer;
141  }

Referenced by HandleResponse(), and XrdCl::MetalinkOpenHandler::HandleResponseWithHosts().

+ Here is the caller graph for this function:

◆ HandleResponse()

virtual void XrdCl::MetalinkReadHandler::HandleResponse ( XRootDStatus status,
AnyObject response 
)
inlinevirtual

Called when a response to associated request arrives or an error occurs

Parameters
statusstatus of the request
responsean object associated with the response (request dependent)

Reimplemented from XrdCl::ResponseHandler.

Definition at line 71 of file XrdClMetalinkRedirector.cc.

72  {
73  try
74  {
75  // check the status
76  if( !status->IsOK() )
77  throw status;
78  // we don't need it anymore
79  delete status;
80  // make sure we got a response
81  if( !response )
82  throw new XRootDStatus( stError, errInternal );
83  // make sure the response is not empty
84  ChunkInfo * info = 0;
85  response->Get( info );
86  if( !info )
87  throw new XRootDStatus( stError, errInternal );
88  uint32_t bytesRead = info->length;
89  uint64_t offset = info->offset + bytesRead;
90  pContent += std::string( pBuffer, bytesRead );
91  // are we done ?
92  if( bytesRead > 0 )
93  {
94  // lets try to read another chunk
95  MetalinkReadHandler * mrh = new MetalinkReadHandler( pRedirector,
96  pUserHandler, pContent );
97  XRootDStatus st = pRedirector->pFile->Read( offset,
98  DefaultCPChunkSize, mrh->GetBuffer(), mrh );
99  if( !st.IsOK() )
100  {
101  delete mrh;
102  throw new XRootDStatus( st );
103  }
104  }
105  else // we have the whole metalink file
106  {
107  // we don't need the File object anymore
108  delete pRedirector->pFile;
109  pRedirector->pFile = 0;
110  // now we can parse the metalink file
111  XRootDStatus st = pRedirector->Parse( pContent );
112  // now with the redirector fully initialized we can handle pending requests
113  pRedirector->FinalizeInitialization();
114  // we are done, pass the status to the user (whatever it is)
115  if( pUserHandler )
116  pUserHandler->HandleResponse( new XRootDStatus( st ), 0 );
117  }
118  // clean up
119  delete response;
120  }
121  catch( XRootDStatus *status )
122  {
123  pRedirector->FinalizeInitialization( *status );
124  // if we were not able to read from the metalink,
125  // propagate the error to the user handler
126  if( pUserHandler )
127  pUserHandler->HandleResponse( status, 0 );
128  else
129  DeallocArgs( status, response, 0 );
130  }
131 
132  delete this;
133  }
XRootDStatus Read(uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
Definition: XrdClFile.cc:206
MetalinkReadHandler(MetalinkRedirector *mr, ResponseHandler *userHandler, const std::string &content="")
virtual void HandleResponse(XRootDStatus *status, AnyObject *response)
const uint16_t stError
An error occurred that could potentially be retried.
Definition: XrdClStatus.hh:32
const uint16_t errInternal
Internal error.
Definition: XrdClStatus.hh:56
void DeallocArgs(XRootDStatus *status, AnyObject *response, HostList *hostList)

References MetalinkReadHandler(), XrdCl::DeallocArgs(), XrdCl::DefaultCPChunkSize, XrdCl::errInternal, XrdCl::AnyObject::Get(), GetBuffer(), XrdCl::ResponseHandler::HandleResponse(), XrdCl::Status::IsOK(), XrdCl::ChunkInfo::length, XrdCl::ChunkInfo::offset, XrdCl::File::Read(), and XrdCl::stError.

+ Here is the call graph for this function:

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