XRootD
Loading...
Searching...
No Matches
XrdClMetalinkRedirector.hh
Go to the documentation of this file.
1/*
2 * XrdClMetalinkRedirector.hh
3 *
4 * Created on: May 2, 2016
5 * Author: simonm
6 */
7
8#ifndef SRC_XRDCL_XRDCLMETALINKREDIRECTOR_HH_
9#define SRC_XRDCL_XRDCLMETALINKREDIRECTOR_HH_
10
13
14#include <string>
15#include <list>
16#include <map>
17
18
19class XrdOucFileInfo;
20
21namespace XrdCl
22{
23
24class File;
25class Message;
26
27//----------------------------------------------------------------------------
30//----------------------------------------------------------------------------
32{
33 friend class MetalinkOpenHandler;
34 friend class MetalinkReadHandler;
35
36 public:
37 //----------------------------------------------------------------------------
40 //----------------------------------------------------------------------------
41 MetalinkRedirector( const std::string &url );
42
43 //----------------------------------------------------------------------------
45 //----------------------------------------------------------------------------
46 virtual ~MetalinkRedirector();
47
48 //----------------------------------------------------------------------------
51 //----------------------------------------------------------------------------
52 XRootDStatus Load( ResponseHandler *userHandler );
53
54 //----------------------------------------------------------------------------
58 //----------------------------------------------------------------------------
59 XRootDStatus HandleRequest( const Message *msg, MsgHandler *handler );
60
61 //----------------------------------------------------------------------------
63 //----------------------------------------------------------------------------
64 std::string GetTargetName() const
65 {
66 return pTarget;
67 }
68
69 //----------------------------------------------------------------------------
72 //----------------------------------------------------------------------------
73 std::string GetCheckSum( const std::string &type ) const
74 {
75 std::string t = type != "adler32" ? type : "a32";
76 CksumMap::const_iterator it = pChecksums.find( t );
77 if( it == pChecksums.end() ) return std::string();
78 return type + ":" + it->second;
79 }
80
81 //----------------------------------------------------------------------------
84 //----------------------------------------------------------------------------
85 std::vector<std::string> GetSupportedCheckSums() const
86 {
87 std::vector<std::string> ret;
88 CksumMap::const_iterator itr = pChecksums.begin();
89 for( ; itr != pChecksums.end(); ++itr )
90 {
91 if( itr->first == "a32" ) ret.push_back( "adler32" );
92 else ret.push_back( itr->first );
93 }
94 return ret;
95 }
96
97 //----------------------------------------------------------------------------
100 //----------------------------------------------------------------------------
101 long long GetSize() const
102 {
103 return pFileSize;
104 }
105
106 //----------------------------------------------------------------------------
108 //----------------------------------------------------------------------------
109 const std::vector<std::string>& GetReplicas()
110 {
111 return pReplicas;
112 }
113
114 //----------------------------------------------------------------------------
116 //----------------------------------------------------------------------------
117 virtual int Count( Message &req ) const;
118
119 private:
120
121 //----------------------------------------------------------------------------
126 //----------------------------------------------------------------------------
127 XRootDStatus HandleRequestImpl( const Message *msg, MsgHandler *handler );
128
129 //----------------------------------------------------------------------------
132 //----------------------------------------------------------------------------
133 XRootDStatus Parse( const std::string &metalink );
134
135 //----------------------------------------------------------------------------
140 //----------------------------------------------------------------------------
141 void FinalizeInitialization( const XRootDStatus &status = XRootDStatus() );
142
143 //----------------------------------------------------------------------------
145 //----------------------------------------------------------------------------
146 std::shared_ptr<Message> GetResponse( const Message *msg ) const;
147
148 //----------------------------------------------------------------------------
150 //----------------------------------------------------------------------------
151 std::shared_ptr<Message> GetErrorMsg( const Message *msg, const std::string &errMsg, XErrorCode code ) const;
152
153 //----------------------------------------------------------------------------
155 //----------------------------------------------------------------------------
156 void InitCksum( XrdOucFileInfo **fileInfos );
157
158 //----------------------------------------------------------------------------
160 //----------------------------------------------------------------------------
161 void InitReplicas( XrdOucFileInfo **fileInfos );
162
163 //----------------------------------------------------------------------------
165 //----------------------------------------------------------------------------
166 XRootDStatus GetReplica( const Message &msg, std::string &replica ) const;
167
168 //----------------------------------------------------------------------------
170 //----------------------------------------------------------------------------
171 XRootDStatus GetCgiInfo( const Message &msg, const std::string &key, std::string &out ) const;
172
173 typedef std::list< std::pair<const Message*, MsgHandler*> > RedirectList;
174 typedef std::map<std::string, std::string> CksumMap;
175 typedef std::vector<std::string> ReplicaList;
176
177 //----------------------------------------------------------------------------
179 //----------------------------------------------------------------------------
180 ReplicaList::const_iterator GetReplica( const Message &msg ) const;
181
182 RedirectList pPendingRedirects;
183 std::string pUrl;
184 File *pFile;
185 CksumMap pChecksums;
186 ReplicaList pReplicas;
187 bool pReady;
188 XRootDStatus pStatus;
189 std::string pTarget;
190 long long pFileSize;
191
192 XrdSysMutex pMutex;
193
194 static const std::string LocalFile;
195
196};
197
198} /* namespace XrdCl */
199
200#endif /* SRC_XRDCL_XRDCLMETALINKREDIRECTOR_HH_ */
XErrorCode
Definition XProtocol.hh:987
XrdOucString File
A file.
Definition XrdClFile.hh:46
The message representation used throughout the system.
std::string GetCheckSum(const std::string &type) const
const std::vector< std::string > & GetReplicas()
Returns a vector with replicas as given in the meatlink file.
XRootDStatus Load(ResponseHandler *userHandler)
virtual ~MetalinkRedirector()
Destructor.
XRootDStatus HandleRequest(const Message *msg, MsgHandler *handler)
std::vector< std::string > GetSupportedCheckSums() const
std::string GetTargetName() const
Gets the file name as specified in the metalink.
virtual int Count(Message &req) const
Count how many replicas do we have left to try for given request.
Handle an async response.
An interface for metadata redirectors.