// ============================================================================ // finalization of the service // ============================================================================ StatusCode DataOnDemandSvc::finalize() { // stream () << MSG::INFO << "Handled \"" << m_trapType << "\" incidents: " << m_statAlg << "/" << m_statNode << "/" << m_stat << "(Alg/Node/Total)." << endmsg ; if ( m_dump || MSG::DEBUG >= outputLevel() ) { stream () << MSG::INFO << m_total.outputUserTime ( "Algorithm timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec ) << m_total.outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ; stream () << MSG::INFO << m_timer_nodes.outputUserTime ( "Nodes timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec ) << m_timer_nodes.outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ; stream () << MSG::INFO << m_timer_algs .outputUserTime ( "Algs timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec ) << m_timer_algs .outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ; stream () << MSG::INFO << m_timer_all .outputUserTime ( "All timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec ) << m_timer_all .outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ; } // dump it! if ( m_dump ) { dump ( MSG::INFO , false ) ; } else if ( MSG::DEBUG >= outputLevel() ) { dump ( MSG::DEBUG , false ) ; } // if ( m_incSvc ) { m_incSvc->removeListener(this, m_trapType); m_incSvc.reset(); } m_algMgr.reset(); m_dataSvc.reset(); if (m_toolSvc) { // we may not have retrieved the ToolSvc // Do not call releaseTool if the ToolSvc was already finalized. if (SmartIF<IStateful>(m_toolSvc)->FSMState() > Gaudi::StateMachine::CONFIGURED) { for(std::list<IDODNodeMapper*>::iterator i = m_nodeMappers.begin(); i != m_nodeMappers.end(); ++i) m_toolSvc->releaseTool(*i).ignore(); for(std::list<IDODAlgMapper*>::iterator i = m_algMappers.begin(); i != m_algMappers.end(); ++i) m_toolSvc->releaseTool(*i).ignore(); } else { warning() << "ToolSvc already finalized: cannot release tools. Check options." << endmsg; } m_nodeMappers.clear(); m_algMappers.clear(); m_toolSvc.reset(); } return Service::finalize(); }
// ============================================================================ /// re-initialization of the service // ============================================================================ StatusCode DataOnDemandSvc::reinitialize() { // reinitialize the Service Base class if ( 0 != m_incSvc ) { m_incSvc -> removeListener ( this , m_trapType ); m_incSvc.reset(); } m_algMgr.reset(); m_dataSvc.reset(); for(std::list<IDODNodeMapper*>::iterator i = m_nodeMappers.begin(); i != m_nodeMappers.end(); ++i) m_toolSvc->releaseTool(*i).ignore(); m_nodeMappers.clear(); for(std::list<IDODAlgMapper*>::iterator i = m_algMappers.begin(); i != m_algMappers.end(); ++i) m_toolSvc->releaseTool(*i).ignore(); m_algMappers.clear(); m_toolSvc.reset(); if ( 0 != m_log ) { delete m_log ; m_log = 0 ; } // StatusCode sc = Service::reinitialize(); if ( sc.isFailure() ) { return sc; } // sc = setup() ; if ( sc.isFailure() ) { return sc; } // if ( m_dump ) { dump ( MSG::INFO ) ; } else if ( MSG::DEBUG >= outputLevel() ) { dump ( MSG::DEBUG ) ; } // return StatusCode::SUCCESS ; }
//============================================================================= // Inherited Service overrides: //============================================================================= StatusCode DataOnDemandSvc::initialize() { // initialize the Service Base class StatusCode sc = Service::initialize(); if ( sc.isFailure() ) { return sc; } sc = setup(); if ( sc.isFailure() ) { return sc; } // if ( m_dump ) { dump ( MSG::INFO ) ; } else if ( MSG::DEBUG >= outputLevel() ) { dump ( MSG::DEBUG ) ; } // if ( m_init ) { return update () ; } // return StatusCode::SUCCESS ; }
/// todo: implement the scanning as an IDataStoreAgent void DataSvcFileEntriesTool::i_collectLeaves(IRegistry* reg) { MsgStream log(msgSvc(), name()); // I do not put sanity checks on the pointers because I know how I'm calling the function IOpaqueAddress *addr = reg->address(); if (addr) { // we consider only objects that are in a file if (outputLevel() <= MSG::VERBOSE) log << MSG::VERBOSE << "::i_collectLeaves added " << reg->identifier() << endmsg; m_leaves.push_back(reg->object()); // add this object // Origin of the current object const std::string& base = addr->par()[0]; // Compare with the origin seen during BeginEvent if ( !m_ignoreOriginChange && (m_initialBase != base) ) throw GaudiException("Origin of data has changed ('" + m_initialBase + "' != '" + base + "'), probably OutputStream was called before " "InputCopyStream: check options", name(), StatusCode::FAILURE); std::vector<IRegistry*> lfs; // leaves of the current object StatusCode sc = m_dataMgrSvc->objectLeaves(reg, lfs); if (sc.isSuccess()) { for(std::vector<IRegistry*>::iterator i = lfs.begin(); i != lfs.end(); ++i) { // Continue if the leaf has the same database as the parent if ( (*i)->address() && (*i)->address()->par()[0] == base ) { DataObject* obj = 0; sc = m_dataSvc->retrieveObject(reg, (*i)->name(), obj); if (sc.isSuccess()) { i_collectLeaves(*i); } else { throw GaudiException("Cannot get " + (*i)->identifier() + " from " + m_dataSvcName, name(), StatusCode::FAILURE); } } } } } }
// =========================================================================== // IIncidentListener interfaces overrides: incident handling // =========================================================================== void DataOnDemandSvc::handle ( const Incident& incident ) { Gaudi::Utils::LockedChrono timer ( m_timer_all , m_locked_all ) ; ++m_stat ; // proper incident type? if ( incident.type() != m_trapType ) { return ; } // RETURN const DataIncident* inc = dynamic_cast<const DataIncident*>(&incident); if ( 0 == inc ) { return ; } // RETURN // update if needed! if ( m_updateRequired ) { update() ; } if ( MSG::VERBOSE >= outputLevel() ) { verbose() << "Incident: [" << incident.type () << "] " << " = " << incident.source () << " Location:" << inc->tag() << endmsg; } // ========================================================================== // const std::string& tag = inc->tag(); Gaudi::StringKey tag ( inc->tag() ) ; // ========================================================================== NodeMap::iterator icl = m_nodes.find ( tag ) ; if ( icl != m_nodes.end() ) { StatusCode sc = execHandler ( tag , icl->second ) ; if ( sc.isSuccess() ) { ++m_statNode ; } return ; // RETURN } // ========================================================================== AlgMap::iterator ialg = m_algs.find ( tag ) ; if ( ialg != m_algs.end() ) { StatusCode sc = execHandler ( tag , ialg->second ) ; if ( sc.isSuccess() ) { ++m_statAlg ; } return ; // RETURN } // ========================================================================== // Fall back on the tools if (m_toolSvc) { if (MSG::VERBOSE >= outputLevel()) verbose() << "Try to find mapping with mapping tools" << endmsg; Finder finder(no_prefix(inc->tag(), m_prefix), m_nodeMappers, m_algMappers); // - try the node mappers std::string node = finder.node(); if (isGood(node)) { // if one is found update the internal node mapping and try again. if (MSG::VERBOSE >= outputLevel()) verbose() << "Found Node handler: " << node << endmsg; i_setNodeHandler(inc->tag(), node); handle(incident); --m_stat; // avoid double counting because of recursion return; } // - try alg mappings Gaudi::Utils::TypeNameString alg = finder.alg(); if (isGood(alg)) { // we got an algorithm, update alg map and try to handle again if (MSG::VERBOSE >= outputLevel()) verbose() << "Found Algorithm handler: " << alg << endmsg; i_setAlgHandler(inc->tag(), alg).ignore(); handle(incident); --m_stat; // avoid double counting because of recursion return; } } }