xrootd
Loading...
Searching...
No Matches
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 MsgHandler;
25
26//--------------------------------------------------------------------------------
28//--------------------------------------------------------------------------------
29class RedirectJob: public Job
30{
31 public:
32 //------------------------------------------------------------------------
34 //------------------------------------------------------------------------
35 RedirectJob( MsgHandler *handler, std::shared_ptr<Message> msg ) : pHandler( handler ), msg( msg )
36 {
37 }
38
39 //------------------------------------------------------------------------
41 //------------------------------------------------------------------------
42 virtual ~RedirectJob()
43 {
44 }
45
46 //------------------------------------------------------------------------
48 //------------------------------------------------------------------------
49 virtual void Run( void *arg );
50
51 private:
53 std::shared_ptr<Message> msg;
54};
55
56//--------------------------------------------------------------------------------
58//--------------------------------------------------------------------------------
60{
61 public:
62 //----------------------------------------------------------------------------
64 //----------------------------------------------------------------------------
66
67 //----------------------------------------------------------------------------
72 //----------------------------------------------------------------------------
73 virtual XRootDStatus HandleRequest( const Message *msg,
74 MsgHandler *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_ */
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
Message handler.
Definition XrdClPostMasterInterfaces.hh:51
A job class for redirect handling in the thread-pool.
Definition XrdClRedirectorRegistry.hh:30
virtual ~RedirectJob()
Destructor.
Definition XrdClRedirectorRegistry.hh:42
std::shared_ptr< Message > msg
Definition XrdClRedirectorRegistry.hh:53
RedirectJob(MsgHandler *handler, std::shared_ptr< Message > msg)
Constructor.
Definition XrdClRedirectorRegistry.hh:35
virtual void Run(void *arg)
Run the user handler.
MsgHandler * pHandler
Definition XrdClRedirectorRegistry.hh:52
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:1126
URL representation.
Definition XrdClURL.hh:31
An interface for metadata redirectors.
Definition XrdClRedirectorRegistry.hh:60
virtual long long GetSize() const =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 int Count(Message &req) const =0
Count how many replicas do we have left to try for given request.
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 XRootDStatus HandleRequest(const Message *msg, MsgHandler *handler)=0
virtual const std::vector< std::string > & GetReplicas()=0
Returns a vector with replicas as given in the meatlink file.
Request status.
Definition XrdClXRootDResponses.hh:219
Definition XrdSysPthread.hh:165
Definition XrdClAction.hh:34