xrootd
XrdClPostMaster.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
3 // Author: Lukasz Janyst <ljanyst@cern.ch>
4 //------------------------------------------------------------------------------
5 // XRootD is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // XRootD is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
17 //------------------------------------------------------------------------------
18 
19 #ifndef __XRD_CL_POST_MASTER_HH__
20 #define __XRD_CL_POST_MASTER_HH__
21 
22 #include <stdint.h>
23 #include <map>
24 #include <vector>
25 #include <functional>
26 #include <memory>
27 
28 #include "XrdCl/XrdClStatus.hh"
29 #include "XrdCl/XrdClURL.hh"
31 
32 #include "XrdSys/XrdSysPthread.hh"
33 
34 namespace XrdCl
35 {
36  class Poller;
37  class TaskManager;
38  class Channel;
39  class JobManager;
40  class Job;
41 
42  struct PostMasterImpl;
43 
44  //----------------------------------------------------------------------------
46  //----------------------------------------------------------------------------
47  class PostMaster
48  {
49  public:
50  //------------------------------------------------------------------------
52  //------------------------------------------------------------------------
53  PostMaster();
54 
55  //------------------------------------------------------------------------
57  //------------------------------------------------------------------------
58  virtual ~PostMaster();
59 
60  //------------------------------------------------------------------------
62  //------------------------------------------------------------------------
63  bool Initialize();
64 
65  //------------------------------------------------------------------------
67  //------------------------------------------------------------------------
68  bool Finalize();
69 
70  //------------------------------------------------------------------------
72  //------------------------------------------------------------------------
73  bool Start();
74 
75  //------------------------------------------------------------------------
77  //------------------------------------------------------------------------
78  bool Stop();
79 
80  //------------------------------------------------------------------------
82  //------------------------------------------------------------------------
83  bool Reinitialize();
84 
85  //------------------------------------------------------------------------
99  //------------------------------------------------------------------------
100  XRootDStatus Send( const URL &url,
101  Message *msg,
102  bool stateful,
103  time_t expires );
104 
105  //------------------------------------------------------------------------
121  //------------------------------------------------------------------------
122  XRootDStatus Send( const URL &url,
123  Message *msg,
124  OutgoingMsgHandler *handler,
125  bool stateful,
126  time_t expires );
127 
128  //------------------------------------------------------------------------
130  //------------------------------------------------------------------------
131  Status Redirect( const URL &url,
132  Message *msg,
133  IncomingMsgHandler *handler);
134 
135  //------------------------------------------------------------------------
146  //------------------------------------------------------------------------
147  Status Receive( const URL &url,
148  Message *&msg,
149  MessageFilter *filter,
150  time_t expires );
151 
152  //------------------------------------------------------------------------
160  //------------------------------------------------------------------------
161  Status Receive( const URL &url,
162  IncomingMsgHandler *handler,
163  time_t expires );
164 
165  //------------------------------------------------------------------------
173  //------------------------------------------------------------------------
174  Status QueryTransport( const URL &url,
175  uint16_t query,
176  AnyObject &result );
177 
178  //------------------------------------------------------------------------
180  //------------------------------------------------------------------------
181  Status RegisterEventHandler( const URL &url,
182  ChannelEventHandler *handler );
183 
184  //------------------------------------------------------------------------
186  //------------------------------------------------------------------------
187  Status RemoveEventHandler( const URL &url,
188  ChannelEventHandler *handler );
189 
190  //------------------------------------------------------------------------
192  //------------------------------------------------------------------------
194 
195  //------------------------------------------------------------------------
197  //------------------------------------------------------------------------
199 
200  //------------------------------------------------------------------------
202  //------------------------------------------------------------------------
203  Status ForceDisconnect( const URL &url );
204 
205  //------------------------------------------------------------------------
207  //------------------------------------------------------------------------
208  uint16_t NbConnectedStrm( const URL &url );
209 
210  //------------------------------------------------------------------------
212  //------------------------------------------------------------------------
213  void SetOnDataConnectHandler( const URL &url,
214  std::shared_ptr<Job> onConnJob );
215 
216  //------------------------------------------------------------------------
218  //------------------------------------------------------------------------
219  void SetOnConnectHandler( std::unique_ptr<Job> onConnJob );
220 
221  //------------------------------------------------------------------------
223  //------------------------------------------------------------------------
224  void SetConnectionErrorHandler( std::function<void( const URL&, const XRootDStatus& )> handler );
225 
226  //------------------------------------------------------------------------
228  //------------------------------------------------------------------------
229  void NotifyConnectHandler( const URL &url );
230 
231  //------------------------------------------------------------------------
233  //------------------------------------------------------------------------
234  void NotifyConnErrHandler( const URL &url, const XRootDStatus &status );
235 
236  //------------------------------------------------------------------------
238  //------------------------------------------------------------------------
239  void CollapseRedirect( const URL &oldurl, const URL &newURL );
240 
241  private:
242  Channel *GetChannel( const URL &url );
243 
244  std::unique_ptr<PostMasterImpl> pImpl;
245  };
246 }
247 
248 #endif // __XRD_CL_POST_MASTER_HH__
A synchronized queue.
Definition: XrdClJobManager.hh:50
void SetOnConnectHandler(std::unique_ptr< Job > onConnJob)
Set the global connection error handler.
uint16_t NbConnectedStrm(const URL &url)
Get the number of connected data streams.
Definition: XrdClAnyObject.hh:32
Status QueryTransport(const URL &url, uint16_t query, AnyObject &result)
Message filter.
Definition: XrdClPostMasterInterfaces.hh:49
The message representation used throughout the system.
Definition: XrdClMessage.hh:29
Status Receive(const URL &url, Message *&msg, MessageFilter *filter, time_t expires)
TaskManager * GetTaskManager()
Get the task manager object user by the post master.
Status Redirect(const URL &url, Message *msg, IncomingMsgHandler *handler)
std::unique_ptr< PostMasterImpl > pImpl
Definition: XrdClPostMaster.hh:244
Status RegisterEventHandler(const URL &url, ChannelEventHandler *handler)
Register channel event handler.
bool Start()
Start the post master.
bool Finalize()
Finalizer.
Procedure execution status.
Definition: XrdClStatus.hh:112
void NotifyConnErrHandler(const URL &url, const XRootDStatus &status)
Notify the global error connection handler.
void NotifyConnectHandler(const URL &url)
Notify the global on-connect handler.
PostMaster()
Constructor.
A communication channel between the client and the server.
Definition: XrdClChannel.hh:48
void CollapseRedirect(const URL &oldurl, const URL &newURL)
Collapse channel URL - replace the URL of the channel.
bool Reinitialize()
Reinitialize after fork.
Request status.
Definition: XrdClXRootDResponses.hh:218
Definition: XrdClAnyObject.hh:25
Channel event handler.
Definition: XrdClPostMasterInterfaces.hh:236
virtual ~PostMaster()
Destructor.
Message handler.
Definition: XrdClPostMasterInterfaces.hh:71
void SetOnDataConnectHandler(const URL &url, std::shared_ptr< Job > onConnJob)
Set the on-connect handler for data streams.
bool Initialize()
Initializer.
void SetConnectionErrorHandler(std::function< void(const URL &, const XRootDStatus &)> handler)
Set the global on-error on-connect handler for control streams.
URL representation.
Definition: XrdClURL.hh:30
JobManager * GetJobManager()
Get the job manager object user by the post master.
Status ForceDisconnect(const URL &url)
Shut down a channel.
Channel * GetChannel(const URL &url)
Status RemoveEventHandler(const URL &url, ChannelEventHandler *handler)
Remove a channel event handler.
Message status handler.
Definition: XrdClPostMasterInterfaces.hh:184
A hub for dispatching and receiving messages.
Definition: XrdClPostMaster.hh:47
Definition: XrdClTaskManager.hh:75
bool Stop()
Stop the postmaster.
XRootDStatus Send(const URL &url, Message *msg, bool stateful, time_t expires)