00001 //------------------------------------------------------------------------------ 00002 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN) 00003 // Author: Lukasz Janyst <ljanyst@cern.ch> 00004 //------------------------------------------------------------------------------ 00005 // XRootD is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU Lesser General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // XRootD is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with XRootD. If not, see <http://www.gnu.org/licenses/>. 00017 //------------------------------------------------------------------------------ 00018 00019 #ifndef __XRD_CL_POST_MASTER_HH__ 00020 #define __XRD_CL_POST_MASTER_HH__ 00021 00022 #include <stdint.h> 00023 #include <map> 00024 #include <vector> 00025 #include <functional> 00026 #include <memory> 00027 00028 #include "XrdCl/XrdClStatus.hh" 00029 #include "XrdCl/XrdClURL.hh" 00030 #include "XrdCl/XrdClPostMasterInterfaces.hh" 00031 00032 #include "XrdSys/XrdSysPthread.hh" 00033 00034 namespace XrdCl 00035 { 00036 class Poller; 00037 class TaskManager; 00038 class Channel; 00039 class JobManager; 00040 class Job; 00041 00042 struct PostMasterImpl; 00043 00044 //---------------------------------------------------------------------------- 00046 //---------------------------------------------------------------------------- 00047 class PostMaster 00048 { 00049 public: 00050 //------------------------------------------------------------------------ 00052 //------------------------------------------------------------------------ 00053 PostMaster(); 00054 00055 //------------------------------------------------------------------------ 00057 //------------------------------------------------------------------------ 00058 virtual ~PostMaster(); 00059 00060 //------------------------------------------------------------------------ 00062 //------------------------------------------------------------------------ 00063 bool Initialize(); 00064 00065 //------------------------------------------------------------------------ 00067 //------------------------------------------------------------------------ 00068 bool Finalize(); 00069 00070 //------------------------------------------------------------------------ 00072 //------------------------------------------------------------------------ 00073 bool Start(); 00074 00075 //------------------------------------------------------------------------ 00077 //------------------------------------------------------------------------ 00078 bool Stop(); 00079 00080 //------------------------------------------------------------------------ 00082 //------------------------------------------------------------------------ 00083 bool Reinitialize(); 00084 00085 //------------------------------------------------------------------------ 00099 //------------------------------------------------------------------------ 00100 XRootDStatus Send( const URL &url, 00101 Message *msg, 00102 bool stateful, 00103 time_t expires ); 00104 00105 //------------------------------------------------------------------------ 00121 //------------------------------------------------------------------------ 00122 XRootDStatus Send( const URL &url, 00123 Message *msg, 00124 OutgoingMsgHandler *handler, 00125 bool stateful, 00126 time_t expires ); 00127 00128 //------------------------------------------------------------------------ 00130 //------------------------------------------------------------------------ 00131 Status Redirect( const URL &url, 00132 Message *msg, 00133 IncomingMsgHandler *handler); 00134 00135 //------------------------------------------------------------------------ 00146 //------------------------------------------------------------------------ 00147 Status Receive( const URL &url, 00148 Message *&msg, 00149 MessageFilter *filter, 00150 time_t expires ); 00151 00152 //------------------------------------------------------------------------ 00160 //------------------------------------------------------------------------ 00161 Status Receive( const URL &url, 00162 IncomingMsgHandler *handler, 00163 time_t expires ); 00164 00165 //------------------------------------------------------------------------ 00173 //------------------------------------------------------------------------ 00174 Status QueryTransport( const URL &url, 00175 uint16_t query, 00176 AnyObject &result ); 00177 00178 //------------------------------------------------------------------------ 00180 //------------------------------------------------------------------------ 00181 Status RegisterEventHandler( const URL &url, 00182 ChannelEventHandler *handler ); 00183 00184 //------------------------------------------------------------------------ 00186 //------------------------------------------------------------------------ 00187 Status RemoveEventHandler( const URL &url, 00188 ChannelEventHandler *handler ); 00189 00190 //------------------------------------------------------------------------ 00192 //------------------------------------------------------------------------ 00193 TaskManager *GetTaskManager(); 00194 00195 //------------------------------------------------------------------------ 00197 //------------------------------------------------------------------------ 00198 JobManager *GetJobManager(); 00199 00200 //------------------------------------------------------------------------ 00202 //------------------------------------------------------------------------ 00203 Status ForceDisconnect( const URL &url ); 00204 00205 //------------------------------------------------------------------------ 00207 //------------------------------------------------------------------------ 00208 uint16_t NbConnectedStrm( const URL &url ); 00209 00210 //------------------------------------------------------------------------ 00212 //------------------------------------------------------------------------ 00213 void SetOnDataConnectHandler( const URL &url, 00214 std::shared_ptr<Job> onConnJob ); 00215 00216 //------------------------------------------------------------------------ 00218 //------------------------------------------------------------------------ 00219 void SetOnConnectHandler( std::unique_ptr<Job> onConnJob ); 00220 00221 //------------------------------------------------------------------------ 00223 //------------------------------------------------------------------------ 00224 void NotifyConnectHandler( const URL &url ); 00225 00226 private: 00227 Channel *GetChannel( const URL &url ); 00228 00229 std::unique_ptr<PostMasterImpl> pImpl; 00230 }; 00231 } 00232 00233 #endif // __XRD_CL_POST_MASTER_HH__