Ejemplo n.º 1
0
void 
IoComponentMgr::handle ( const Incident& i ) {

  pair<iodITR,iodITR> pit;
  

  if ( i.type() == IncidentType::BeginInputFile ) {

    const FileIncident *fi = dynamic_cast<const FileIncident*> ( &i );
    DEBMSG << "BeginInputFile:   s: " << fi->source() << "  t: " << fi->type()
	   << "  n: " << fi->fileName() << "  g: " << fi->fileGuid()
	   << endmsg;

    if (findComp(fi->source(),pit)) {
      DEBMSG << "  found component: " << endmsg;
      while (pit.first != pit.second) {
	IIoComponent* c = pit.first->first;
	IoComponentEntry e = pit.first->second;
	DEBMSG << "    c: " << c->name() << "  " << e << endmsg;
	
	++pit.first;
      }
    } else {
      DEBMSG << "  could not find component \"" << fi->source() 
	     << "\"!" << endmsg;
    }
	  


  } else if ( i.type() == IncidentType::BeginOutputFile ) {

    const FileIncident *fi = dynamic_cast<const FileIncident*> ( &i );
    DEBMSG << "BeginOutputFile:   s: " << fi->source() << "  t: " << fi->type()
	   << "  n: " << fi->fileName() << "  g: " << fi->fileGuid()
	   << endmsg;

    if (findComp(fi->source(),pit)) {
      DEBMSG << "  found component: " << endmsg;
      while (pit.first != pit.second) {
	IIoComponent* c = pit.first->first;
	IoComponentEntry e = pit.first->second;
	DEBMSG << "    c: " << c->name() << "  " << e << endmsg;
	
	++pit.first;
      }
    } else {
      DEBMSG << "  could not find component \"" << fi->source() 
	     << "\"!" << endmsg;
    }

  }

}
Ejemplo n.º 2
0
// ============================================================================
void IncidentSvc::fireIncident( const Incident& incident )
{

  Gaudi::Utils::LockedChrono timer ( m_timer , m_timerLock ) ;

  // Call specific listeners
  i_fireIncident(incident, incident.type());
  // Try listeners registered for ALL incidents
  if ( incident.type() != "ALL" ){ // avoid double calls if somebody fires the incident "ALL"
    i_fireIncident(incident, "ALL");
  }

}
Ejemplo n.º 3
0
// ============================================================================
void TimingAuditor::handle ( const Incident& i )
{
  if      ( IncidentType::BeginEvent == i.type () )
  {
    m_timer -> start ( m_map[ m_appMgr ] ) ;
    ++m_indent ;
    m_inEvent = true ;
  }
  else if ( IncidentType::EndEvent   == i.type () )
  {
    m_timer -> stop  ( m_map[ m_appMgr ] ) ;
    --m_indent ;
    m_inEvent = false ;
  }
}
Ejemplo n.º 4
0
void DataSvcFileEntriesTool::handle(const Incident& incident) {
  // Get the file id of the root node at every event
  IOpaqueAddress *addr = i_getRootNode()->address();
  if (addr)
    m_initialBase = addr->par()[0];
  else
    m_initialBase.clear(); // use empty file id if there is no address

  m_leaves.clear();
  if (m_scanOnBeginEvent) {
    MsgStream log(msgSvc(), name());
    log << MSG::VERBOSE << "::handle scanning on " << incident.type() << endmsg;
    i_collectLeaves();
  }
}
Ejemplo n.º 5
0
// ============================================================================
void IncidentSvc::i_fireIncident
( const Incident&    incident     ,
  const std::string& listenerType )
{

  boost::recursive_mutex::scoped_lock lock(m_listenerMapMutex);

  // Special case: FailInputFile incident must set the application return code
  if (incident.type() == IncidentType::FailInputFile
      || incident.type() == IncidentType::CorruptedInputFile) {
    SmartIF<IProperty> appmgr(serviceLocator());
    if (incident.type() == IncidentType::FailInputFile)
      // Set the return code to Gaudi::ReturnCode::FailInput (2)
      Gaudi::setAppReturnCode(appmgr, Gaudi::ReturnCode::FailInput).ignore();
    else
      Gaudi::setAppReturnCode(appmgr, Gaudi::ReturnCode::CorruptedInput).ignore();
  }

  ListenerMap::iterator itmap = m_listenerMap.find( listenerType );
  if ( m_listenerMap.end() == itmap ) return;

  // setting this pointer will avoid that a call to removeListener() during
  // the loop triggers a segfault
  m_currentIncidentType = &(incident.type());

  ListenerList* llist = (*itmap).second;
  ListenerList::iterator itlist;
  bool weHaveToCleanUp = false;
  // loop over all registered Listeners

    for( itlist = llist->begin(); itlist != llist->end(); itlist++ )
  {

    VERMSG << "Calling '" << getListenerName((*itlist).iListener)
           << "' for incident [" << incident.type() << "]" << endmsg;

    // handle exceptions if they occur
    try {
      (*itlist).iListener->handle(incident);
    }
    catch( const GaudiException& exc ) {
      error() << "Exception with tag=" << exc.tag() << " is caught"
                 " handling incident" << m_currentIncidentType << endmsg;
      error() <<  exc  << endmsg;
      if ( (*itlist).rethrow ) { throw (exc); }
    }
    catch( const std::exception& exc ) {
     error() << "Standard std::exception is caught"
          " handling incident" << m_currentIncidentType << endmsg;
      error() << exc.what()  << endmsg;
      if ( (*itlist).rethrow ) { throw (exc); }
    }
    catch(...) {
      error() << "UNKNOWN Exception is caught"
          " handling incident" << m_currentIncidentType << endmsg;
      if ( (*itlist).rethrow ) { throw; }
    }
    // check if at least one of the listeners is a one-shot
    weHaveToCleanUp |= itlist->singleShot;
  }
  if (weHaveToCleanUp) {
    // remove all the listeners that need to be removed from the list
    llist->remove_if( listenerToBeRemoved() );
    // if the list is empty, we can remove it
    if( llist->size() == 0) {
      delete llist;
      m_listenerMap.erase(itmap);
    }
  }

  m_currentIncidentType = 0;
}
Ejemplo n.º 6
0
//=========================================================================
//  Incident handler
//=========================================================================
void PatPixelHitManager::handle ( const Incident& incident ) {
  if ( IncidentType::BeginEvent == incident.type() ){
    this->clearHits();
    m_eventReady = false;
  }
}
Ejemplo n.º 7
0
// ===========================================================================
// 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;
    }
  }
}