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 <cstdint>
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  //------------------------------------------------------------------------
101  //------------------------------------------------------------------------
102  XRootDStatus Send( const URL &url,
103  Message *msg,
104  MsgHandler *handler,
105  bool stateful,
106  time_t expires );
107 
108  //------------------------------------------------------------------------
110  //------------------------------------------------------------------------
111  Status Redirect( const URL &url,
112  Message *msg,
113  MsgHandler *handler);
114 
115  //------------------------------------------------------------------------
123  //------------------------------------------------------------------------
124  Status QueryTransport( const URL &url,
125  uint16_t query,
126  AnyObject &result );
127 
128  //------------------------------------------------------------------------
130  //------------------------------------------------------------------------
131  Status RegisterEventHandler( const URL &url,
132  ChannelEventHandler *handler );
133 
134  //------------------------------------------------------------------------
136  //------------------------------------------------------------------------
137  Status RemoveEventHandler( const URL &url,
138  ChannelEventHandler *handler );
139 
140  //------------------------------------------------------------------------
142  //------------------------------------------------------------------------
144 
145  //------------------------------------------------------------------------
147  //------------------------------------------------------------------------
149 
150  //------------------------------------------------------------------------
152  //------------------------------------------------------------------------
153  Status ForceDisconnect( const URL &url );
154 
155  //------------------------------------------------------------------------
157  //------------------------------------------------------------------------
158  Status ForceDisconnect( const URL &url, bool hush );
159 
160  //------------------------------------------------------------------------
162  //------------------------------------------------------------------------
163  Status ForceReconnect( const URL &url );
164 
165  //------------------------------------------------------------------------
167  //------------------------------------------------------------------------
168  uint16_t NbConnectedStrm( const URL &url );
169 
170  //------------------------------------------------------------------------
172  //------------------------------------------------------------------------
173  void SetOnDataConnectHandler( const URL &url,
174  std::shared_ptr<Job> onConnJob );
175 
176  //------------------------------------------------------------------------
178  //------------------------------------------------------------------------
179  void SetOnConnectHandler( std::unique_ptr<Job> onConnJob );
180 
181  //------------------------------------------------------------------------
183  //------------------------------------------------------------------------
184  void SetConnectionErrorHandler( std::function<void( const URL&, const XRootDStatus& )> handler );
185 
186  //------------------------------------------------------------------------
188  //------------------------------------------------------------------------
189  void NotifyConnectHandler( const URL &url );
190 
191  //------------------------------------------------------------------------
193  //------------------------------------------------------------------------
194  void NotifyConnErrHandler( const URL &url, const XRootDStatus &status );
195 
196  //------------------------------------------------------------------------
198  //------------------------------------------------------------------------
199  void CollapseRedirect( const URL &oldurl, const URL &newURL );
200 
201  //------------------------------------------------------------------------
203  //------------------------------------------------------------------------
204  void DecFileInstCnt( const URL &url );
205 
206  //------------------------------------------------------------------------
208  //------------------------------------------------------------------------
209  bool IsRunning();
210 
211  private:
212  Channel *GetChannel( const URL &url );
213 
214  std::unique_ptr<PostMasterImpl> pImpl;
215  };
216 }
217 
218 #endif // __XRD_CL_POST_MASTER_HH__
A communication channel between the client and the server.
Definition: XrdClChannel.hh:49
A synchronized queue.
The message representation used throughout the system.
Definition: XrdClMessage.hh:32
A hub for dispatching and receiving messages.
void SetOnDataConnectHandler(const URL &url, std::shared_ptr< Job > onConnJob)
Set the on-connect handler for data streams.
void CollapseRedirect(const URL &oldurl, const URL &newURL)
Collapse channel URL - replace the URL of the channel.
bool Start()
Start the post master.
bool Finalize()
Finalizer.
XRootDStatus Send(const URL &url, Message *msg, MsgHandler *handler, bool stateful, time_t expires)
Status ForceReconnect(const URL &url)
Reconnect the channel.
bool Stop()
Stop the postmaster.
bool Reinitialize()
Reinitialize after fork.
TaskManager * GetTaskManager()
Get the task manager object user by the post master.
uint16_t NbConnectedStrm(const URL &url)
Get the number of connected data streams.
void SetOnConnectHandler(std::unique_ptr< Job > onConnJob)
Set the global connection error handler.
Status RemoveEventHandler(const URL &url, ChannelEventHandler *handler)
Remove a channel event handler.
virtual ~PostMaster()
Destructor.
PostMaster()
Constructor.
void SetConnectionErrorHandler(std::function< void(const URL &, const XRootDStatus &)> handler)
Set the global on-error on-connect handler for control streams.
Status ForceDisconnect(const URL &url)
Shut down a channel.
Status Redirect(const URL &url, Message *msg, MsgHandler *handler)
void NotifyConnErrHandler(const URL &url, const XRootDStatus &status)
Notify the global error connection handler.
Status QueryTransport(const URL &url, uint16_t query, AnyObject &result)
Status RegisterEventHandler(const URL &url, ChannelEventHandler *handler)
Register channel event handler.
void NotifyConnectHandler(const URL &url)
Notify the global on-connect handler.
JobManager * GetJobManager()
Get the job manager object user by the post master.
bool Initialize()
Initializer.
void DecFileInstCnt(const URL &url)
Decrement file object instance count bound to this channel.
URL representation.
Definition: XrdClURL.hh:31
Procedure execution status.
Definition: XrdClStatus.hh:115