/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Private Member Functions | Private Attributes
JobInfoWriterAlg Class Reference

#include <JobInfoWriterAlg.h>

Collaboration diagram for JobInfoWriterAlg:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 JobInfoWriterAlg (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~JobInfoWriterAlg ()
virtual StatusCode initialize ()
virtual StatusCode execute ()
virtual StatusCode finalize ()
virtual StatusCode endRun ()
virtual void handle (const Incident &incident)

Private Member Functions

StatusCode writeDataToFile ()
StatusCode writeDataToDatabase ()

Private Attributes

bool m_writeToFile
bool m_writeToDatabase
std::string m_jobInfoLocation
IDybStorageSvcm_storageSvc
IJobInfoSvcm_jobInfoSvc
IIncidentSvc * m_incsvc

Detailed Description

Definition at line 22 of file JobInfoWriterAlg.h.


Constructor & Destructor Documentation

JobInfoWriterAlg::JobInfoWriterAlg ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 12 of file JobInfoWriterAlg.cc.

  : GaudiAlgorithm(name,pSvcLocator),
    m_storageSvc(0),
    m_jobInfoSvc(0)
{
  declareProperty("JobInfoLocation",
                  m_jobInfoLocation=DayaBay::JobHeaderLocation::Default,
                  "Location in file where job info is to be found.");
  declareProperty("WriteToFile",m_writeToFile=false,
                  "Write the job info to the current output file?");
  declareProperty("WriteToDatabase",m_writeToDatabase=false,
                  "Write the job info to the offline database?");
}
JobInfoWriterAlg::~JobInfoWriterAlg ( ) [virtual]

Definition at line 27 of file JobInfoWriterAlg.cc.

{
}

Member Function Documentation

StatusCode JobInfoWriterAlg::initialize ( ) [virtual]

Definition at line 31 of file JobInfoWriterAlg.cc.

{
  // Initialize the necessary services
  if( m_writeToFile ){
    StatusCode sc = this->service("DybStorageSvc",m_storageSvc,true);
    if(sc.isFailure()){
      error() << "Failed to get DybStorageSvc" << endreq;
      return sc;
    }
  }
  StatusCode sc = this->service("JobInfoSvc",m_jobInfoSvc,true);
  if(sc.isFailure()){
    error() << "Failed to get JobInfoSvc" << endreq;
    return sc;
  }

  // Get and hold on to the incident service and add ourself.
  sc = this->service("IncidentSvc",m_incsvc,true);
  if (sc.isFailure()) {
      error() << "Failed to get IncidentSvc" << endreq;
      return sc;
  }
  m_incsvc->addListener(this,"RootIOIncident");

  return StatusCode::SUCCESS;
}
StatusCode JobInfoWriterAlg::execute ( ) [virtual]

Definition at line 58 of file JobInfoWriterAlg.cc.

{
  return StatusCode::SUCCESS;
}
StatusCode JobInfoWriterAlg::finalize ( ) [virtual]

Definition at line 63 of file JobInfoWriterAlg.cc.

{
  m_jobInfoSvc->release();

  // Must remove self.  O.w. we may finalize before RootIOSvc and
  // leave beind a dangling handler.
  m_incsvc->removeListener(this,"RootIOIncident");
  m_incsvc->release();

  return StatusCode::SUCCESS;
}
StatusCode JobInfoWriterAlg::endRun ( ) [virtual]

Definition at line 76 of file JobInfoWriterAlg.cc.

{
  // Write the job info to file/database at the end of the run
  StatusCode sc = StatusCode::SUCCESS;
  if( m_writeToFile ) sc = this->writeDataToFile();
  if( !sc.isSuccess() ) return sc;
  if( m_writeToDatabase ) sc = this->writeDataToDatabase();
  return sc;
}
void JobInfoWriterAlg::handle ( const Incident &  incident) [virtual]

Definition at line 125 of file JobInfoWriterAlg.cc.

{
    if (!m_writeToFile) return;

    // Handle the incident in a trivial manner

    const RootIOIncident* rioinc = dynamic_cast<const RootIOIncident*>(&incident);
    if (!rioinc) {
        warning() 
            << "Ignoring unexpected incident not of class RootIOIncident" 
            << endreq;
        return;
    }
    
    if (rioinc->state() != RootIOIncident::opened_output) {
        return;
    }

    StatusCode sc = this->writeDataToFile();
    if (sc.isFailure()) {
        error()
            << "Failed to write JobInfo to output file "
            << "while handling opened output incidence"
            << endreq;
    }
    debug() << "Handled closing_output for " << rioinc->filename() << endreq;
}
StatusCode JobInfoWriterAlg::writeDataToFile ( ) [private]

Definition at line 86 of file JobInfoWriterAlg.cc.

                                            {
  // Write job info to current output file

  debug() << "Writing JobInfo" << endreq;

  std::vector<DayaBay::JobInfo*> jobInfo = m_jobInfoSvc->cachedJobInfo();

  // Create Job Header
  DayaBay::JobHeader jobHeader;
  jobHeader.setJobInfoList( jobInfo );

  // Have to put JobHeader in a registry for DybStorageSvc to work correctly
  DataSvcHelpers::RegistryEntry* regEntry 
    = new DataSvcHelpers::RegistryEntry(m_jobInfoLocation);
  regEntry->setObject(&jobHeader);

  debug() << "Storing JobHeader with "
          << jobInfo.size() << " entries at " 
          << m_jobInfoLocation << endreq;
  StatusCode sc = m_storageSvc->store(&jobHeader, m_jobInfoLocation);
  debug() << "Stored JobHeader" << endreq;
  if(sc.isFailure()){
    error() << "Failed to store Job Header to output file" << endreq;
  }

  // Clear job info to prevent deleting
  jobInfo.clear();
  jobHeader.setJobInfoList( jobInfo );

  return sc;
}
StatusCode JobInfoWriterAlg::writeDataToDatabase ( ) [private]

Definition at line 118 of file JobInfoWriterAlg.cc.

                                                {
  // Write Job Info to offline database
  warning() << "Writing job info to offline database is not yet implemented."
            << endreq;
  return StatusCode::SUCCESS;
}

Member Data Documentation

Definition at line 45 of file JobInfoWriterAlg.h.

Definition at line 48 of file JobInfoWriterAlg.h.

std::string JobInfoWriterAlg::m_jobInfoLocation [private]

Definition at line 51 of file JobInfoWriterAlg.h.

Definition at line 54 of file JobInfoWriterAlg.h.

Definition at line 56 of file JobInfoWriterAlg.h.

IIncidentSvc* JobInfoWriterAlg::m_incsvc [private]

Definition at line 58 of file JobInfoWriterAlg.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:59:35 for JobInfoSvc by doxygen 1.7.4