#include <DistBossServer.h>
Public Member Functions | |
DistBossServer (const std::string &jobOpt) | |
~DistBossServer () | |
const std::string & | serverName () const |
int | run () |
Private Types | |
RawEvtSvc | |
SimSeedSvc | |
RootEvtSvc | |
WriteDst | |
WriteRec | |
WriteTuple | |
WriteHist | |
enum | SvcType { RawEvtSvc, SimSeedSvc, RootEvtSvc, WriteDst, WriteRec, WriteTuple, WriteHist } |
Private Member Functions | |
DistBossServer () | |
Static Private Member Functions | |
static std::string | autoServerName () |
Private Attributes | |
JobOptionsMgr | m_optMgr |
RpcInterface * | m_readerRpc |
std::vector< RpcInterface * > | m_writerRpcs |
ServerExitHandler * | m_exitHandler |
ServerErrorHandler * | m_errorHandler |
Static Private Attributes | |
static const std::string | m_serverName = DistBossServer::autoServerName() |
static const std::string | m_svc [7] |
Definition at line 9 of file DistBossServer.h.
enum DistBossServer::SvcType [private] |
Definition at line 39 of file DistBossServer.h.
00039 { 00040 RawEvtSvc, 00041 SimSeedSvc, 00042 RootEvtSvc, 00043 WriteDst, 00044 WriteRec, 00045 WriteTuple, 00046 WriteHist 00047 };
DistBossServer::DistBossServer | ( | const std::string & | jobOpt | ) |
Definition at line 37 of file DistBossServer.cxx.
References JobOptionsMgr::clientOptsTemplate(), JobOptionsMgr::dstFile(), JobOptionsMgr::evtMax(), JobOptionsMgr::inputFiles(), JobOptionsMgr::inputType(), m_errorHandler, m_exitHandler, m_optMgr, m_readerRpc, m_serverName, m_svc, m_writerRpcs, JobOptionsMgr::outputTypes(), and JobOptionsMgr::recFile().
00038 : m_optMgr(jobOpt) 00039 { 00040 if ( m_optMgr.evtMax() == 0 ) { 00041 std::cout << "[DistBossServer] EvtMax = 0, exit now!" << std::endl; 00042 exit(0); 00043 } 00044 00045 std::cout << "[DistBossServer] Starting server: " << m_serverName << std::endl; 00046 00047 switch ( m_optMgr.inputType() ) { 00048 case ( 0 ) : 00049 m_readerRpc = new ReaderRpc<RawFileReader>(m_svc[0], m_optMgr.inputFiles(), m_optMgr.evtMax()); 00050 break; 00051 case ( 1 ) : 00052 std::cout << "[DistBossServer] Simulation is not supported by DistBoss yet!" << std::endl; 00053 exit(1); 00054 case ( 2 ) : 00055 //m_readerRpc = new ReaderRpc<RootFileReader>(m_svc[2], m_optMgr.inputFiles(), m_optMgr.evtMax()); 00056 //break; 00057 std::cout << "[DistBossServer] Root input files are not supported by DistBoss yet!" << std::endl; 00058 exit(1); 00059 default : 00060 assert( false ); //we shouldn't come here 00061 } 00062 00063 const std::vector<int>& outputs = m_optMgr.outputTypes(); 00064 for ( std::vector<int>::const_iterator it = outputs.begin(); it != outputs.end(); ++it ) { 00065 switch ( *it ) { 00066 case ( 3 ) : 00067 m_writerRpcs.push_back(new WriterRpc<RootFileWriter>(m_svc[3], m_optMgr.dstFile())); 00068 break; 00069 case ( 4 ) : 00070 m_writerRpcs.push_back(new WriterRpc<RootFileWriter>(m_svc[4], m_optMgr.recFile())); 00071 break; 00072 case ( 5 ) : 00073 //std::cout << "[DistBossServer] Ntuple outputs is not supported by DistBoss yet!" << std::endl; 00074 break; 00075 case ( 6 ) : 00076 //std::cout << "[DistBossServer] Hist outputs is not supported by DistBoss yet!" << std::endl; 00077 break; 00078 default : 00079 assert(false); //we shouldn't come here 00080 } 00081 } 00082 00083 m_optMgr.clientOptsTemplate( m_serverName ); 00084 00085 m_exitHandler = new ServerExitHandler(); 00086 m_errorHandler = new ServerErrorHandler(); 00087 }
DistBossServer::~DistBossServer | ( | ) |
Definition at line 89 of file DistBossServer.cxx.
References genRecEmupikp::i, m_exitHandler, m_readerRpc, and m_writerRpcs.
00090 { 00091 delete m_readerRpc; 00092 00093 for ( unsigned int i = 0; i < m_writerRpcs.size(); ++i ) { 00094 delete m_writerRpcs[i]; 00095 } 00096 00097 std::cout << "[DistBossServer] Server stopped." << std::endl; 00098 00099 delete m_exitHandler; 00100 }
DistBossServer::DistBossServer | ( | ) | [private] |
std::string DistBossServer::autoServerName | ( | ) | [static, private] |
Definition at line 23 of file DistBossServer.cxx.
References deljobs::string.
00024 { 00025 std::stringstream spid; 00026 spid << getpid(); 00027 00028 char hname[64]; 00029 gethostname(hname, 64); 00030 00031 std::string name("/DistBoss/P"); 00032 name += spid.str() + "@" + hname; 00033 00034 return name; 00035 }
int DistBossServer::run | ( | ) |
Definition at line 102 of file DistBossServer.cxx.
References genRecEmupikp::i, m_errorHandler, m_exitHandler, m_readerRpc, m_serverName, m_writerRpcs, deljobs::start, and RpcInterface::wait_to_end().
Referenced by main().
00103 { 00104 DimServer::addExitHandler( m_exitHandler ); 00105 DimServer::addErrorHandler( m_errorHandler ); 00106 00107 DimServer::start(m_serverName.c_str()); 00108 00109 // we'd better check the return value of wait_to_end() here 00110 int nClients = m_readerRpc->wait_to_end(); 00111 00112 for ( unsigned int i = 0; i < m_writerRpcs.size(); ++i ) { 00113 nClients = m_writerRpcs[i]->wait_to_end(); 00114 } 00115 00116 return nClients; 00117 }
const std::string& DistBossServer::serverName | ( | ) | const [inline] |
Definition at line 16 of file DistBossServer.h.
References m_serverName.
00016 { return m_serverName; }
ServerErrorHandler* DistBossServer::m_errorHandler [private] |
ServerExitHandler* DistBossServer::m_exitHandler [private] |
Definition at line 32 of file DistBossServer.h.
Referenced by DistBossServer(), run(), and ~DistBossServer().
JobOptionsMgr DistBossServer::m_optMgr [private] |
RpcInterface* DistBossServer::m_readerRpc [private] |
Definition at line 29 of file DistBossServer.h.
Referenced by DistBossServer(), run(), and ~DistBossServer().
const std::string DistBossServer::m_serverName = DistBossServer::autoServerName() [static, private] |
Definition at line 35 of file DistBossServer.h.
Referenced by DistBossServer(), run(), and serverName().
const std::string DistBossServer::m_svc [static, private] |
Initial value:
{ m_serverName + "/RawEvtSvc", m_serverName + "/SimSeedSvc", m_serverName + "/RootEvtSvc", m_serverName + "/WriteDst", m_serverName + "/WriteRec", m_serverName + "/WriteTuple", m_serverName + "/WriteHist" }
Definition at line 48 of file DistBossServer.h.
Referenced by DistBossServer().
std::vector<RpcInterface*> DistBossServer::m_writerRpcs [private] |
Definition at line 30 of file DistBossServer.h.
Referenced by DistBossServer(), run(), and ~DistBossServer().