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 OutgoingMsgHandler *outHandler, 00129 IncomingMsgHandler *handler); 00130 00131 //------------------------------------------------------------------------ 00142 //------------------------------------------------------------------------ 00143 Status Receive( const URL &url, 00144 Message *&msg, 00145 MessageFilter *filter, 00146 time_t expires ); 00147 00148 //------------------------------------------------------------------------ 00156 //------------------------------------------------------------------------ 00157 Status Receive( const URL &url, 00158 IncomingMsgHandler *handler, 00159 time_t expires ); 00160 00161 //------------------------------------------------------------------------ 00169 //------------------------------------------------------------------------ 00170 Status QueryTransport( const URL &url, 00171 uint16_t query, 00172 AnyObject &result ); 00173 00174 //------------------------------------------------------------------------ 00176 //------------------------------------------------------------------------ 00177 Status RegisterEventHandler( const URL &url, 00178 ChannelEventHandler *handler ); 00179 00180 //------------------------------------------------------------------------ 00182 //------------------------------------------------------------------------ 00183 Status RemoveEventHandler( const URL &url, 00184 ChannelEventHandler *handler ); 00185 00186 //------------------------------------------------------------------------ 00188 //------------------------------------------------------------------------ 00189 TaskManager *GetTaskManager() 00190 { 00191 return pTaskManager; 00192 } 00193 00194 //------------------------------------------------------------------------ 00196 //------------------------------------------------------------------------ 00197 JobManager *GetJobManager() 00198 { 00199 return pJobManager; 00200 } 00201 00202 private: 00203 Channel *GetChannel( const URL &url ); 00204 00205 typedef std::map<std::string, Channel*> ChannelMap; 00206 Poller *pPoller; 00207 TaskManager *pTaskManager; 00208 ChannelMap pChannelMap; 00209 XrdSysMutex pChannelMapMutex; 00210 bool pInitialized; 00211 JobManager *pJobManager; 00212 }; 00213 } 00214 00215 #endif // __XRD_CL_POST_MASTER_HH__