15 #include <arpa/inet.h>
23 if( pHandler->
Examine( msg ) != MsgHandler::Action::Ignore )
37 RedirectorMap::iterator itr;
38 for( itr = pRegistry.begin(); itr != pRegistry.end(); ++itr )
39 delete itr->second.first;
44 URL url = ConvertLocalfile( u );
57 RedirectorMap::iterator itr = pRegistry.find( key );
58 if( itr != pRegistry.end() )
68 MetalinkRedirector *redirector =
new MetalinkRedirector( key );
69 XRootDStatus st = redirector->Load( handler );
73 pRegistry[key] = std::pair<VirtualRedirector*, size_t>( redirector, 1 );
81 URL RedirectorRegistry::ConvertLocalfile(
const URL &url )
86 if( localml && url.GetProtocol() ==
"root" && url.GetHostName() ==
"localfile" )
90 "Please note that the 'root://localfile//path/filename.meta4' "
91 "semantic is now deprecated, use 'file://localhost/path/filename.meta4'"
95 copy.SetHostName(
"localhost" );
96 copy.SetProtocol(
"file" );
105 return RegisterImpl( url, 0 );
111 Status st = RegisterImpl( url, &handler );
112 if( !st.
IsOK() )
return st;
118 URL url = ConvertLocalfile( u );
124 RedirectorMap::const_iterator itr = pRegistry.find( key );
125 if( itr != pRegistry.end() )
126 return itr->second.first;
136 URL url = ConvertLocalfile( u );
142 RedirectorMap::iterator itr = pRegistry.find( key );
143 if( itr == pRegistry.end() )
return;
145 --itr->second.second;
148 if( !itr->second.second )
150 delete itr->second.first;
151 pRegistry.erase( itr );
static Log * GetLog()
Get default log.
static Env * GetEnv()
Get default client environment.
bool GetInt(const std::string &key, int &value)
static XRootDStatus WaitForStatus(SyncResponseHandler *handler)
Wait and return the status of the query.
virtual uint16_t Examine(std::shared_ptr< Message > &msg)=0
virtual void Run(void *arg)
Run the user handler.
Singleton access to URL to virtual redirector mapping.
~RedirectorRegistry()
Destructor.
static RedirectorRegistry & Instance()
Returns reference to the single instance.
void Release(const URL &url)
Release the virtual redirector associated with the given URL.
XRootDStatus RegisterAndWait(const URL &url)
Creates a new virtual redirector and registers it (sync).
VirtualRedirector * Get(const URL &url) const
Get a virtual redirector associated with the given URL.
XRootDStatus Register(const URL &url)
Creates a new virtual redirector and registers it (async).
Handle an async response.
virtual void HandleResponseWithHosts(XRootDStatus *status, AnyObject *response, HostList *hostList)
Synchronize the response.
bool IsMetalink() const
Is it a URL to a metalink.
const std::string & GetHostName() const
Get the name of the target host.
const std::string & GetProtocol() const
Get the protocol.
std::string GetLocation() const
Get location (protocol://host:port/path)
const std::string & GetPath() const
Get the path.
An interface for metadata redirectors.
const uint16_t stError
An error occurred that could potentially be retried.
const uint64_t PostMasterMsg
const uint16_t stOK
Everything went OK.
const int DefaultLocalMetalinkFile
const uint16_t suAlreadyDone
const uint16_t errNotSupported
Procedure execution status.
bool IsOK() const
We're fine.