Loading...
Searching...
No Matches
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 ResponseHandler * | Wrap (std::function< void(XRootDStatus &, AnyObject &)> func)
static ResponseHandler * | Wrap (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.

:
pRedirector( mr ), pUserHandler( userHandler ), pBuffer(
new char[DefaultCPChunkSize] ), pContent( content )
{
}
XrdCl::DefaultCPChunkSize
const int DefaultCPChunkSize
Definition XrdClConstants.hh:61

References XrdCl::DefaultCPChunkSize.

Referenced by HandleResponse().

Here is the caller graph for this function:

## ~MetalinkReadHandler()

virtual XrdCl::MetalinkReadHandler::~MetalinkReadHandler | ( |  | ) |

inline virtual

Definition at line 63 of file XrdClMetalinkRedirector.cc.

{
delete[] pBuffer;
}

## Member Function Documentation

## GetBuffer()

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

inline

Definition at line 138 of file XrdClMetalinkRedirector.cc.

{
return pBuffer;
}

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 )

inline virtual

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

Parameters

  status | status of the request
  response | an object associated with the response (request dependent)

Reimplemented from XrdCl::ResponseHandler.

Definition at line 71 of file XrdClMetalinkRedirector.cc.

{
try
{
// check the status
if( !status->IsOK() )
throw status;
// we don't need it anymore
delete status;
// make sure we got a response
if( !response )
throw new XRootDStatus( stError, errInternal );
// make sure the response is not empty
ChunkInfo * info = 0;
response->Get( info );
if( !info )
throw new XRootDStatus( stError, errInternal );
uint32_t bytesRead = info->length;
uint64_t offset = info->offset + bytesRead;
pContent += std::string( pBuffer, bytesRead );
// are we done ?
if( bytesRead > 0 )
{
// lets try to read another chunk
MetalinkReadHandler * mrh = new MetalinkReadHandler( pRedirector,
pUserHandler, pContent );
XRootDStatus st = pRedirector->pFile->Read( offset,
DefaultCPChunkSize, mrh->GetBuffer(), mrh );
if( !st.IsOK() )
{
delete mrh;
throw new XRootDStatus( st );
}
}
else // we have the whole metalink file
{
// we don't need the File object anymore
delete pRedirector->pFile;
pRedirector->pFile = 0;
// now we can parse the metalink file
XRootDStatus st = pRedirector->Parse( pContent );
// now with the redirector fully initialized we can handle pending requests
pRedirector->FinalizeInitialization();
// we are done, pass the status to the user (whatever it is)
if( pUserHandler )
pUserHandler->HandleResponse( new XRootDStatus( st ), 0 );
}
// clean up
delete response;
}
catch( XRootDStatus *status )
{
pRedirector->FinalizeInitialization( *status );
// if we were not able to read from the metalink,
// propagate the error to the user handler
if( pUserHandler )
pUserHandler->HandleResponse( status, 0 );
else
DeallocArgs( status, response, 0 );
}
delete this;
}
XrdCl::MetalinkReadHandler::MetalinkReadHandler
MetalinkReadHandler(MetalinkRedirector *mr, ResponseHandler *userHandler, const std::string &content="")
Definition XrdClMetalinkRedirector.cc:53
XrdCl::stError
const uint16_t stError
An error occurred that could potentially be retried.
Definition XrdClStatus.hh:32
XrdCl::errInternal
const uint16_t errInternal
Internal error.
Definition XrdClStatus.hh:56
XrdCl::DeallocArgs
void DeallocArgs(XRootDStatus *status, AnyObject *response, HostList *hostList)
Definition XrdClMetalinkRedirector.cc:32

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

Here is the call graph for this function:

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

- XrdClMetalinkRedirector.cc