Loading...
Searching...
No Matches
XrdClMetalinkRedirector.hh
Go to the documentation of this file.
/*
* XrdClMetalinkRedirector.hh
*
* Created on: May 2, 2016
* Author: simonm
*/
#ifndef SRC_XRDCL_XRDCLMETALINKREDIRECTOR_HH_
#define SRC_XRDCL_XRDCLMETALINKREDIRECTOR_HH_
#include "XrdCl/XrdClMessageUtils.hh"
#include "XrdCl/XrdClRedirectorRegistry.hh"
#include <string>
#include <list>
#include <map>
class XrdOucFileInfo;
namespace XrdCl
{
class File;
class Message;
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
class MetalinkRedirector : public VirtualRedirector
{
friend class MetalinkOpenHandler;
friend class MetalinkReadHandler;
public:
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
MetalinkRedirector( const std::string &url );
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
virtual ~MetalinkRedirector();
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
XRootDStatus Load( ResponseHandler *userHandler );
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
XRootDStatus HandleRequest( const Message *msg, MsgHandler *handler );
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
std::string GetTargetName() const
{
return pTarget;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
std::string GetCheckSum( const std::string &type ) const
{
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;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
std::vector<std::string> GetSupportedCheckSums() const
{
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;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
long long GetSize() const
{
return pFileSize;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
const std::vector<std::string>& GetReplicas()
{
return pReplicas;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
virtual int Count( Message &req ) const;
private:
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
XRootDStatus HandleRequestImpl( const Message *msg, MsgHandler *handler );
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
XRootDStatus Parse( const std::string &metalink );
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void FinalizeInitialization( const XRootDStatus &status = XRootDStatus() );
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
std::shared_ptr<Message> GetResponse( const Message *msg ) const;
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
std::shared_ptr<Message> GetErrorMsg( const Message *msg, const std::string &errMsg, XErrorCode code ) const;
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void InitCksum( XrdOucFileInfo **fileInfos );
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void InitReplicas( XrdOucFileInfo **fileInfos );
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
XRootDStatus GetReplica( const Message &msg, std::string &replica ) const;
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
XRootDStatus GetCgiInfo( const Message &msg, const std::string &key, std::string &out ) const;
typedef std::list< std::pair<const Message*, MsgHandler*> > RedirectList;
typedef std::map<std::string, std::string> CksumMap;
typedef std::vector<std::string> ReplicaList;
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
ReplicaList::const_iterator GetReplica( const Message &msg ) const;
RedirectList pPendingRedirects;
std::string pUrl;
File *pFile;
CksumMap pChecksums;
ReplicaList pReplicas;
bool pReady;
XRootDStatus pStatus;
std::string pTarget;
long long pFileSize;
XrdSysMutex pMutex;
static const std::string LocalFile;
};
} /* namespace XrdCl */
#endif /* SRC_XRDCL_XRDCLMETALINKREDIRECTOR_HH_ */
XErrorCode
XErrorCode
Definition XProtocol.hh:989
XrdClMessageUtils.hh
XrdClRedirectorRegistry.hh
XrdCl::File
A file.
Definition XrdClFile.hh:46
XrdCl::Message
The message representation used throughout the system.
Definition XrdClMessage.hh:32
XrdCl::MetalinkRedirector::MetalinkOpenHandler
friend class MetalinkOpenHandler
Definition XrdClMetalinkRedirector.hh:33
XrdCl::MetalinkRedirector::MetalinkReadHandler
friend class MetalinkReadHandler
Definition XrdClMetalinkRedirector.hh:34
XrdCl::MetalinkRedirector::GetCheckSum
std::string GetCheckSum(const std::string &type) const
Definition XrdClMetalinkRedirector.hh:73
XrdCl::MetalinkRedirector::GetReplicas
const std::vector< std::string > & GetReplicas()
Returns a vector with replicas as given in the meatlink file.
Definition XrdClMetalinkRedirector.hh:109
XrdCl::MetalinkRedirector::Load
XRootDStatus Load(ResponseHandler *userHandler)
Definition XrdClMetalinkRedirector.cc:235
XrdCl::MetalinkRedirector::~MetalinkRedirector
virtual ~MetalinkRedirector()
Destructor.
Definition XrdClMetalinkRedirector.cc:227
XrdCl::MetalinkRedirector::HandleRequest
XRootDStatus HandleRequest(const Message *msg, MsgHandler *handler)
Definition XrdClMetalinkRedirector.cc:381
XrdCl::MetalinkRedirector::GetSupportedCheckSums
std::vector< std::string > GetSupportedCheckSums() const
Definition XrdClMetalinkRedirector.hh:85
XrdCl::MetalinkRedirector::GetSize
long long GetSize() const
Definition XrdClMetalinkRedirector.hh:101
XrdCl::MetalinkRedirector::MetalinkRedirector
MetalinkRedirector(const std::string &url)
Definition XrdClMetalinkRedirector.cc:218
XrdCl::MetalinkRedirector::GetTargetName
std::string GetTargetName() const
Gets the file name as specified in the metalink.
Definition XrdClMetalinkRedirector.hh:64
XrdCl::MetalinkRedirector::Count
virtual int Count(Message &req) const
Count how many replicas do we have left to try for given request.
Definition XrdClMetalinkRedirector.cc:399
XrdCl::MsgHandler
Message handler.
Definition XrdClPostMasterInterfaces.hh:51
XrdCl::ResponseHandler
Handle an async response.
Definition XrdClXRootDResponses.hh:1127
XrdCl::VirtualRedirector
An interface for metadata redirectors.
Definition XrdClRedirectorRegistry.hh:60
XrdCl::XRootDStatus
Request status.
Definition XrdClXRootDResponses.hh:219
XrdOucFileInfo
Definition XrdOucFileInfo.hh:46
XrdSysMutex
Definition XrdSysPthread.hh:165
XrdCl
Definition XrdClAction.hh:34
XrdCl::GetResponse
Response * GetResponse(AnyObject *rsp)
Definition XrdClOperationHandlers.hh:137