27 #include "GaudiCoreSvcVersion.h"
38 static const char* s_eventloop =
"EventLoop";
39 static const char* s_runable =
"Runable";
41 #define ON_DEBUG if (UNLIKELY(m_outputLevel <= MSG::DEBUG))
42 #define ON_VERBOSE if (UNLIKELY(m_outputLevel <= MSG::VERBOSE))
67 m_svcLocator = svcManager();
74 m_name =
"ApplicationMgr";
78 m_propertyMgr->declareProperty(
"Go", m_SIGo = 0 );
79 m_propertyMgr->declareProperty(
"Exit", m_SIExit = 0 );
80 m_propertyMgr->declareProperty(
"Dlls", m_dllNameList );
81 m_propertyMgr->declareProperty(
"ExtSvc", m_extSvcNameList );
82 m_propertyMgr->declareProperty(
"CreateSvc", m_createSvcNameList );
83 m_propertyMgr->declareProperty(
"ExtSvcCreates", m_extSvcCreates=
true );
85 m_propertyMgr->declareProperty(
"SvcMapping", m_svcMapping );
86 m_propertyMgr->declareProperty(
"SvcOptMapping", m_svcOptMapping );
88 m_propertyMgr->declareProperty(
"TopAlg", m_topAlgNameList );
89 m_propertyMgr->declareProperty(
"OutStream", m_outStreamNameList );
90 m_propertyMgr->declareProperty(
"OutStreamType", m_outStreamType =
"OutputStream" );
91 m_propertyMgr->declareProperty(
"MessageSvcType",m_messageSvcType=
"MessageSvc" );
92 m_propertyMgr->declareProperty(
"JobOptionsSvcType",
93 m_jobOptionsSvcType =
"JobOptionsSvc" );
94 m_propertyMgr->declareProperty( s_runable, m_runableType =
"AppMgrRunable");
95 m_propertyMgr->declareProperty( s_eventloop, m_eventLoopMgr =
"EventLoopMgr");
97 m_propertyMgr->declareProperty(
"HistogramPersistency", m_histPersName=
"NONE");
100 m_propertyMgr->declareProperty(
"JobOptionsType", m_jobOptionsType =
"FILE");
101 m_propertyMgr->declareProperty(
"JobOptionsPath", m_jobOptionsPath =
"");
102 m_propertyMgr->declareProperty(
"EvtMax", m_evtMax = -1);
103 m_propertyMgr->declareProperty(
"EvtSel", m_evtsel );
104 m_propertyMgr->declareProperty(
"OutputLevel", m_outputLevel =
MSG::INFO);
106 m_propertyMgr->declareProperty(
"MultiThreadExtSvc", m_multiThreadSvcNameList);
107 m_propertyMgr->declareProperty(
"NoOfThreads", m_noOfEvtThreads = 0);
108 m_propertyMgr->declareProperty(
"AppName", m_appName =
"ApplicationMgr");
109 m_propertyMgr->declareProperty(
"AppVersion", m_appVersion =
"");
111 m_propertyMgr->declareProperty(
"AuditTools", m_auditTools =
false);
112 m_propertyMgr->declareProperty(
"AuditServices", m_auditSvcs =
false);
113 m_propertyMgr->declareProperty(
"AuditAlgorithms", m_auditAlgs =
false);
115 m_propertyMgr->declareProperty(
"ActivateHistory", m_actHistory =
false);
116 m_propertyMgr->declareProperty(
"StatusCodeCheck", m_codeCheck =
false);
118 m_propertyMgr->declareProperty(
"Environment", m_environment);
121 m_propertyMgr->declareProperty(
"InitializationLoopCheck", m_loopCheck =
true)
123 svcManager()->setLoopCheckEnabled(m_loopCheck);
126 m_propertyMgr->declareProperty
128 m_propertiesPrint =
false,
129 "Flag to activate the printout of properties" );
131 m_propertyMgr->declareProperty(
"PluginDebugLevel", m_pluginDebugLevel = 0 );
133 m_propertyMgr->declareProperty(
"StopOnSignal", m_stopOnSignal =
false,
134 "Flag to enable/disable the signal handler that schedule a stop of the event loop");
136 m_propertyMgr->declareProperty(
"StalledEventMonitoring", m_stalledEventMonitoring =
false,
137 "Flag to enable/disable the monitoring and reporting of stalled events");
140 "Return code of the application. Set internally in case of error conditions.");
142 m_propertyMgr->declareProperty(
"AlgTypeAliases", algMgr->
typeAliases(),
143 "Aliases of algorithm types, to replace an algorithm type for every instance");
152 m_svcMapping.push_back(
"EvtDataSvc/EventDataSvc");
153 m_svcMapping.push_back(
"DetDataSvc/DetectorDataSvc");
154 m_svcMapping.push_back(
"HistogramSvc/HistogramDataSvc");
155 m_svcMapping.push_back(
"HbookCnv::PersSvc/HbookHistSvc");
156 m_svcMapping.push_back(
"RootHistCnv::PersSvc/RootHistSvc");
157 m_svcMapping.push_back(
"EvtPersistencySvc/EventPersistencySvc");
158 m_svcMapping.push_back(
"DetPersistencySvc/DetectorPersistencySvc");
159 m_svcMapping.push_back(
"HistogramPersistencySvc/HistogramPersistencySvc");
187 {
return serviceLocator()-> queryInterface ( iid , ppvi ) ; }
189 {
return svcManager() -> queryInterface ( iid , ppvi ) ; }
191 {
return algManager() -> queryInterface ( iid , ppvi ) ; }
193 {
return m_classManager -> queryInterface ( iid , ppvi ) ; }
195 {
return m_propertyMgr -> queryInterface ( iid , ppvi ) ; }
198 *ppvi =
reinterpret_cast<void*
>(m_messageSvc.get());
200 m_messageSvc->addRef();
228 fatal() <<
"Error creating JobOptionsSvc" <<
endmsg;
233 if ( !jobOptsIProp.
isValid() ) {
234 fatal() <<
"Error locating JobOptionsSvc" <<
endmsg;
239 fatal() <<
"Error setting TYPE option in JobOptionsSvc" <<
endmsg;
246 fatal() <<
"Error setting PATH option in JobOptionsSvc" <<
endmsg;
250 else if (
isEnvSet(
"JOBOPTPATH") ) {
255 <<
"Error setting PATH option in JobOptionsSvc from env"
262 "../options/job.opts"));
265 <<
"Error setting PATH option in JobOptionsSvc to default"
270 jobOptsIProp->release();
276 msgSvcIProp->release();
278 sc = jobsvc->sysInitialize();
280 fatal() <<
"Error initializing JobOptionsSvc" <<
endmsg;
283 sc = msgsvc->sysInitialize();
285 fatal() <<
"Error initializing MessageSvc" <<
endmsg;
292 fatal() <<
"Error retrieving MessageSvc." <<
endmsg;
297 fatal() <<
"Error retrieving JobOptionsSvc." <<
endmsg;
316 <<
"configure: Invalid state \"" <<
m_state <<
"\"" <<
endmsg;
337 log <<
MSG::WARNING <<
"Problems getting my properties from JobOptionsSvc"
349 <<
"=================================================================="
350 <<
"=================================================================="
361 <<
"v" << GAUDICORESVC_MAJOR_VERSION
362 <<
"r" << GAUDICORESVC_MINOR_VERSION
363 #if GAUDICORESVC_PATCH_VERSION
364 <<
"p" << GAUDICORESVC_PATCH_VERSION
375 <<
"=================================================================="
376 <<
"=================================================================="
383 typedef std::vector<Property*> Properties;
386 <<
"List of ALL properties of "
388 <<
" #properties = " << properties.size() <<
endmsg ;
389 for ( Properties::const_iterator property = properties.begin() ;
390 properties.end() != property ; ++property )
391 { log <<
"Property ['Name': Value] = " << ( **property) <<
endmsg ; }
399 log <<
MSG::FATAL <<
"Error adding StatusCodeSvc for multiple threads" <<
endmsg;
407 std::map<std::string,std::string>::iterator var;
409 const std::string &
name = var->first;
410 const std::string &
value = var->second;
412 const MSG::Level lvl = (!old.empty() && (old !=
"UNKNOWN" ))
416 log << lvl <<
"Setting " << name <<
" = " << value <<
endmsg;
421 VectorName::const_iterator j;
425 log <<
MSG::ERROR <<
"configure: declaring svc type:'" << *j <<
"' failed." <<
endmsg;
432 log <<
MSG::ERROR <<
"configure: declaring svc type:'" << *j <<
"' failed." <<
endmsg;
449 log <<
MSG::ERROR <<
"Failure during external service association" <<
endmsg;
455 log <<
MSG::ERROR <<
"Failure during multi thread service creation"
482 <<
"\n Check option ApplicationMgr." << s_runable <<
endmsg;
489 <<
"\n Check option ApplicationMgr." << s_eventloop
490 <<
"\n No events will be processed." <<
endmsg;
507 sc =
svcManager()->addService(
"HistorySvc",std::numeric_limits<int>::max());
514 sc =
addMultiSvc(
"HistorySvc",std::numeric_limits<int>::max());
516 log <<
MSG::FATAL <<
"Error adding HistorySvc for multiple threads"
523 log <<
MSG::INFO <<
"Application Manager Configured successfully" <<
endmsg;
540 std::string svcname(
"Gaudi::Utils::StopSignalHandler");
543 log <<
MSG::INFO <<
"Cannot instantiate " << svcname <<
"signals will be ignored" <<
endmsg;
549 std::string svcname(
"StalledEventMonitor");
552 log <<
MSG::INFO <<
"Cannot instantiate " << svcname <<
"signals will be ignored" <<
endmsg;
562 <<
"initialize: Invalid state \"" <<
m_state <<
"\"" <<
endmsg;
576 log <<
MSG::INFO <<
"Application Manager Initialized successfully" <<
endmsg;
610 log <<
MSG::INFO <<
"Application Manager Started successfully" <<
endmsg;
628 log <<
MSG::FATAL <<
"No event processing manager specified. Check option:"
667 log <<
MSG::INFO <<
"Application Manager Stopped successfully" <<
endmsg;
714 log <<
MSG::INFO <<
"Application Manager Finalized successfully" <<
endmsg;
742 log <<
MSG::INFO <<
"Application Manager Terminated successfully" <<
endmsg;
744 log <<
MSG::INFO <<
"Application Manager Terminated successfully with a user requested ScheduledStop" <<
endmsg;
765 log <<
MSG::ERROR <<
"Could not get the IService interface of the MessageSvc" <<
endmsg;
767 svc->sysFinalize().ignore();
773 log <<
MSG::ERROR <<
"Could not get the IService interface of the JobOptionsSvc" <<
endmsg;
775 svc->sysFinalize().ignore();
861 log <<
MSG::FATAL <<
"Application execution failed. Ending the job."
865 log <<
MSG::FATAL <<
"Application has no runable object. Check option:"
949 throw GaudiException(
"Cannot reinitialize application if not INITIALIZED or RUNNING",
1012 props->setProperty( p ).ignore();
1023 "MinimalEventLoopMgr::createSvcNameListHandler",
1033 VectorName::const_iterator it(theNames.begin());
1034 VectorName::const_iterator et(theNames.end());
1039 log <<
MSG::ERROR <<
"decodeCreateSvcNameList: Cannot create service "
1044 log <<
MSG::DEBUG <<
"decodeCreateSvcNameList: Created service "
1058 "MinimalEventLoopMgr::extSvcNameListHandler",
1071 VectorName::const_iterator it(theNames.begin());
1072 VectorName::const_iterator et(theNames.end());
1078 log <<
MSG::ERROR <<
"decodeExtSvcNameList: Cannot create service "
1083 item.
type()) ).isFailure()) {
1085 log <<
MSG::ERROR <<
"decodeExtSvcNameList: Cannot declare service "
1099 "MinimalEventLoopMgr::multiThreadSvcNameListHandler",
1112 for (VectorName::const_iterator it = theNames.begin();
1113 it != theNames.end();
1121 <<
"decodeMultiThreadSvcNameList: Cannot create service "
1127 <<
"decodeMultiThreadSvcNameList: created service "
1139 const std::string&
type) {
1143 result =
svcManager()->declareSvcType(name, type);
1145 log <<
MSG::ERROR <<
"declareMultiSvcType: Cannot declare service "
1146 << type <<
"/" << name <<
endmsg;
1149 log <<
MSG::VERBOSE <<
"declareMultiSvcType: declared service "
1150 << type <<
"/" << name <<
endmsg;
1155 result =
svcManager()->declareSvcType(thrName, type);
1157 log <<
MSG::ERROR <<
"declareMultiSvcType: Cannot declare service "
1158 << type <<
"/" << thrName <<
endmsg;
1161 log <<
MSG::VERBOSE <<
"declareMultiSvcType: declared service "
1162 << type <<
"/" << thrName <<
endmsg;
1177 result =
svcManager()->addService(typeName, prio);
1180 log <<
MSG::ERROR <<
"addMultiSvc: Cannot add service "
1189 const std::string &
type = typeName.
type();
1191 result =
svcManager()->addService(TypeNameString(thrName, type), prio);
1192 if( result.isFailure() ) {
1193 log <<
MSG::ERROR <<
"addMultiSvc: Cannot add service "
1194 << type <<
"/" << thrName <<
endmsg;
1198 << type <<
"/" << thrName <<
endmsg;
1211 "MinimalEventLoopMgr::dllNameListHandler",
1226 std::vector<std::string> newList;
1227 std::map<std::string,unsigned int> dllInList, duplicateList;
1230 if ( 0 == dllInList[*it] ) {
1231 newList.push_back(*it);
1232 }
else { ++duplicateList[*it]; }
1238 ON_DEBUG if ( !duplicateList.empty() ) {
1239 log <<
MSG::DEBUG <<
"Removed duplicate entries for modules : ";
1240 for ( std::map<std::string,unsigned int>::const_iterator it = duplicateList.begin();
1241 it != duplicateList.end(); ++it ) {
1242 log << it->first <<
"(" << 1+it->second <<
")";
1243 if ( it != --duplicateList.end() ) log <<
", ";
1249 const std::vector<std::string>& theNames = newList;
1254 std::vector<std::string> successNames, failNames;
1255 std::vector<std::string>::const_iterator it;
1257 for (it = theNames.begin(); it != theNames.end(); it++) {
1262 failNames.push_back(*it);
1266 successNames.push_back(*it);
1272 if ( !successNames.empty() ) {
1273 log <<
MSG::INFO <<
"Successfully loaded modules : ";
1274 for (it = successNames.begin(); it != successNames.end(); it++) {
1276 if( (it+1) != successNames.end()) log <<
", ";
1285 for (it = failNames.begin(); it != failNames.end(); it++) {
1287 if( (it+1) != failNames.end()) log <<
", ";
1302 <<
"Updating Gaudi::PluginService::SetDebug(level) to level="
The ServiceManager class is in charge of the creation of concrete instances of Services.
void dllNameListHandler(Property &theProp)
Gaudi::StateMachine::State m_targetState
Internal State.
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
The AlgorithmManager class is in charge of the creation of concrete instances of Algorithms.
StatusCode setProperty(IProperty *component, const std::string &name, const TYPE &value, const std::string &doc)
simple function to set the property of the given object from the value
virtual Gaudi::StateMachine::State FSMState() const
Get the current state.
std::string m_jobOptionsType
Source type (e.g. dbase, file...)
StringArrayProperty m_createSvcNameList
void createSvcNameListHandler(Property &)
Definition of the MsgStream class used to transmit messages.
StringProperty m_messageSvcType
MessageSvc type.
Define general base for Gaudi exception.
StatusCode decodeDllNameList()
GAUDI_API int setEnv(const std::string &name, const std::string &value, int overwrite=1)
Set an environment variables.
SmartIF< IRunable > m_runable
Reference to the runable object.
virtual ~ApplicationMgr()
MSG::Level level()
Retrieve output level.
virtual StatusCode executeEvent(void *par)
implementation of IEventProcessor::executeEvent(void*)
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
int m_noOfEvtThreads
no of multiThreadSvc copies
unsigned long id() const
get the interface identifier
bool m_codeCheck
Activate StatusCode checking.
static Time current(void)
Returns the current time.
bool isSuccess() const
Test for a status code of SUCCESS.
std::string m_appName
The name of the application.
IntegerProperty m_pluginDebugLevel
Debug level for the plugin system.
static GAUDI_API void enableChecking()
std::vector< std::string > m_okDlls
names of successfully loaded dlls
std::map< std::string, std::string > m_environment
Environment variables to set.
State
Allowed states for classes implementing the state machine (ApplicationMgr, Algorithm, Service, AlgTool).
virtual StatusCode restart()
Initialization (from RUNNING to RUNNING, via INITIALIZED).
StringArrayProperty m_dllNameList
List of DDL's names.
SimpleProperty< bool > BooleanProperty
SmartIF< IJobOptionsSvc > m_jobOptionsSvc
Reference to JobOption service.
AlgTypeAliasesMap & typeAliases()
Property manager helper class.
virtual Gaudi::StateMachine::State targetFSMState() const
When we are in the middle of a transition, get the state where the transition is leading us...
bool isFailure() const
Test for a status code of FAILURE.
SmartIF< IEventProcessor > m_processingMgr
Reference to processing manager object.
SmartIF< ISvcManager > & svcManager()
SimpleProperty< std::string > StringProperty
int m_outputLevel
Message output level.
virtual StatusCode run()
Run the complete job (from initialize to terminate)
DLLClassManager * m_classManager
Reference to the class manager.
PropertyMgr * m_propertyMgr
Reference to Property Manager.
StatusCode addMultiSvc(const Gaudi::Utils::TypeNameString &typeName, int prio)
add one or more copies of svc type/name as determined by NoOfThreads
const int FinalizationFailure
Error codes for operation failures.
Gaudi::InterfaceId< IInterface, 0, 0 > iid
Interface ID.
virtual StatusCode stopRun()
implementation of IEventProcessor::stopRun()
int m_evtMax
Number of events to be processed.
virtual void declareUpdateHandler(PropertyCallbackFunctor *pf)
set new callback for update
IntegerProperty m_returnCode
Property to record the error conditions occurring during the running.
void multiThreadSvcNameListHandler(Property &theProp)
GAUDIPS_API void SetDebug(int debugLevel)
Backward compatibility with Reflex.
virtual const std::string & name() const
This is needed to avoid ambiguous calls to name()
Helper class to parse a string of format "type/name".
virtual StatusCode start()
Start (from INITIALIZED to RUNNING).
bool isValid() const
Allow for check if smart pointer is valid.
std::string m_jobOptionsPath
The "file" to look for properties.
BooleanProperty m_extSvcCreates
LHCb or ATLAS defn of "ExtSvc".
VectorName m_svcMapping
Default mapping of services.
SmartIF< ISvcLocator > m_svcLocator
Reference to its own service locator.
This class is used for returning status codes from appropriate routines.
Definition of the basic interface.
bool m_actHistory
Activate HistorySvc.
#define DECLARE_OBJECT_FACTORY(x)
BooleanProperty m_loopCheck
For ServiceMgr initialization loop checking.
GAUDI_API std::string getGaudiThreadIDfromID(int iCopy)
helper function to extract Gaudi Thread ID from thread copy number
virtual StatusCode reinitialize()
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
StatusCode GoToState(Gaudi::StateMachine::State state, bool ignoreFailures=false)
Reach a state from current state (whichever it is) going through the correct transitions.
static const int DEFAULT_SVC_PRIORITY
SimpleProperty< int > IntegerProperty
const TYPE & value() const
explicit conversion
StringArrayProperty m_multiThreadSvcNameList
List of external services names for which we want a copy per evt thread.
virtual StatusCode queryInterface(const InterfaceID &iid, void **pinterface)
Set the void** to the pointer to the requested interface of the instance.
VectorName m_svcOptMapping
Default mapping of services.
GAUDI_API bool isEnvSet(const char *var)
Check if an environment variable is set or not.
The Application Manager class.
virtual StatusCode stop()
Stop (from RUNNING to INITIALIZED).
std::string m_runableType
Runable type.
StatusCode decodeExtSvcNameList()
const std::vector< Property * > & getProperties() const
get all properties
GAUDI_API const std::string & hostName()
Host name.
void initLoopCheckHndlr(Property &)
bool m_propertiesPrint
flag to activate the printout of properties
Property base class allowing Property* collections to be "homogeneous".
void SIGoHandler(Property &theProp)
virtual unsigned long release()=0
Release Interface instance.
StringArrayProperty m_extSvcNameList
List of external services names.
StringProperty m_jobOptionsSvcType
JobOptionsSvc type.
const std::string & type() const
StatusCode decodeCreateSvcNameList()
void evtLoopPropertyHandler(Property &theProp)
virtual StatusCode nextEvent(int maxevt)
Process the next maxevt events.
BooleanProperty m_stalledEventMonitoring
Property to enable/disable the monitoring and reporting of stalled events (enabled by default)...
std::string m_eventLoopMgr
Processing manager type.
virtual StatusCode finalize()
Finalize the job.
void SIExitHandler(Property &theProp)
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
StatusCode i_startup()
Internal startup routine.
static GAUDI_API void disableChecking()
virtual StatusCode initialize()
Initialize the job.
Gaudi::StateMachine::State m_state
Internal State.
const std::string & name() const
std::string typeName(const std::type_info &typ)
StatusCode decodeMultiThreadSvcNameList()
virtual StatusCode terminate()
Terminate the job.
The IProperty is the basic interface for all components which have properties that can be set or get...
SmartIF< IAlgManager > & algManager()
void extSvcNameListHandler(Property &theProp)
void pluginDebugPropertyHandler(Property &theProp)
BooleanProperty m_stopOnSignal
Property to enable/disable the "stop on signal" service (enabled by default).
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
std::string m_appVersion
The version of the application.
SmartIF< IMessageSvc > m_messageSvc
Reference to the message service.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
virtual StatusCode loadModule(const std::string &module, bool fireIncident=true)
Declare a sharable library to be used for creating instances of a given algorithm type...
virtual StatusCode executeRun(int evtmax)
implementation of IEventProcessor::executeRun(int)
virtual StatusCode configure()
Configure the job.
std::string format(bool local, std::string spec="%c") const
Format the time using strftime.
StatusCode declareMultiSvcType(const std::string &name, const std::string &type)
declare one or more copies of svc type/name as determined by NoOfThreads