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 00026 #include "XrdCl/XrdClStatus.hh" 00027 #include "XrdCl/XrdClURL.hh" 00028 #include "XrdCl/XrdClPostMasterInterfaces.hh" 00029 00030 #include "XrdSys/XrdSysPthread.hh" 00031 00032 namespace XrdCl 00033 { 00034 class Poller; 00035 class TaskManager; 00036 class Channel; 00037 class JobManager; 00038 00039 //---------------------------------------------------------------------------- 00041 //---------------------------------------------------------------------------- 00042 class PostMaster 00043 { 00044 public: 00045 //------------------------------------------------------------------------ 00047 //------------------------------------------------------------------------ 00048 PostMaster(); 00049 00050 //------------------------------------------------------------------------ 00052 //------------------------------------------------------------------------ 00053 virtual ~PostMaster(); 00054 00055 //------------------------------------------------------------------------ 00057 //------------------------------------------------------------------------ 00058 bool Initialize(); 00059 00060 //------------------------------------------------------------------------ 00062 //------------------------------------------------------------------------ 00063 bool Finalize(); 00064 00065 //------------------------------------------------------------------------ 00067 //------------------------------------------------------------------------ 00068 bool Start(); 00069 00070 //------------------------------------------------------------------------ 00072 //------------------------------------------------------------------------ 00073 bool Stop(); 00074 00075 //------------------------------------------------------------------------ 00077 //------------------------------------------------------------------------ 00078 bool Reinitialize(); 00079 00080 //------------------------------------------------------------------------ 00094 //------------------------------------------------------------------------ 00095 Status Send( const URL &url, 00096 Message *msg, 00097 bool stateful, 00098 time_t expires ); 00099 00100 //------------------------------------------------------------------------ 00116 //------------------------------------------------------------------------ 00117 Status Send( const URL &url, 00118 Message *msg, 00119 OutgoingMsgHandler *handler, 00120 bool stateful, 00121 time_t expires ); 00122 00123 //------------------------------------------------------------------------ 00125 //------------------------------------------------------------------------ 00126 Status Redirect( const URL &url, 00127 Message *msg, 00128 IncomingMsgHandler *handler); 00129 00130 //------------------------------------------------------------------------ 00141 //------------------------------------------------------------------------ 00142 Status Receive( const URL &url, 00143 Message *&msg, 00144 MessageFilter *filter, 00145 time_t expires ); 00146 00147 //------------------------------------------------------------------------ 00155 //------------------------------------------------------------------------ 00156 Status Receive( const URL &url, 00157 IncomingMsgHandler *handler, 00158 time_t expires ); 00159 00160 //------------------------------------------------------------------------ 00168 //------------------------------------------------------------------------ 00169 Status QueryTransport( const URL &url, 00170 uint16_t query, 00171 AnyObject &result ); 00172 00173 //------------------------------------------------------------------------ 00175 //------------------------------------------------------------------------ 00176 Status RegisterEventHandler( const URL &url, 00177 ChannelEventHandler *handler ); 00178 00179 //------------------------------------------------------------------------ 00181 //------------------------------------------------------------------------ 00182 Status RemoveEventHandler( const URL &url, 00183 ChannelEventHandler *handler ); 00184 00185 //------------------------------------------------------------------------ 00187 //------------------------------------------------------------------------ 00188 TaskManager *GetTaskManager() 00189 { 00190 return pTaskManager; 00191 } 00192 00193 //------------------------------------------------------------------------ 00195 //------------------------------------------------------------------------ 00196 JobManager *GetJobManager() 00197 { 00198 return pJobManager; 00199 } 00200 00201 //------------------------------------------------------------------------ 00203 //------------------------------------------------------------------------ 00204 Status ForceDisconnect( const URL &url ); 00205 00206 private: 00207 Channel *GetChannel( const URL &url ); 00208 00209 typedef std::map<std::string, Channel*> ChannelMap; 00210 Poller *pPoller; 00211 TaskManager *pTaskManager; 00212 ChannelMap pChannelMap; 00213 XrdSysMutex pChannelMapMutex; 00214 bool pInitialized; 00215 JobManager *pJobManager; 00216 }; 00217 } 00218 00219 #endif // __XRD_CL_POST_MASTER_HH__