xrootd
XrdClRedirectorRegistry.hh
Go to the documentation of this file.
1/*
2 * XrdClRedirectorRegister.hh
3 *
4 * Created on: May 23, 2016
5 * Author: simonm
6 */
7
8#ifndef SRC_XRDCL_XRDCLREDIRECTORREGISTRY_HH_
9#define SRC_XRDCL_XRDCLREDIRECTORREGISTRY_HH_
10
12#include "XrdCl/XrdClURL.hh"
15
16#include <string>
17#include <vector>
18#include <map>
19
20namespace XrdCl
21{
22
23class Message;
24class IncomingMsgHandler;
25class OutgoingMsgHandler;
26
27//--------------------------------------------------------------------------------
29//--------------------------------------------------------------------------------
30class RedirectJob: public Job
31{
32 public:
33 //------------------------------------------------------------------------
35 //------------------------------------------------------------------------
36 RedirectJob( IncomingMsgHandler *handler ) : pHandler( handler )
37 {
38 }
39
40 //------------------------------------------------------------------------
42 //------------------------------------------------------------------------
43 virtual ~RedirectJob()
44 {
45 }
46
47 //------------------------------------------------------------------------
49 //------------------------------------------------------------------------
50 virtual void Run( void *arg );
51
52 private:
54};
55
56//--------------------------------------------------------------------------------
58//--------------------------------------------------------------------------------
60{
61 public:
62 //----------------------------------------------------------------------------
64 //----------------------------------------------------------------------------
66
67 //----------------------------------------------------------------------------
72 //----------------------------------------------------------------------------
73 virtual XRootDStatus HandleRequest( const Message *msg,
74 IncomingMsgHandler *handler ) = 0;
75
76 //----------------------------------------------------------------------------
78 //----------------------------------------------------------------------------
79 virtual XRootDStatus Load( ResponseHandler *userHandler ) = 0;
80
81 //----------------------------------------------------------------------------
83 //----------------------------------------------------------------------------
84 virtual std::string GetTargetName() const = 0;
85
86 //----------------------------------------------------------------------------
89 //----------------------------------------------------------------------------
90 virtual std::string GetCheckSum( const std::string &type ) const = 0;
91
92 //----------------------------------------------------------------------------
95 //----------------------------------------------------------------------------
96 virtual std::vector<std::string> GetSupportedCheckSums() const = 0;
97
98 //----------------------------------------------------------------------------
101 //----------------------------------------------------------------------------
102 virtual long long GetSize() const = 0;
103
104 //----------------------------------------------------------------------------
106 //----------------------------------------------------------------------------
107 virtual const std::vector<std::string>& GetReplicas() = 0;
108
109 //----------------------------------------------------------------------------
111 //----------------------------------------------------------------------------
112 virtual int Count( Message *req ) const = 0;
113};
114
115//--------------------------------------------------------------------------------
117//--------------------------------------------------------------------------------
119{
120
121 public:
122
123 //----------------------------------------------------------------------------
125 //----------------------------------------------------------------------------
127
128 //----------------------------------------------------------------------------
130 //----------------------------------------------------------------------------
132
133 //----------------------------------------------------------------------------
135 //----------------------------------------------------------------------------
136 XRootDStatus Register( const URL &url );
137
138 //----------------------------------------------------------------------------
140 //----------------------------------------------------------------------------
142
143 //----------------------------------------------------------------------------
145 //----------------------------------------------------------------------------
146 VirtualRedirector* Get( const URL &url ) const;
147
148 //----------------------------------------------------------------------------
150 //----------------------------------------------------------------------------
151 void Release( const URL &url );
152
153 private:
154
155 typedef std::map< std::string, std::pair<VirtualRedirector*, size_t> > RedirectorMap;
156
157 //----------------------------------------------------------------------------
159 //----------------------------------------------------------------------------
161
162 //----------------------------------------------------------------------------
167 //----------------------------------------------------------------------------
168 static URL ConvertLocalfile( const URL &url );
169
170 //----------------------------------------------------------------------------
171 // Constructor (private!).
172 //----------------------------------------------------------------------------
174
175 //----------------------------------------------------------------------------
176 // Copy constructor (private!).
177 //----------------------------------------------------------------------------
179
180 //----------------------------------------------------------------------------
181 // Assignment operator (private!).
182 //----------------------------------------------------------------------------
184
186
188};
189
190} /* namespace XrdCl */
191
192#endif /* SRC_XRDCL_XRDCLREDIRECTORREGISTRY_HH_ */
Message handler.
Definition: XrdClPostMasterInterfaces.hh:69
Interface for a job to be run by the job manager.
Definition: XrdClJobManager.hh:34
The message representation used throughout the system.
Definition: XrdClMessage.hh:30
A job class for redirect handling in the thread-pool.
Definition: XrdClRedirectorRegistry.hh:31
virtual ~RedirectJob()
Destructor.
Definition: XrdClRedirectorRegistry.hh:43
RedirectJob(IncomingMsgHandler *handler)
Constructor.
Definition: XrdClRedirectorRegistry.hh:36
IncomingMsgHandler * pHandler
Definition: XrdClRedirectorRegistry.hh:53
virtual void Run(void *arg)
Run the user handler.
Singleton access to URL to virtual redirector mapping.
Definition: XrdClRedirectorRegistry.hh:119
~RedirectorRegistry()
Destructor.
static URL ConvertLocalfile(const URL &url)
static RedirectorRegistry & Instance()
Returns reference to the single instance.
RedirectorRegistry()
Definition: XrdClRedirectorRegistry.hh:173
XRootDStatus RegisterImpl(const URL &url, ResponseHandler *handler)
Register implementation.
void Release(const URL &url)
Release the virtual redirector associated with the given URL.
XrdSysMutex pMutex
Definition: XrdClRedirectorRegistry.hh:187
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.
RedirectorRegistry(const RedirectorRegistry &)
std::map< std::string, std::pair< VirtualRedirector *, size_t > > RedirectorMap
Definition: XrdClRedirectorRegistry.hh:155
RedirectorMap pRegistry
Definition: XrdClRedirectorRegistry.hh:185
XRootDStatus Register(const URL &url)
Creates a new virtual redirector and registers it (async).
RedirectorRegistry & operator=(const RedirectorRegistry &)
Handle an async response.
Definition: XrdClXRootDResponses.hh:855
URL representation.
Definition: XrdClURL.hh:31
An interface for metadata redirectors.
Definition: XrdClRedirectorRegistry.hh:60
virtual long long GetSize() const =0
virtual XRootDStatus HandleRequest(const Message *msg, IncomingMsgHandler *handler)=0
virtual XRootDStatus Load(ResponseHandler *userHandler)=0
Initializes the object with the content of the metalink file.
virtual std::string GetCheckSum(const std::string &type) const =0
virtual std::string GetTargetName() const =0
Gets the file name as specified in the metalink.
virtual std::vector< std::string > GetSupportedCheckSums() const =0
virtual ~VirtualRedirector()
Destructor.
Definition: XrdClRedirectorRegistry.hh:65
virtual const std::vector< std::string > & GetReplicas()=0
Returns a vector with replicas as given in the meatlink file.
virtual int Count(Message *req) const =0
Count how many replicas do we have left to try for given request.
Request status.
Definition: XrdClXRootDResponses.hh:213
Definition: XrdSysPthread.hh:166
Definition: XrdClAnyObject.hh:26