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 00027 #include "XrdCl/XrdClStatus.hh" 00028 #include "XrdCl/XrdClURL.hh" 00029 #include "XrdCl/XrdClPostMasterInterfaces.hh" 00030 00031 #include "XrdSys/XrdSysPthread.hh" 00032 00033 namespace XrdCl 00034 { 00035 class Poller; 00036 class TaskManager; 00037 class Channel; 00038 class JobManager; 00039 class Job; 00040 00041 //---------------------------------------------------------------------------- 00043 //---------------------------------------------------------------------------- 00044 class PostMaster 00045 { 00046 public: 00047 //------------------------------------------------------------------------ 00049 //------------------------------------------------------------------------ 00050 PostMaster(); 00051 00052 //------------------------------------------------------------------------ 00054 //------------------------------------------------------------------------ 00055 virtual ~PostMaster(); 00056 00057 //------------------------------------------------------------------------ 00059 //------------------------------------------------------------------------ 00060 bool Initialize(); 00061 00062 //------------------------------------------------------------------------ 00064 //------------------------------------------------------------------------ 00065 bool Finalize(); 00066 00067 //------------------------------------------------------------------------ 00069 //------------------------------------------------------------------------ 00070 bool Start(); 00071 00072 //------------------------------------------------------------------------ 00074 //------------------------------------------------------------------------ 00075 bool Stop(); 00076 00077 //------------------------------------------------------------------------ 00079 //------------------------------------------------------------------------ 00080 bool Reinitialize(); 00081 00082 //------------------------------------------------------------------------ 00096 //------------------------------------------------------------------------ 00097 Status Send( const URL &url, 00098 Message *msg, 00099 bool stateful, 00100 time_t expires ); 00101 00102 //------------------------------------------------------------------------ 00118 //------------------------------------------------------------------------ 00119 Status Send( const URL &url, 00120 Message *msg, 00121 OutgoingMsgHandler *handler, 00122 bool stateful, 00123 time_t expires ); 00124 00125 //------------------------------------------------------------------------ 00127 //------------------------------------------------------------------------ 00128 Status Redirect( const URL &url, 00129 Message *msg, 00130 IncomingMsgHandler *handler); 00131 00132 //------------------------------------------------------------------------ 00143 //------------------------------------------------------------------------ 00144 Status Receive( const URL &url, 00145 Message *&msg, 00146 MessageFilter *filter, 00147 time_t expires ); 00148 00149 //------------------------------------------------------------------------ 00157 //------------------------------------------------------------------------ 00158 Status Receive( const URL &url, 00159 IncomingMsgHandler *handler, 00160 time_t expires ); 00161 00162 //------------------------------------------------------------------------ 00170 //------------------------------------------------------------------------ 00171 Status QueryTransport( const URL &url, 00172 uint16_t query, 00173 AnyObject &result ); 00174 00175 //------------------------------------------------------------------------ 00177 //------------------------------------------------------------------------ 00178 Status RegisterEventHandler( const URL &url, 00179 ChannelEventHandler *handler ); 00180 00181 //------------------------------------------------------------------------ 00183 //------------------------------------------------------------------------ 00184 Status RemoveEventHandler( const URL &url, 00185 ChannelEventHandler *handler ); 00186 00187 //------------------------------------------------------------------------ 00189 //------------------------------------------------------------------------ 00190 TaskManager *GetTaskManager() 00191 { 00192 return pTaskManager; 00193 } 00194 00195 //------------------------------------------------------------------------ 00197 //------------------------------------------------------------------------ 00198 JobManager *GetJobManager() 00199 { 00200 return pJobManager; 00201 } 00202 00203 //------------------------------------------------------------------------ 00205 //------------------------------------------------------------------------ 00206 Status ForceDisconnect( const URL &url ); 00207 00208 //------------------------------------------------------------------------ 00210 //------------------------------------------------------------------------ 00211 uint16_t NbConnectedStrm( const URL &url ); 00212 00213 //------------------------------------------------------------------------ 00215 //------------------------------------------------------------------------ 00216 void SetOnConnectHandler( const URL &url, 00217 Job *onConnJob ); 00218 00219 private: 00220 Channel *GetChannel( const URL &url ); 00221 00222 typedef std::map<std::string, Channel*> ChannelMap; 00223 Poller *pPoller; 00224 TaskManager *pTaskManager; 00225 ChannelMap pChannelMap; 00226 XrdSysMutex pChannelMapMutex; 00227 bool pInitialized; 00228 JobManager *pJobManager; 00229 }; 00230 } 00231 00232 #endif // __XRD_CL_POST_MASTER_HH__