24 #include "GaudiCoreSvcVersion.h" 34 #define ON_DEBUG if ( UNLIKELY( m_outputLevel <= MSG::DEBUG ) ) 35 #define ON_VERBOSE if ( UNLIKELY( m_outputLevel <= MSG::VERBOSE ) ) 53 m_managers[IService::interfaceID().id()] =
new ServiceManager(
this );
55 m_svcLocator = svcManager();
62 m_managers[IAlgorithm::interfaceID().id()] = algMgr;
67 "Aliases of algorithm types, to replace an algorithm type for every instance" );
78 svcManager()->setLoopCheckEnabled( m_loopCheck );
80 m_svcMapping = {
"EvtDataSvc/EventDataSvc",
81 "DetDataSvc/DetectorDataSvc",
82 "HistogramSvc/HistogramDataSvc",
83 "HbookCnv::PersSvc/HbookHistSvc",
84 "RootHistCnv::PersSvc/RootHistSvc",
85 "EvtPersistencySvc/EventPersistencySvc",
86 "DetPersistencySvc/DetectorPersistencySvc",
87 "HistogramPersistencySvc/HistogramPersistencySvc"};
147 fatal() <<
"Error creating JobOptionsSvc" <<
endmsg;
151 auto jobOptsIProp = jobsvc.as<
IProperty>();
152 if ( !jobOptsIProp ) {
153 fatal() <<
"Error locating JobOptionsSvc" <<
endmsg;
158 fatal() <<
"Error setting TYPE option in JobOptionsSvc" <<
endmsg;
165 fatal() <<
"Error setting JobOptionsPreAction option in JobOptionsSvc" <<
endmsg;
173 fatal() <<
"Error setting JobOptionsPostAction option in JobOptionsSvc" <<
endmsg;
181 fatal() <<
"Error setting PATH option in JobOptionsSvc" <<
endmsg;
184 }
else if (
isEnvSet(
"JOBOPTPATH" ) ) {
187 fatal() <<
"Error setting PATH option in JobOptionsSvc from env" <<
endmsg;
193 fatal() <<
"Error setting PATH option in JobOptionsSvc to default" <<
endmsg;
197 jobOptsIProp.reset();
201 auto msgSvcIProp = msgsvc.as<
IProperty>();
205 sc = jobsvc->sysInitialize();
207 fatal() <<
"Error initializing JobOptionsSvc" <<
endmsg;
210 sc = msgsvc->sysInitialize();
212 fatal() <<
"Error initializing MessageSvc" <<
endmsg;
219 fatal() <<
"Error retrieving MessageSvc." <<
endmsg;
224 fatal() <<
"Error retrieving JobOptionsSvc." <<
endmsg;
274 <<
"==================================================================" 275 <<
"==================================================================" <<
std::endl 283 <<
"v" << GAUDICORESVC_MAJOR_VERSION <<
"r" << GAUDICORESVC_MINOR_VERSION
284 #if GAUDICORESVC_PATCH_VERSION 285 <<
"p" << GAUDICORESVC_PATCH_VERSION
294 <<
"==================================================================" 295 <<
"==================================================================" <<
endmsg;
304 log <<
"Property ['Name': Value] = " << *
property <<
endmsg;
313 log <<
MSG::FATAL <<
"Error adding StatusCodeSvc for multiple threads" <<
endmsg;
334 log <<
MSG::ERROR <<
"configure: declaring svc type:'" << j <<
"' failed." <<
endmsg;
341 log <<
MSG::ERROR <<
"configure: declaring svc type:'" << j <<
"' failed." <<
endmsg;
358 log <<
MSG::ERROR <<
"Failure during external service association" <<
endmsg;
364 log <<
MSG::ERROR <<
"Failure during multi thread service creation" <<
endmsg;
378 sc =
addMultiSvc( evtloop_item, ServiceManager::DEFAULT_SVC_PRIORITY * 10 );
387 log <<
MSG::FATAL <<
"Error retrieving Runable: " <<
m_runableType.value() <<
"\n Check option ApplicationMgr." 394 <<
"\n Check option ApplicationMgr." <<
m_eventLoopMgr.name() <<
"\n No events will be processed." <<
endmsg;
416 log <<
MSG::FATAL <<
"Error adding HistorySvc for multiple threads" <<
endmsg;
422 log <<
MSG::INFO <<
"Application Manager Configured successfully" <<
endmsg;
440 std::string svcname(
"Gaudi::Utils::StopSignalHandler" );
443 log <<
MSG::INFO <<
"Cannot instantiate " << svcname <<
"signals will be ignored" <<
endmsg;
452 log <<
MSG::INFO <<
"Cannot instantiate " << svcname <<
"signals will be ignored" <<
endmsg;
475 log <<
MSG::INFO <<
"Application Manager Initialized successfully" <<
endmsg;
509 log <<
MSG::INFO <<
"Application Manager Started successfully" <<
endmsg;
565 log <<
MSG::INFO <<
"Application Manager Stopped successfully" <<
endmsg;
614 log <<
MSG::INFO <<
"Application Manager Finalized successfully" <<
endmsg;
642 log <<
MSG::INFO <<
"Application Manager Terminated successfully" <<
endmsg;
644 log <<
MSG::INFO <<
"Application Manager Terminated successfully with a user requested ScheduledStop" <<
endmsg;
665 log <<
MSG::ERROR <<
"Could not get the IService interface of the MessageSvc" <<
endmsg;
667 svc->sysFinalize().ignore();
673 log <<
MSG::ERROR <<
"Could not get the IService interface of the JobOptionsSvc" <<
endmsg;
675 svc->sysFinalize().ignore();
768 if ( ignoreFailures ) {
790 log <<
MSG::FATAL <<
"Application execution failed. Ending the job." <<
endmsg;
870 throw GaudiException(
"Cannot reinitialize application if not INITIALIZED or RUNNING",
945 throw GaudiException(
"Failed to create ext services",
"MinimalEventLoopMgr::createSvcNameListHandler",
956 auto it = theNames.begin();
957 auto et = theNames.end();
958 while ( result.
isSuccess() && it != et ) {
960 if ( ( result =
svcManager()->addService( item, ServiceManager::DEFAULT_SVC_PRIORITY ) ).isFailure() ) {
962 log <<
MSG::ERROR <<
"decodeCreateSvcNameList: Cannot create service " << item.
type() <<
"/" << item.
name()
981 throw GaudiException(
"Failed to declare ext services",
"MinimalEventLoopMgr::extSvcNameListHandler",
995 auto it = theNames.begin();
996 auto et = theNames.end();
997 while ( result.
isSuccess() && it != et ) {
1000 if ( ( result =
svcManager()->addService( item, ServiceManager::DEFAULT_SVC_PRIORITY ) ).isFailure() ) {
1002 log <<
MSG::ERROR <<
"decodeExtSvcNameList: Cannot create service " << item.
type() <<
"/" << item.
name()
1006 if ( ( result =
svcManager()->declareSvcType( item.
name(), item.
type() ) ).isFailure() ) {
1008 log <<
MSG::ERROR <<
"decodeExtSvcNameList: Cannot declare service " << item.
type() <<
"/" << item.
name()
1035 for (
const auto& it : theNames ) {
1037 result =
addMultiSvc( item, ServiceManager::DEFAULT_SVC_PRIORITY );
1041 log <<
MSG::ERROR <<
"decodeMultiThreadSvcNameList: Cannot create service " << item.
type() <<
"/" << item.
name()
1047 log <<
MSG::VERBOSE <<
"decodeMultiThreadSvcNameList: created service " << item.
type() <<
"/" << item.
name()
1065 log <<
MSG::ERROR <<
"declareMultiSvcType: Cannot declare service " << type <<
"/" << name <<
endmsg;
1068 log <<
MSG::VERBOSE <<
"declareMultiSvcType: declared service " << type <<
"/" << name <<
endmsg;
1075 log <<
MSG::ERROR <<
"declareMultiSvcType: Cannot declare service " << type <<
"/" << thrName <<
endmsg;
1078 log <<
MSG::VERBOSE <<
"declareMultiSvcType: declared service " << type <<
"/" << thrName <<
endmsg;
1106 if ( result.isFailure() ) {
1107 log <<
MSG::ERROR <<
"addMultiSvc: Cannot add service " << type <<
"/" << thrName <<
endmsg;
1110 log <<
MSG::VERBOSE <<
"addMultiSvc: added service " << type <<
"/" << thrName <<
endmsg;
1142 if ( 0 == dllInList[it] ) {
1145 ++duplicateList[it];
1155 log <<
MSG::DEBUG <<
"Removed duplicate entries for modules : ";
1156 for (
auto it = duplicateList.
begin(); it != duplicateList.
end(); ++it ) {
1157 log << it->first <<
"(" << 1 + it->second <<
")";
1158 if ( it != --duplicateList.
end() ) log <<
", ";
1170 for (
const auto& it : theNames ) {
1184 if ( !successNames.
empty() ) {
1185 log <<
MSG::INFO <<
"Successfully loaded modules : ";
1186 for (
auto it = successNames.
begin(); it != successNames.
end(); it++ ) {
1188 if ( ( it + 1 ) != successNames.
end() ) log <<
", ";
1197 for (
auto it = failNames.
begin(); it != failNames.
end(); it++ ) {
1199 if ( ( it + 1 ) != failNames.
end() ) log <<
", ";
The ServiceManager class is in charge of the creation of concrete instances of Services.
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 initialize() override
constexpr int FinalizationFailure
Error codes for operation failures.
virtual StatusCode addService(IService *svc, int prio=DEFAULT_SVC_PRIORITY)=0
Add a service to the "active" list of services of the factory.
Definition of the MsgStream class used to transmit messages.
Gaudi::Property< bool > m_propertiesPrint
virtual StatusCode stopRun()=0
Schedule a stop of the current event processing.
virtual StatusCode run()=0
Run the class implementation.
Define general base for Gaudi exception.
StatusCode decodeDllNameList()
Gaudi::Property< int > m_returnCode
Property to record the error conditions occurring during the running.
GAUDI_API int setEnv(const std::string &name, const std::string &value, int overwrite=1)
Set an environment variables.
void SIExitHandler(Gaudi::Details::PropertyBase &theProp)
Gaudi::Property< bool > m_stopOnSignal
Property to enable/disable the "stop on signal" service.
StatusCode loadModule(const std::string &module, bool fireIncident=true) override
Gaudi::Property< bool > m_codeCheck
Gaudi::Property< int > m_evtMax
SmartIF< IRunable > m_runable
Reference to the runable object.
Gaudi::Details::PropertyBase * property(const std::string &name) const
Implementation of property with value of concrete type.
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
const std::vector< Gaudi::Details::PropertyBase * > & getProperties() const override
get all properties
virtual PropertyBase & declareUpdateHandler(std::function< void(PropertyBase &)> fun)=0
set new callback for update
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
void SIGoHandler(Gaudi::Details::PropertyBase &theProp)
Gaudi::Property< std::string > m_jobOptionsType
bool isSuccess() const
Test for a status code of SUCCESS.
const std::string & name() const override
void multiThreadSvcNameListHandler(Gaudi::Details::PropertyBase &theProp)
static Time current()
Returns the current time.
Gaudi::Property< std::map< std::string, std::string > > m_environment
Gaudi::Property< std::vector< std::string > > m_multiThreadSvcNameList
List of external services names for which we want a copy per evt thread.
virtual StatusCode executeEvent(void *par=0)=0
Process single event.
Gaudi::Property< std::string > m_appVersion
static GAUDI_API void enableChecking()
std::vector< std::string > m_okDlls
names of successfully loaded dlls
State
Allowed states for classes implementing the state machine (ApplicationMgr, Algorithm, Service, AlgTool).
StatusCode nextEvent(int maxevt) override
SmartIF< IJobOptionsSvc > m_jobOptionsSvc
Reference to JobOption service.
AlgTypeAliasesMap & typeAliases()
virtual StatusCode declareSvcType(const std::string &svcname, const std::string &svctype)=0
Declare the type of the service to be used when crating a given service name.
void createSvcNameListHandler(Gaudi::Details::PropertyBase &)
bool isFailure() const
Test for a status code of FAILURE.
SmartIF< IEventProcessor > m_processingMgr
Reference to processing manager object.
StatusCode terminate() override
SmartIF< ISvcManager > & svcManager()
virtual StatusCode start()=0
Start (from INITIALIZED to RUNNING).
constexpr int ScheduledStop
Gaudi::Property< std::string > m_eventLoopMgr
StatusCode addMultiSvc(const Gaudi::Utils::TypeNameString &typeName, int prio)
add one or more copies of svc type/name as determined by NoOfThreads
TYPE * get() const
Get interface pointer.
virtual StatusCode nextEvent(int maxevt)=0
Process the next maxevt events.
void evtLoopPropertyHandler(Gaudi::Details::PropertyBase &theProp)
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
GAUDIPS_API void SetDebug(int debugLevel)
Backward compatibility with Reflex.
virtual StatusCode setProperty(const Gaudi::Details::PropertyBase &p)=0
Set the property by property.
Gaudi::Property< int > m_outputLevel
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
Helper class to parse a string of format "type/name".
StatusCode executeRun(int evtmax) override
implementation of IEventProcessor::executeRun(int)
virtual StatusCode stop()=0
Stop (from RUNNING to INITIALIZED).
virtual StatusCode reinitialize()=0
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
Gaudi::StateMachine::State targetFSMState() const override
void extSvcNameListHandler(Gaudi::Details::PropertyBase &theProp)
void initLoopCheckHndlr(Gaudi::Details::PropertyBase &)
General service interface definition.
SmartIF< ISvcLocator > m_svcLocator
Reference to its own service locator (must be instantiated prior to any service!) ...
This class is used for returning status codes from appropriate routines.
virtual SmartIF< IService > & createService(const Gaudi::Utils::TypeNameString &nametype)=0
Creates and instance of a service type that has been declared beforehand and assigns it a name...
Gaudi::Details::PropertyBase * declareProperty(const std::string &name, TYPE &value, const std::string &doc="none")
Declare a property (templated)
Definition of the basic interface.
virtual StatusCode setMyProperties(const std::string &client, IProperty *me)=0
Override default properties of the calling client.
Gaudi::Property< std::vector< std::string > > m_extSvcNameList
#define DECLARE_OBJECT_FACTORY(x)
void dllNameListHandler(Gaudi::Details::PropertyBase &theProp)
Gaudi::Property< std::string > m_runableType
GAUDI_API std::string getGaudiThreadIDfromID(int iCopy)
helper function to extract Gaudi Thread ID from thread copy number
Gaudi::Property< bool > m_stalledEventMonitoring
Property to enable/disable the monitoring and reporting of stalled events.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
StatusCode GoToState(Gaudi::StateMachine::State state, bool ignoreFailures=false)
Reach a state from current state (whichever it is) going through the correct transitions.
StatusCode finalize() override
Gaudi::Property< std::vector< std::string > > m_svcOptMapping
virtual StatusCode initialize()=0
Initialization (from CONFIGURED to INITIALIZED).
Gaudi::Property< std::string > m_jobOptionsPreAction
Gaudi::Property< std::vector< std::string > > m_svcMapping
Gaudi::Property< std::vector< std::string > > m_dllNameList
GAUDI_API bool isEnvSet(const char *var)
Check if an environment variable is set or not.
StatusCode queryInterface(const InterfaceID &iid, void **pinterface) override
implementation of IInterface::queryInterface
StatusCode executeEvent(void *par) override
implementation of IEventProcessor::executeEvent(void*)
The Application Manager class.
Gaudi::Property< bool > m_actHistory
constexpr bool versionMatch(const InterfaceID &iid) const
check compatibility.
StatusCode queryInterface(const InterfaceID &iid, void **pinterface) override
StatusCode decodeExtSvcNameList()
GAUDI_API const std::string & hostName()
Host name.
Gaudi::Property< bool > m_extSvcCreates
SmartIF< DLLClassManager > m_classManager
Reference to the class manager.
Gaudi::Property< std::string > m_jobOptionsSvcType
StatusCode start() override
Gaudi::Property< std::vector< std::string > > m_createSvcNameList
StatusCode restart() override
StatusCode configure() override
void pluginDebugPropertyHandler(Gaudi::Details::PropertyBase &theProp)
virtual StatusCode restart()=0
Initialization (from RUNNING to RUNNING, via INITIALIZED).
StatusCode stopRun() override
implementation of IEventProcessor::stopRun()
const std::string & type() const
StatusCode decodeCreateSvcNameList()
virtual StatusCode finalize()=0
Finalize (from INITIALIZED to CONFIGURED).
Gaudi::Property< std::string > m_jobOptionsPostAction
StatusCode i_startup()
Internal startup routine.
StatusCode stop() override
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
static GAUDI_API void disableChecking()
Gaudi::Property< std::string > m_messageSvcType
StatusCode reinitialize() override
MSG::Level level() const
Retrieve output level.
Gaudi::StateMachine::State m_state
Internal State.
Gaudi::Property< std::string > m_appName
Gaudi::StateMachine::State FSMState() const override
const std::string & name() const
SmartIF< ISvcLocator > & serviceLocator() const override
Needed to locate the message service.
virtual void setLoopCheckEnabled(bool en=true)=0
Set the value of the initialization loop check flag.
virtual StatusCode executeRun(int maxevt)=0
Process the maxevt events as a Run (beginRun() and endRun() called)
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
StatusCode run() override
std::string typeName(const std::type_info &typ)
StatusCode queryInterface(const InterfaceID &iid, void **pinterface) override
StatusCode decodeMultiThreadSvcNameList()
The IProperty is the basic interface for all components which have properties that can be set or get...
SmartIF< IAlgManager > & algManager()
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
Gaudi::Property< int > m_noOfEvtThreads
SmartIF< IMessageSvc > m_messageSvc
Reference to the message service.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Gaudi::Property< int > m_pluginDebugLevel
Gaudi::Property< std::string > m_jobOptionsPath
virtual void setOutputLevel(int new_level)=0
Set new global output level threshold.
std::string format(bool local, std::string spec="%c") const
Format the time using strftime.
Gaudi::Property< bool > m_loopCheck
virtual StatusCode queryInterface(const InterfaceID &ti, void **pp)=0
Set the void** to the pointer to the requested interface of the instance.
StatusCode declareMultiSvcType(const std::string &name, const std::string &type)
declare one or more copies of svc type/name as determined by NoOfThreads