|
||||
File indexing completed on 2025-01-18 10:15:36
0001 //------------------------------------------------------------------------------ 0002 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN) 0003 // Author: Lukasz Janyst <ljanyst@cern.ch> 0004 //------------------------------------------------------------------------------ 0005 // XRootD is free software: you can redistribute it and/or modify 0006 // it under the terms of the GNU Lesser General Public License as published by 0007 // the Free Software Foundation, either version 3 of the License, or 0008 // (at your option) any later version. 0009 // 0010 // XRootD is distributed in the hope that it will be useful, 0011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 // GNU General Public License for more details. 0014 // 0015 // You should have received a copy of the GNU Lesser General Public License 0016 // along with XRootD. If not, see <http://www.gnu.org/licenses/>. 0017 //------------------------------------------------------------------------------ 0018 0019 #ifndef __XRD_CL_POST_MASTER_HH__ 0020 #define __XRD_CL_POST_MASTER_HH__ 0021 0022 #include <cstdint> 0023 #include <map> 0024 #include <vector> 0025 #include <functional> 0026 #include <memory> 0027 0028 #include "XrdCl/XrdClStatus.hh" 0029 #include "XrdCl/XrdClURL.hh" 0030 #include "XrdCl/XrdClPostMasterInterfaces.hh" 0031 0032 #include "XrdSys/XrdSysPthread.hh" 0033 0034 namespace XrdCl 0035 { 0036 class Poller; 0037 class TaskManager; 0038 class Channel; 0039 class JobManager; 0040 class Job; 0041 0042 struct PostMasterImpl; 0043 0044 //---------------------------------------------------------------------------- 0045 //! A hub for dispatching and receiving messages 0046 //---------------------------------------------------------------------------- 0047 class PostMaster 0048 { 0049 public: 0050 //------------------------------------------------------------------------ 0051 //! Constructor 0052 //------------------------------------------------------------------------ 0053 PostMaster(); 0054 0055 //------------------------------------------------------------------------ 0056 //! Destructor 0057 //------------------------------------------------------------------------ 0058 virtual ~PostMaster(); 0059 0060 //------------------------------------------------------------------------ 0061 //! Initializer 0062 //------------------------------------------------------------------------ 0063 bool Initialize(); 0064 0065 //------------------------------------------------------------------------ 0066 //! Finalizer 0067 //------------------------------------------------------------------------ 0068 bool Finalize(); 0069 0070 //------------------------------------------------------------------------ 0071 //! Start the post master 0072 //------------------------------------------------------------------------ 0073 bool Start(); 0074 0075 //------------------------------------------------------------------------ 0076 //! Stop the postmaster 0077 //------------------------------------------------------------------------ 0078 bool Stop(); 0079 0080 //------------------------------------------------------------------------ 0081 //! Reinitialize after fork 0082 //------------------------------------------------------------------------ 0083 bool Reinitialize(); 0084 0085 //------------------------------------------------------------------------ 0086 //! Send the message asynchronously - the message is inserted into the 0087 //! send queue and a listener is called when the message is succesfsully 0088 //! pushed through the wire or when the timeout elapses 0089 //! 0090 //! DEADLOCK WARNING: no lock should be taken while calling this method 0091 //! that are used in the callback as well. 0092 //! 0093 //! @param url recipient of the message 0094 //! @param msg message to be sent 0095 //! @param expires unix timestamp after which a failure is reported 0096 //! to the handler 0097 //! @param handler handler will be notified about the status 0098 //! @param stateful physical stream disconnection causes an error 0099 //! @return success if the message was successfully inserted 0100 //! into the send queues, failure otherwise 0101 //------------------------------------------------------------------------ 0102 XRootDStatus Send( const URL &url, 0103 Message *msg, 0104 MsgHandler *handler, 0105 bool stateful, 0106 time_t expires ); 0107 0108 //------------------------------------------------------------------------ 0109 //! 0110 //------------------------------------------------------------------------ 0111 Status Redirect( const URL &url, 0112 Message *msg, 0113 MsgHandler *handler); 0114 0115 //------------------------------------------------------------------------ 0116 //! Query the transport handler for a given URL 0117 //! 0118 //! @param url the channel to be queried 0119 //! @param query the query as defined in the TransportQuery struct or 0120 //! others that may be recognized by the protocol transport 0121 //! @param result the result of the query 0122 //! @return status of the query 0123 //------------------------------------------------------------------------ 0124 Status QueryTransport( const URL &url, 0125 uint16_t query, 0126 AnyObject &result ); 0127 0128 //------------------------------------------------------------------------ 0129 //! Register channel event handler 0130 //------------------------------------------------------------------------ 0131 Status RegisterEventHandler( const URL &url, 0132 ChannelEventHandler *handler ); 0133 0134 //------------------------------------------------------------------------ 0135 //! Remove a channel event handler 0136 //------------------------------------------------------------------------ 0137 Status RemoveEventHandler( const URL &url, 0138 ChannelEventHandler *handler ); 0139 0140 //------------------------------------------------------------------------ 0141 //! Get the task manager object user by the post master 0142 //------------------------------------------------------------------------ 0143 TaskManager *GetTaskManager(); 0144 0145 //------------------------------------------------------------------------ 0146 //! Get the job manager object user by the post master 0147 //------------------------------------------------------------------------ 0148 JobManager *GetJobManager(); 0149 0150 //------------------------------------------------------------------------ 0151 //! Shut down a channel 0152 //------------------------------------------------------------------------ 0153 Status ForceDisconnect( const URL &url ); 0154 0155 //------------------------------------------------------------------------ 0156 //! Reconnect the channel 0157 //------------------------------------------------------------------------ 0158 Status ForceReconnect( const URL &url ); 0159 0160 //------------------------------------------------------------------------ 0161 //! Get the number of connected data streams 0162 //------------------------------------------------------------------------ 0163 uint16_t NbConnectedStrm( const URL &url ); 0164 0165 //------------------------------------------------------------------------ 0166 //! Set the on-connect handler for data streams 0167 //------------------------------------------------------------------------ 0168 void SetOnDataConnectHandler( const URL &url, 0169 std::shared_ptr<Job> onConnJob ); 0170 0171 //------------------------------------------------------------------------ 0172 //! Set the global connection error handler 0173 //------------------------------------------------------------------------ 0174 void SetOnConnectHandler( std::unique_ptr<Job> onConnJob ); 0175 0176 //------------------------------------------------------------------------ 0177 //! Set the global on-error on-connect handler for control streams 0178 //------------------------------------------------------------------------ 0179 void SetConnectionErrorHandler( std::function<void( const URL&, const XRootDStatus& )> handler ); 0180 0181 //------------------------------------------------------------------------ 0182 //! Notify the global on-connect handler 0183 //------------------------------------------------------------------------ 0184 void NotifyConnectHandler( const URL &url ); 0185 0186 //------------------------------------------------------------------------ 0187 //! Notify the global error connection handler 0188 //------------------------------------------------------------------------ 0189 void NotifyConnErrHandler( const URL &url, const XRootDStatus &status ); 0190 0191 //------------------------------------------------------------------------ 0192 //! Collapse channel URL - replace the URL of the channel 0193 //------------------------------------------------------------------------ 0194 void CollapseRedirect( const URL &oldurl, const URL &newURL ); 0195 0196 //------------------------------------------------------------------------ 0197 //! Decrement file object instance count bound to this channel 0198 //------------------------------------------------------------------------ 0199 void DecFileInstCnt( const URL &url ); 0200 0201 //------------------------------------------------------------------------ 0202 //! @return : true if underlying threads are running, false otherwise 0203 //------------------------------------------------------------------------ 0204 bool IsRunning(); 0205 0206 private: 0207 Channel *GetChannel( const URL &url ); 0208 0209 std::unique_ptr<PostMasterImpl> pImpl; 0210 }; 0211 } 0212 0213 #endif // __XRD_CL_POST_MASTER_HH__
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |