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 //------------------------------------------------------------------------ 00134 //------------------------------------------------------------------------ 00135 Status Receive( const URL &url, 00136 Message *&msg, 00137 MessageFilter *filter, 00138 time_t expires ); 00139 00140 //------------------------------------------------------------------------ 00148 //------------------------------------------------------------------------ 00149 Status Receive( const URL &url, 00150 IncomingMsgHandler *handler, 00151 time_t expires ); 00152 00153 //------------------------------------------------------------------------ 00161 //------------------------------------------------------------------------ 00162 Status QueryTransport( const URL &url, 00163 uint16_t query, 00164 AnyObject &result ); 00165 00166 //------------------------------------------------------------------------ 00168 //------------------------------------------------------------------------ 00169 Status RegisterEventHandler( const URL &url, 00170 ChannelEventHandler *handler ); 00171 00172 //------------------------------------------------------------------------ 00174 //------------------------------------------------------------------------ 00175 Status RemoveEventHandler( const URL &url, 00176 ChannelEventHandler *handler ); 00177 00178 //------------------------------------------------------------------------ 00180 //------------------------------------------------------------------------ 00181 TaskManager *GetTaskManager() 00182 { 00183 return pTaskManager; 00184 } 00185 00186 //------------------------------------------------------------------------ 00188 //------------------------------------------------------------------------ 00189 JobManager *GetJobManager() 00190 { 00191 return pJobManager; 00192 } 00193 00194 private: 00195 Channel *GetChannel( const URL &url ); 00196 00197 typedef std::map<std::string, Channel*> ChannelMap; 00198 Poller *pPoller; 00199 TaskManager *pTaskManager; 00200 ChannelMap pChannelMap; 00201 XrdSysMutex pChannelMapMutex; 00202 bool pInitialized; 00203 JobManager *pJobManager; 00204 }; 00205 } 00206 00207 #endif // __XRD_CL_POST_MASTER_HH__