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 
26 #include "XrdCl/XrdClStatus.hh"
27 #include "XrdCl/XrdClURL.hh"
29 
30 #include "XrdSys/XrdSysPthread.hh"
31 
32 namespace XrdCl
33 {
34  class Poller;
35  class TaskManager;
36  class Channel;
37  class JobManager;
38 
39  //----------------------------------------------------------------------------
41  //----------------------------------------------------------------------------
42  class PostMaster
43  {
44  public:
45  //------------------------------------------------------------------------
47  //------------------------------------------------------------------------
48  PostMaster();
49 
50  //------------------------------------------------------------------------
52  //------------------------------------------------------------------------
53  virtual ~PostMaster();
54 
55  //------------------------------------------------------------------------
57  //------------------------------------------------------------------------
58  bool Initialize();
59 
60  //------------------------------------------------------------------------
62  //------------------------------------------------------------------------
63  bool Finalize();
64 
65  //------------------------------------------------------------------------
67  //------------------------------------------------------------------------
68  bool Start();
69 
70  //------------------------------------------------------------------------
72  //------------------------------------------------------------------------
73  bool Stop();
74 
75  //------------------------------------------------------------------------
77  //------------------------------------------------------------------------
78  bool Reinitialize();
79 
80  //------------------------------------------------------------------------
94  //------------------------------------------------------------------------
95  Status Send( const URL &url,
96  Message *msg,
97  bool stateful,
98  time_t expires );
99 
100  //------------------------------------------------------------------------
116  //------------------------------------------------------------------------
117  Status Send( const URL &url,
118  Message *msg,
119  OutgoingMsgHandler *handler,
120  bool stateful,
121  time_t expires );
122 
123  //------------------------------------------------------------------------
125  //------------------------------------------------------------------------
126  Status Redirect( const URL &url,
127  Message *msg,
128  OutgoingMsgHandler *outHandler,
129  IncomingMsgHandler *handler);
130 
131  //------------------------------------------------------------------------
142  //------------------------------------------------------------------------
143  Status Receive( const URL &url,
144  Message *&msg,
145  MessageFilter *filter,
146  time_t expires );
147 
148  //------------------------------------------------------------------------
156  //------------------------------------------------------------------------
157  Status Receive( const URL &url,
158  IncomingMsgHandler *handler,
159  time_t expires );
160 
161  //------------------------------------------------------------------------
169  //------------------------------------------------------------------------
170  Status QueryTransport( const URL &url,
171  uint16_t query,
172  AnyObject &result );
173 
174  //------------------------------------------------------------------------
176  //------------------------------------------------------------------------
177  Status RegisterEventHandler( const URL &url,
178  ChannelEventHandler *handler );
179 
180  //------------------------------------------------------------------------
182  //------------------------------------------------------------------------
183  Status RemoveEventHandler( const URL &url,
184  ChannelEventHandler *handler );
185 
186  //------------------------------------------------------------------------
188  //------------------------------------------------------------------------
189  TaskManager *GetTaskManager()
190  {
191  return pTaskManager;
192  }
193 
194  //------------------------------------------------------------------------
196  //------------------------------------------------------------------------
197  JobManager *GetJobManager()
198  {
199  return pJobManager;
200  }
201 
202  private:
203  Channel *GetChannel( const URL &url );
204 
205  typedef std::map<std::string, Channel*> ChannelMap;
206  Poller *pPoller;
207  TaskManager *pTaskManager;
211  JobManager *pJobManager;
212  };
213 }
214 
215 #endif // __XRD_CL_POST_MASTER_HH__
Definition: XrdClAnyObject.hh:32
Status QueryTransport(const URL &url, uint16_t query, AnyObject &result)
Message filter.
Definition: XrdClPostMasterInterfaces.hh:46
The message representation used throughout the system.
Definition: XrdClMessage.hh:29
Status Redirect(const URL &url, Message *msg, OutgoingMsgHandler *outHandler, IncomingMsgHandler *handler)
Status Receive(const URL &url, Message *&msg, MessageFilter *filter, time_t expires)
TaskManager * GetTaskManager()
Get the task manager object user by the post master.
Definition: XrdClPostMaster.hh:189
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:107
JobManager * pJobManager
Definition: XrdClPostMaster.hh:211
Definition: XrdSysPthread.hh:140
PostMaster()
Constructor.
Poller * pPoller
Definition: XrdClPostMaster.hh:206
bool Reinitialize()
Reinitialize after fork.
Definition: XrdClEnv.hh:28
Channel event handler.
Definition: XrdClPostMasterInterfaces.hh:220
virtual ~PostMaster()
Destructor.
Message handler.
Definition: XrdClPostMasterInterfaces.hh:68
bool Initialize()
Initializer.
URL representation.
Definition: XrdClURL.hh:30
JobManager * GetJobManager()
Get the job manager object user by the post master.
Definition: XrdClPostMaster.hh:197
ChannelMap pChannelMap
Definition: XrdClPostMaster.hh:208
Channel * GetChannel(const URL &url)
Status RemoveEventHandler(const URL &url, ChannelEventHandler *handler)
Remove a channel event handler.
Message status handler.
Definition: XrdClPostMasterInterfaces.hh:167
A hub for dispatching and receiving messages.
Definition: XrdClPostMaster.hh:42
XrdSysMutex pChannelMapMutex
Definition: XrdClPostMaster.hh:209
TaskManager * pTaskManager
Definition: XrdClPostMaster.hh:207
std::map< std::string, Channel * > ChannelMap
Definition: XrdClPostMaster.hh:205
bool pInitialized
Definition: XrdClPostMaster.hh:210
Status Send(const URL &url, Message *msg, bool stateful, time_t expires)
bool Stop()
Stop the postmaster.