Loading...
Searching...
No Matches
XrdCl::MetalinkRedirector Class Reference

`#include <XrdClMetalinkRedirector.hh>`

Inheritance diagram for XrdCl::MetalinkRedirector:
Collaboration diagram for XrdCl::MetalinkRedirector:

## Public Member Functions

| MetalinkRedirector (const std::string &url)
virtual | ~MetalinkRedirector ()
| Destructor.
virtual int | Count (Message &req) const
| Count how many replicas do we have left to try for given request.
std::string | GetCheckSum (const std::string &type) const
const std::vector< std::string > & | GetReplicas ()
| Returns a vector with replicas as given in the meatlink file.
long long | GetSize () const
std::vector< std::string > | GetSupportedCheckSums () const
std::string | GetTargetName () const
| Gets the file name as specified in the metalink.
XRootDStatus | HandleRequest (const Message *msg, MsgHandler *handler)
XRootDStatus | Load (ResponseHandler *userHandler)
Public Member Functions inherited from XrdCl::VirtualRedirector
virtual | ~VirtualRedirector ()
| Destructor.

## Friends

class | MetalinkOpenHandler
class | MetalinkReadHandler

## Detailed Description

An abstraction representing a virtual redirector based on a metalink file

Definition at line 31 of file XrdClMetalinkRedirector.hh.

## Constructor & Destructor Documentation

## MetalinkRedirector()

XrdCl::MetalinkRedirector::MetalinkRedirector | ( | const std::string & | url | ) |

Constructor

Parameters

  url | : URL to the metalink file

Definition at line 218 of file XrdClMetalinkRedirector.cc.

:
pUrl( url ), pFile( new File( File::DisableVirtRedirect ) ), pReady(
false ), pFileSize( -1 )
{
}
File
XrdOucString File
Definition XrdSecpwdSrvAdmin.cc:159
XrdCl::File::DisableVirtRedirect
@ DisableVirtRedirect
Definition XrdClFile.hh:52

## ~MetalinkRedirector()

XrdCl::MetalinkRedirector::~MetalinkRedirector | ( |  | ) |

virtual

Destructor.

Definition at line 227 of file XrdClMetalinkRedirector.cc.

{
delete pFile;
}

## Member Function Documentation

## Count()

int XrdCl::MetalinkRedirector::Count | ( | Message & | req | ) | const

virtual

Count how many replicas do we have left to try for given request.

Implements XrdCl::VirtualRedirector.

Definition at line 399 of file XrdClMetalinkRedirector.cc.

{
ReplicaList::const_iterator itr = GetReplica( req );
return pReplicas.end() - itr;
}

## GetCheckSum()

std::string XrdCl::MetalinkRedirector::GetCheckSum | ( | const std::string & | type | ) | const

inline virtual

Returns the checksum of the given type if specified in the metalink file, or an empty string otherwise

Implements XrdCl::VirtualRedirector.

Definition at line 73 of file XrdClMetalinkRedirector.hh.

{
std::string t = type != "adler32" ? type : "a32";
CksumMap::const_iterator it = pChecksums.find( t );
if( it == pChecksums.end() ) return std::string();
return type + ":" + it->second;
}

## GetReplicas()

const std::vector< std::string > & XrdCl::MetalinkRedirector::GetReplicas | ( |  | ) |

inline virtual

Returns a vector with replicas as given in the meatlink file.

Implements XrdCl::VirtualRedirector.

Definition at line 109 of file XrdClMetalinkRedirector.hh.

{
return pReplicas;
}

## GetSize()

long long XrdCl::MetalinkRedirector::GetSize | ( |  | ) | const

inline virtual

Returns the file size if specified in the metalink file, otherwise a negative number

Implements XrdCl::VirtualRedirector.

Definition at line 101 of file XrdClMetalinkRedirector.hh.

{
return pFileSize;
}

## GetSupportedCheckSums()

std::vector< std::string > XrdCl::MetalinkRedirector::GetSupportedCheckSums | ( |  | ) | const

inline virtual

Returns the first (in alphabetical order) checksum type available in the metalink file, if no checksum is available returns an empty string

Implements XrdCl::VirtualRedirector.

Definition at line 85 of file XrdClMetalinkRedirector.hh.

{
std::vector<std::string> ret;
CksumMap::const_iterator itr = pChecksums.begin();
for( ; itr != pChecksums.end(); ++itr )
{
if( itr->first == "a32" ) ret.push_back( "adler32" );
else ret.push_back( itr->first );
}
return ret;
}

## GetTargetName()

std::string XrdCl::MetalinkRedirector::GetTargetName | ( |  | ) | const

inline virtual

Gets the file name as specified in the metalink.

Implements XrdCl::VirtualRedirector.

Definition at line 64 of file XrdClMetalinkRedirector.hh.

{
return pTarget;
}

## HandleRequest()

XRootDStatus XrdCl::MetalinkRedirector::HandleRequest | ( | const Message * | msg,
|  | MsgHandler * | handler )

virtual

If the MetalinkRedirector is initialized creates an instant redirect response, otherwise queues the request until initialization is done.

Implements XrdCl::VirtualRedirector.

Definition at line 381 of file XrdClMetalinkRedirector.cc.

{
XrdSysMutexHelper scopedLck( pMutex );
// if the metalink data haven't been loaded yet, make it pending
if( !pReady )
{
pPendingRedirects.push_back(
std::make_pair( msg, handler ) );;
return XRootDStatus();
}
// otherwise generate a virtual response
return HandleRequestImpl( msg, handler );
}

## Load()

XRootDStatus XrdCl::MetalinkRedirector::Load | ( | ResponseHandler * | userHandler | ) |

virtual

Initializes the object with the content of the metalink file

Parameters

  userHandler | : the response handler provided by end user

Implements XrdCl::VirtualRedirector.

Definition at line 235 of file XrdClMetalinkRedirector.cc.

{
MetalinkOpenHandler *handler = new MetalinkOpenHandler( this, userHandler );
XRootDStatus st = pFile->Open( pUrl, OpenFlags::Read, Access::None, handler,
0 );
if( !st.IsOK() )
delete handler;
return st;
}
XrdCl::MetalinkRedirector::MetalinkOpenHandler
friend class MetalinkOpenHandler
Definition XrdClMetalinkRedirector.hh:33
XrdCl::Access::None
@ None
Definition XrdClFileSystem.hh:123
XrdCl::OpenFlags::Read
@ Read
Open only for reading.
Definition XrdClFileSystem.hh:95

References XrdCl::Status::IsOK(), MetalinkOpenHandler, XrdCl::Access::None, and XrdCl::OpenFlags::Read.

Here is the call graph for this function:

## Friends And Related Symbol Documentation

## MetalinkOpenHandler

friend class MetalinkOpenHandler

friend

Definition at line 33 of file XrdClMetalinkRedirector.hh.

References MetalinkOpenHandler.

Referenced by Load(), and MetalinkOpenHandler.

## MetalinkReadHandler

friend class MetalinkReadHandler

friend

Definition at line 34 of file XrdClMetalinkRedirector.hh.

References MetalinkReadHandler.

Referenced by MetalinkReadHandler.

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

- XrdClMetalinkRedirector.hh
- XrdClMetalinkRedirector.cc