#include <XrdClMetalinkRedirector.hh>
Public Member Functions | |
MetalinkRedirector (const std::string &url) | |
virtual | ~MetalinkRedirector () |
Destructor. | |
XRootDStatus | Load (ResponseHandler *userHandler) |
Initializes the object with the content of the metalink file. | |
XRootDStatus | HandleRequest (const Message *msg, IncomingMsgHandler *handler) |
std::string | GetTargetName () const |
Gets the file name as specified in the metalink. | |
std::string | GetCheckSum (const std::string &type) const |
std::vector< std::string > | GetSupportedCheckSums () const |
long long | GetSize () const |
const std::vector< std::string > & | GetReplicas () |
Returns a vector with replicas as given in the meatlink file. | |
virtual int | Count (Message *req) const |
Count how many replicas do we have left to try for given request. | |
Private Types | |
typedef std::list< std::pair < const Message *, IncomingMsgHandler * > > | RedirectList |
typedef std::map< std::string, std::string > | CksumMap |
typedef std::vector< std::string > | ReplicaList |
Private Member Functions | |
XRootDStatus | HandleRequestImpl (const Message *msg, IncomingMsgHandler *handler) |
XRootDStatus | Parse (const std::string &metalink) |
void | FinalizeInitialization (const XRootDStatus &status=XRootDStatus()) |
Message * | GetResponse (const Message *msg) const |
Generates redirect response for the given request. | |
Message * | GetErrorMsg (const Message *msg, const std::string &errMsg, XErrorCode code) const |
Generates error response for the given request. | |
void | InitCksum (XrdOucFileInfo **fileInfos) |
Initializes checksum map. | |
void | InitReplicas (XrdOucFileInfo **fileInfos) |
Initializes replica list. | |
XRootDStatus | GetReplica (const Message *msg, std::string &replica) const |
Get the next replica for the given message. | |
XRootDStatus | GetCgiInfo (const Message *msg, const std::string &key, std::string &out) const |
Extracts an element from URL cgi. | |
ReplicaList::const_iterator | GetReplica (const Message *msg) const |
Get the next replica for the given message. | |
Private Attributes | |
RedirectList | pPendingRedirects |
std::string | pUrl |
File * | pFile |
CksumMap | pChecksums |
ReplicaList | pReplicas |
bool | pReady |
XRootDStatus | pStatus |
std::string | pTarget |
long long | pFileSize |
XrdSysMutex | pMutex |
Static Private Attributes | |
static const std::string | LocalFile |
Friends | |
class | MetalinkOpenHandler |
class | MetalinkReadHandler |
An abstraction representing a virtual redirector based on a metalink file
typedef std::map<std::string, std::string> XrdCl::MetalinkRedirector::CksumMap [private] |
typedef std::list< std::pair<const Message*, IncomingMsgHandler*> > XrdCl::MetalinkRedirector::RedirectList [private] |
typedef std::vector<std::string> XrdCl::MetalinkRedirector::ReplicaList [private] |
XrdCl::MetalinkRedirector::MetalinkRedirector | ( | const std::string & | url | ) |
Constructor
url | : URL to the metalink file | |
userHandler | : the response handler provided by end user |
virtual XrdCl::MetalinkRedirector::~MetalinkRedirector | ( | ) | [virtual] |
Destructor.
virtual int XrdCl::MetalinkRedirector::Count | ( | Message * | req | ) | const [virtual] |
Count how many replicas do we have left to try for given request.
Implements XrdCl::VirtualRedirector.
void XrdCl::MetalinkRedirector::FinalizeInitialization | ( | const XRootDStatus & | status = XRootDStatus() |
) | [private] |
Finalize the initialization process:
XRootDStatus XrdCl::MetalinkRedirector::GetCgiInfo | ( | const Message * | msg, | |
const std::string & | key, | |||
std::string & | out | |||
) | const [private] |
Extracts an element from URL cgi.
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.
References pChecksums.
Message* XrdCl::MetalinkRedirector::GetErrorMsg | ( | const Message * | msg, | |
const std::string & | errMsg, | |||
XErrorCode | code | |||
) | const [private] |
Generates error response for the given request.
ReplicaList::const_iterator XrdCl::MetalinkRedirector::GetReplica | ( | const Message * | msg | ) | const [private] |
Get the next replica for the given message.
XRootDStatus XrdCl::MetalinkRedirector::GetReplica | ( | const Message * | msg, | |
std::string & | replica | |||
) | const [private] |
Get the next replica for the given message.
const std::vector<std::string>& XrdCl::MetalinkRedirector::GetReplicas | ( | ) | [inline, virtual] |
Returns a vector with replicas as given in the meatlink file.
Implements XrdCl::VirtualRedirector.
References pReplicas.
Generates redirect response for the given request.
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.
References pFileSize.
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.
References pChecksums.
std::string XrdCl::MetalinkRedirector::GetTargetName | ( | ) | const [inline, virtual] |
Gets the file name as specified in the metalink.
Implements XrdCl::VirtualRedirector.
References pTarget.
XRootDStatus XrdCl::MetalinkRedirector::HandleRequest | ( | const Message * | msg, | |
IncomingMsgHandler * | handler | |||
) | [virtual] |
If the MetalinkRedirector is initialized creates an instant redirect response, otherwise queues the request until initialization is done.
Implements XrdCl::VirtualRedirector.
XRootDStatus XrdCl::MetalinkRedirector::HandleRequestImpl | ( | const Message * | msg, | |
IncomingMsgHandler * | handler | |||
) | [private] |
Creates an instant redirect response for the given message or an error response if there are no more replicas to try. The virtual response is being handled by the given handler in the thread-pool.
void XrdCl::MetalinkRedirector::InitCksum | ( | XrdOucFileInfo ** | fileInfos | ) | [private] |
Initializes checksum map.
void XrdCl::MetalinkRedirector::InitReplicas | ( | XrdOucFileInfo ** | fileInfos | ) | [private] |
Initializes replica list.
XRootDStatus XrdCl::MetalinkRedirector::Load | ( | ResponseHandler * | userHandler | ) | [virtual] |
Initializes the object with the content of the metalink file.
Implements XrdCl::VirtualRedirector.
XRootDStatus XrdCl::MetalinkRedirector::Parse | ( | const std::string & | metalink | ) | [private] |
Parses the metalink file
metalink | : the content of the metalink file |
friend class MetalinkOpenHandler [friend] |
friend class MetalinkReadHandler [friend] |
const std::string XrdCl::MetalinkRedirector::LocalFile [static, private] |
Referenced by GetCheckSum(), and GetSupportedCheckSums().
File* XrdCl::MetalinkRedirector::pFile [private] |
long long XrdCl::MetalinkRedirector::pFileSize [private] |
Referenced by GetSize().
XrdSysMutex XrdCl::MetalinkRedirector::pMutex [private] |
bool XrdCl::MetalinkRedirector::pReady [private] |
Referenced by GetReplicas().
std::string XrdCl::MetalinkRedirector::pTarget [private] |
Referenced by GetTargetName().
std::string XrdCl::MetalinkRedirector::pUrl [private] |