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"
13 #include "XrdCl/XrdClJobManager.hh"
14 #include "XrdSys/XrdSysPthread.hh"
15 
16 #include <string>
17 #include <vector>
18 #include <map>
19 
20 namespace XrdCl
21 {
22 
23 class Message;
24 class MsgHandler;
25 
26 //--------------------------------------------------------------------------------
28 //--------------------------------------------------------------------------------
29 class RedirectJob: public Job
30 {
31  public:
32  //------------------------------------------------------------------------
34  //------------------------------------------------------------------------
35  RedirectJob( MsgHandler *handler ) : pHandler( handler )
36  {
37  }
38 
39  //------------------------------------------------------------------------
41  //------------------------------------------------------------------------
42  virtual ~RedirectJob()
43  {
44  }
45 
46  //------------------------------------------------------------------------
48  //------------------------------------------------------------------------
49  virtual void Run( void *arg );
50 
51  private:
53 };
54 
55 //--------------------------------------------------------------------------------
57 //--------------------------------------------------------------------------------
59 {
60  public:
61  //----------------------------------------------------------------------------
63  //----------------------------------------------------------------------------
64  virtual ~VirtualRedirector(){}
65 
66  //----------------------------------------------------------------------------
71  //----------------------------------------------------------------------------
72  virtual XRootDStatus HandleRequest( const Message *msg,
73  MsgHandler *handler ) = 0;
74 
75  //----------------------------------------------------------------------------
77  //----------------------------------------------------------------------------
78  virtual XRootDStatus Load( ResponseHandler *userHandler ) = 0;
79 
80  //----------------------------------------------------------------------------
82  //----------------------------------------------------------------------------
83  virtual std::string GetTargetName() const = 0;
84 
85  //----------------------------------------------------------------------------
88  //----------------------------------------------------------------------------
89  virtual std::string GetCheckSum( const std::string &type ) const = 0;
90 
91  //----------------------------------------------------------------------------
94  //----------------------------------------------------------------------------
95  virtual std::vector<std::string> GetSupportedCheckSums() const = 0;
96 
97  //----------------------------------------------------------------------------
100  //----------------------------------------------------------------------------
101  virtual long long GetSize() const = 0;
102 
103  //----------------------------------------------------------------------------
105  //----------------------------------------------------------------------------
106  virtual const std::vector<std::string>& GetReplicas() = 0;
107 
108  //----------------------------------------------------------------------------
110  //----------------------------------------------------------------------------
111  virtual int Count( Message *req ) const = 0;
112 };
113 
114 //--------------------------------------------------------------------------------
116 //--------------------------------------------------------------------------------
118 {
119 
120  public:
121 
122  //----------------------------------------------------------------------------
124  //----------------------------------------------------------------------------
125  static RedirectorRegistry& Instance();
126 
127  //----------------------------------------------------------------------------
129  //----------------------------------------------------------------------------
131 
132  //----------------------------------------------------------------------------
134  //----------------------------------------------------------------------------
135  XRootDStatus Register( const URL &url );
136 
137  //----------------------------------------------------------------------------
139  //----------------------------------------------------------------------------
140  XRootDStatus RegisterAndWait( const URL &url );
141 
142  //----------------------------------------------------------------------------
144  //----------------------------------------------------------------------------
145  VirtualRedirector* Get( const URL &url ) const;
146 
147  //----------------------------------------------------------------------------
149  //----------------------------------------------------------------------------
150  void Release( const URL &url );
151 
152  private:
153 
154  typedef std::map< std::string, std::pair<VirtualRedirector*, size_t> > RedirectorMap;
155 
156  //----------------------------------------------------------------------------
158  //----------------------------------------------------------------------------
159  XRootDStatus RegisterImpl( const URL &url, ResponseHandler *handler );
160 
161  //----------------------------------------------------------------------------
166  //----------------------------------------------------------------------------
167  static URL ConvertLocalfile( const URL &url );
168 
169  //----------------------------------------------------------------------------
170  // Constructor (private!).
171  //----------------------------------------------------------------------------
173 
174  //----------------------------------------------------------------------------
175  // Copy constructor (private!).
176  //----------------------------------------------------------------------------
178 
179  //----------------------------------------------------------------------------
180  // Assignment operator (private!).
181  //----------------------------------------------------------------------------
183 
185 
187 };
188 
189 } /* namespace XrdCl */
190 
191 #endif /* SRC_XRDCL_XRDCLREDIRECTORREGISTRY_HH_ */
void Release(const URL &url)
Release the virtual redirector associated with the given URL.
static URL ConvertLocalfile(const URL &url)
virtual ~RedirectJob()
Destructor.
Definition: XrdClRedirectorRegistry.hh:42
virtual std::string GetTargetName() const =0
Gets the file name as specified in the metalink.
The message representation used throughout the system.
Definition: XrdClMessage.hh:29
An interface for metadata redirectors.
Definition: XrdClRedirectorRegistry.hh:58
RedirectorRegistry & operator=(const RedirectorRegistry &)
Message handler.
Definition: XrdClPostMasterInterfaces.hh:49
~RedirectorRegistry()
Destructor.
virtual void Run(void *arg)
Run the user handler.
virtual XRootDStatus HandleRequest(const Message *msg, MsgHandler *handler)=0
virtual XRootDStatus Load(ResponseHandler *userHandler)=0
Initializes the object with the content of the metalink file.
XRootDStatus Register(const URL &url)
Creates a new virtual redirector and registers it (async).
A job class for redirect handling in the thread-pool.
Definition: XrdClRedirectorRegistry.hh:29
Definition: XrdSysPthread.hh:164
std::map< std::string, std::pair< VirtualRedirector *, size_t > > RedirectorMap
Definition: XrdClRedirectorRegistry.hh:154
XrdSysMutex pMutex
Definition: XrdClRedirectorRegistry.hh:186
Request status.
Definition: XrdClXRootDResponses.hh:218
virtual int Count(Message *req) const =0
Count how many replicas do we have left to try for given request.
Definition: XrdClAnyObject.hh:25
XRootDStatus RegisterAndWait(const URL &url)
Creates a new virtual redirector and registers it (sync).
virtual ~VirtualRedirector()
Destructor.
Definition: XrdClRedirectorRegistry.hh:64
VirtualRedirector * Get(const URL &url) const
Get a virtual redirector associated with the given URL.
virtual const std::vector< std::string > & GetReplicas()=0
Returns a vector with replicas as given in the meatlink file.
virtual std::vector< std::string > GetSupportedCheckSums() const =0
RedirectJob(MsgHandler *handler)
Constructor.
Definition: XrdClRedirectorRegistry.hh:35
Handle an async response.
Definition: XrdClXRootDResponses.hh:1050
URL representation.
Definition: XrdClURL.hh:30
XRootDStatus RegisterImpl(const URL &url, ResponseHandler *handler)
Register implementation.
MsgHandler * pHandler
Definition: XrdClRedirectorRegistry.hh:52
RedirectorMap pRegistry
Definition: XrdClRedirectorRegistry.hh:184
Interface for a job to be run by the job manager.
Definition: XrdClJobManager.hh:33
Singleton access to URL to virtual redirector mapping.
Definition: XrdClRedirectorRegistry.hh:117
virtual std::string GetCheckSum(const std::string &type) const =0
virtual long long GetSize() const =0
RedirectorRegistry()
Definition: XrdClRedirectorRegistry.hh:172
static RedirectorRegistry & Instance()
Returns reference to the single instance.