1#include "DistBossServer/JobOptionsMgr.h"
3#include "GaudiKernel/IMessageSvc.h"
4#include "GaudiKernel/ISvcLocator.h"
5#include "GaudiKernel/Bootstrap.h"
6#include "GaudiKernel/Service.h"
7#include "GaudiKernel/StatusCode.h"
8#include "GaudiKernel/Property.h"
9#include "GaudiKernel/Parsers.h"
10#include "JobOptionsSvc.h"
13#define CheckSTATUS(msg) \
14 if ( sc.isFailure() ) { \
15 std::cout << "[JobOptionsMgr] " << msg << std::endl; \
21 sc = Gaudi::Parsers::parse(var, pprop->toString()); \
22 if ( sc.isFailure() ) { \
23 std::cout << "[JobOptionsMgr] Failed to parse " << #var << std::endl; \
33 m_dstFile(
"digi.root"),
34 m_recFile(
"digi.root")
37 StatusCode sc = Gaudi::svcLocator()->service(
"JobOptionsSvc", svc);
38 CheckSTATUS(
"Failed to retrieve the JobOptionsSvc");
39 m_svc =
dynamic_cast<JobOptionsSvc*
>(svc);
41 sc = m_svc->setProperty( StringProperty(
"TYPE",
"FILE") );
42 sc = m_svc->setProperty( StringProperty(
"PATH", optname) );
43 CheckSTATUS(
"Failed to set the property of DistBossServer");
45 sc = m_svc->initialize();
48 const Property* pprop = getProperty(
"ApplicationMgr",
"EvtMax");
49 if ( pprop != NULL ) {
53 if ( (pprop = getProperty(
"RawDataInputSvc",
"InputFiles")) != NULL ) {
57 else if ( (pprop = getProperty(
"BesSim",
"TDSFlag")) != NULL ) {
61 else if ( (pprop = getProperty(
"EventCnvSvc",
"digiRootInputFile")) != NULL ) {
66 std::cout <<
"[JobOptionsMgr] Unknown Job Type!" << std::endl;
70 if ( (pprop = getProperty(
"EventPreSelect",
"WriteDst")) != NULL ) {
74 m_oFileTypes.push_back(3);
75 if ( (pprop = getProperty(
"WriteDst",
"digiRootOutputFile")) != NULL ) {
81 if ( (pprop = getProperty(
"EventPreSelect",
"WriteRec")) != NULL ) {
85 m_oFileTypes.push_back(4);
86 if ( (pprop = getProperty(
"WriteRec",
"digiRootOutputFile")) != NULL ) {
92 if ( (pprop = getProperty(
"NTupleSvc",
"Output")) != NULL ) {
93 m_oFileTypes.push_back(5);
97 if ( (pprop = getProperty(
"THistSvc",
"Output")) != NULL ) {
98 m_oFileTypes.push_back(6);
105 StatusCode sc = m_svc->finalize();
109#define ignorePROPERTY(client, pname) \
110 if ( clients[i] == client && property->name() == pname ) continue
115 SvcCatalog* m_clientCatalogue =
new SvcCatalog;
119 std::vector<std::string> clients = m_svc->getClients();
120 for (
unsigned int i = 0; i < clients.size(); ++i ) {
121 const std::vector<const Property*>* properties = m_svc->getProperties(clients[i]);
122 for (
unsigned int j = 0; j < properties->size(); ++j ) {
123 const Property*
property = properties->at(j);
136 StringProperty* tmp=
new StringProperty(property->name(), property->toString());
137 sc = m_clientCatalogue->addProperty(clients[i], tmp);
138 if ( sc.isFailure() ) {
139 StringProperty* tmp2 =
new StringProperty(property->name(),
'"'+property->toString()+
'"');
140 m_clientCatalogue->addProperty(clients[i], tmp2);
145 StringProperty* tmpservername =
new StringProperty(
"ServerName",
'"'+svrName+
'"');
146 m_clientCatalogue->addProperty(
"DistBoss", tmpservername);
147 if ( m_iFileType == 0 ) {
148 StringProperty* tmprunmode =
new StringProperty(
"RunMode",
"3");
149 m_clientCatalogue->addProperty(
"RawDataInputSvc", tmprunmode);
157 for (
unsigned int i = 0; i < m_oFileTypes.size(); ++i ) {
158 int type = m_oFileTypes[i];
160 m_clientCatalogue->addProperty(
"WriteDst",
new StringProperty(
"RunMode",
"3"));
162 else if ( type == 4 ) {
163 m_clientCatalogue->addProperty(
"WriteRec",
new StringProperty(
"RunMode",
"3"));
173 std::string client_opt_name = m_optName +
".distboss_client";
174 std::ofstream os(client_opt_name.c_str(), std::ios::out|std::ios::trunc);
176 std::cout <<
"[JobOptionsMgr] Failed to open client_template file!" << std::endl;
180 m_clientCatalogue->fillStream( os );
182 delete m_clientCatalogue;
185const Property* JobOptionsMgr::getProperty(
const std::string& client,
const std::string& name)
187 const Property* pprop = NULL;
189 const std::vector<const Property*>* properties = m_svc->getProperties(client);
190 if ( properties != NULL ) {
191 for (
unsigned int i = 0; i < properties->size(); ++i ) {
192 if ( properties->at(i)->name() == name) {
193 pprop = properties->at(i);
#define ignorePROPERTY(client, pname)
void clientOptsTemplate(const std::string &svrName)
JobOptionsMgr(const std::string &optname)