#include <JobInfoSvc.h>
Inheritance diagram for JobInfoSvc:
Public Types | |
SUCCESS | |
NO_INTERFACE | |
VERSMISMATCH | |
LAST_ERROR | |
enum | Status |
SUCCESS | |
NO_INTERFACE | |
VERSMISMATCH | |
LAST_ERROR | |
Public Member Functions | |
JobInfoSvc (const std::string &name, ISvcLocator *svc) | |
Standard Service Constructor. | |
virtual StatusCode | initialize () |
virtual StatusCode | finalize () |
virtual const DayaBay::JobInfo * | currentJobInfo () |
Get the information for the current running job. | |
virtual const DayaBay::JobInfo * | jobInfo (const DayaBay::JobId &jobId) |
Get the information for the job with the given jobId. | |
virtual StatusCode | setJobInfo (const DayaBay::JobInfo &jobInfo) |
Add/update job information. | |
virtual const std::vector< DayaBay::JobInfo * > & | cachedJobInfo () |
Return cached list of job info. | |
virtual StatusCode | queryInterface (const InterfaceID &id, void **interface) |
Methods required by ServiceManager. | |
virtual unsigned long | addRef () |
virtual unsigned long | release () |
virtual const std::string & | name () const |
virtual const InterfaceID & | type () const |
virtual StatusCode | configure () |
virtual StatusCode | start () |
virtual StatusCode | stop () |
virtual StatusCode | terminate () |
virtual Gaudi::StateMachine::State | FSMState () const |
virtual Gaudi::StateMachine::State | targetFSMState () const |
virtual StatusCode | reinitialize () |
virtual StatusCode | restart () |
virtual StatusCode | sysInitialize () |
virtual StatusCode | sysStart () |
virtual StatusCode | sysStop () |
virtual StatusCode | sysFinalize () |
virtual StatusCode | sysReinitialize () |
virtual StatusCode | sysRestart () |
virtual StatusCode | setProperty (const Property &p) |
virtual StatusCode | setProperty (const std::string &s) |
virtual StatusCode | setProperty (const std::string &n, const std::string &v) |
StatusCode | setProperty (const std::string &name, const TYPE &value) |
virtual StatusCode | getProperty (Property *p) const |
virtual const Property & | getProperty (const std::string &name) const |
virtual StatusCode | getProperty (const std::string &n, std::string &v) const |
virtual const std::vector< Property * > & | getProperties () const |
ISvcLocator * | serviceLocator () const |
IMessageSvc * | msgSvc () |
IMessageSvc * | msgSvc () const |
IMessageSvc * | messageService () |
IMessageSvc * | messageService () const |
StatusCode | setProperties () |
StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const |
StatusCode | service (const std::string &svcType, const std::string &svcName, T *&psvc) const |
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const |
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const |
IAuditorSvc * | auditorSvc () const |
virtual unsigned long | addRef ()=0 |
virtual unsigned long | release ()=0 |
Static Public Member Functions | |
static const InterfaceID & | interfaceID () |
static const InterfaceID & | interfaceID () |
static const InterfaceID & | interfaceID () |
static const InterfaceID & | interfaceID () |
Public Attributes | |
SUCCESS | |
NO_INTERFACE | |
VERSMISMATCH | |
LAST_ERROR | |
Protected Member Functions | |
int | outputLevel () const |
Protected Attributes | |
IntegerProperty | m_outputLevel |
Gaudi::StateMachine::State | m_state |
Gaudi::StateMachine::State | m_targetState |
IMessageSvc * | m_messageSvc |
Private Member Functions | |
StatusCode | readDataFromDatabase (const DayaBay::JobId &jobId) |
StatusCode | readDataFromFile () |
Private Attributes | |
bool | m_readFromFile |
bool | m_readFromDatabase |
std::string | m_jobInfoLocation |
std::vector< DayaBay::JobInfo * > | m_jobInfoList |
DayaBay::JobInfo * | m_currentJobInfo |
bool | m_fileIsInitialized |
std::string | m_jobIdString |
DayaBay::JobId | m_jobId |
std::map< std::string, std::string > | m_jobConfig |
Friends | |
friend class | ServiceManager |
Definition at line 12 of file JobInfoSvc.h.
JobInfoSvc::JobInfoSvc | ( | const std::string & | name, | |
ISvcLocator * | svc | |||
) |
Standard Service Constructor.
Definition at line 13 of file JobInfoSvc.cc.
00014 : 00015 Service(name, 00016 svc), 00017 m_currentJobInfo(0), 00018 m_fileIsInitialized(false) 00019 { 00020 declareProperty("ReadFromFile",m_readFromFile=false, 00021 "Load the job info from the current input file?"); 00022 declareProperty("ReadFromDatabase",m_readFromDatabase=true, 00023 "Check the database for job info?"); 00024 declareProperty("JobInfoLocation", 00025 m_jobInfoLocation = DayaBay::JobHeaderLocation::Default, 00026 "Path for job info if reading from file"); 00027 declareProperty("JobId",m_jobIdString, 00028 "Used by nuwa.py to initialize current job ID"); 00029 declareProperty("JobConfig",m_jobConfig, 00030 "Use to initialize current job configuration"); 00031 }
StatusCode JobInfoSvc::initialize | ( | ) | [virtual] |
Reimplemented from Service.
Definition at line 48 of file JobInfoSvc.cc.
00048 { 00049 StatusCode status = Service::initialize(); 00050 if (status.isFailure()) { 00051 throw GaudiException("Could not initialize super class", 00052 name(), 00053 status); 00054 } 00055 m_jobId.set(m_jobIdString); 00056 return StatusCode::SUCCESS; 00057 }
StatusCode JobInfoSvc::finalize | ( | ) | [virtual] |
Reimplemented from Service.
Definition at line 59 of file JobInfoSvc.cc.
00059 { 00060 // Clear job info list 00061 std::vector<DayaBay::JobInfo*>::iterator it, done = m_jobInfoList.end(); 00062 for (it = m_jobInfoList.begin(); it != done; ++it) { 00063 // boost::pool somehow owns the job info objects, so don't delete 00064 //delete *it; 00065 } 00066 m_jobInfoList.clear(); 00067 return Service::finalize(); 00068 }
const DayaBay::JobInfo * JobInfoSvc::currentJobInfo | ( | ) | [virtual] |
Get the information for the current running job.
Implements IJobInfoSvc.
Definition at line 70 of file JobInfoSvc.cc.
00070 { 00071 // Get the information for the current job 00072 MsgStream log(msgSvc(), "JobInfoSvc"); 00073 if(!m_currentJobInfo){ 00074 // Construct current job information 00075 m_currentJobInfo = new DayaBay::JobInfo(); 00076 m_currentJobInfo->setJobId(m_jobId); 00077 m_currentJobInfo->setParameters(m_jobConfig); 00078 m_jobInfoList.push_back(m_currentJobInfo); 00079 } 00080 return m_currentJobInfo; 00081 }
const DayaBay::JobInfo * JobInfoSvc::jobInfo | ( | const DayaBay::JobId & | jobId | ) | [virtual] |
Get the information for the job with the given jobId.
Implements IJobInfoSvc.
Definition at line 83 of file JobInfoSvc.cc.
00083 { 00084 // Return the job info given the job ID 00085 00086 MsgStream log(msgSvc(), "JobInfoSvc"); 00087 StatusCode sc = StatusCode::SUCCESS; 00088 // Check if file info should be loaded from file 00089 if( m_readFromFile && !m_fileIsInitialized){ 00090 sc = this->readDataFromFile(); 00091 if(!sc.isSuccess()) return 0; 00092 } 00093 00094 // Check current cache for this job ID 00095 DayaBay::JobInfo* jobInfo = 0; 00096 std::vector<DayaBay::JobInfo*>::iterator jobIter, 00097 jobDone = m_jobInfoList.end(); 00098 for(jobIter = m_jobInfoList.begin(); jobIter != jobDone; ++jobIter) { 00099 DayaBay::JobInfo* checkJob = *jobIter; 00100 log << MSG::DEBUG << "Checking job info with ID " 00101 << checkJob->jobId().uuid() << endreq; 00102 if(checkJob->jobId()==jobId){ 00103 // Fond the job 00104 jobInfo = checkJob; 00105 break; 00106 } 00107 } 00108 00109 // Not in cache? Check database 00110 if(!jobInfo && m_readFromDatabase ){ 00111 sc = this->readDataFromDatabase(jobId); 00112 if(!sc.isSuccess()) return 0; 00113 } 00114 00115 return jobInfo; 00116 }
StatusCode JobInfoSvc::setJobInfo | ( | const DayaBay::JobInfo & | jobInfo | ) | [virtual] |
Add/update job information.
Implements IJobInfoSvc.
Definition at line 118 of file JobInfoSvc.cc.
00118 { 00119 // Add or update the job info for the given job 00120 bool updateJob = false; 00121 std::vector<DayaBay::JobInfo*>::iterator jobIter, 00122 jobDone = m_jobInfoList.end(); 00123 for(jobIter = m_jobInfoList.begin(); jobIter != jobDone; ++jobIter) { 00124 if( (*jobIter)->jobId() == jobInfo.jobId() ){ 00125 // Found job in current list; update 00126 *(*jobIter) = jobInfo; 00127 updateJob = true; 00128 break; 00129 } 00130 } 00131 // Catch new job 00132 if( !updateJob ) m_jobInfoList.push_back(new DayaBay::JobInfo(jobInfo)); 00133 return StatusCode::SUCCESS; 00134 }
const std::vector< DayaBay::JobInfo * > & JobInfoSvc::cachedJobInfo | ( | ) | [virtual] |
Return cached list of job info.
Implements IJobInfoSvc.
Definition at line 136 of file JobInfoSvc.cc.
00136 { 00137 // Return the current internal list of job info. 00138 // Use this for Database / File storage of job info 00139 00140 // Ensure current job info is initialized 00141 if(!m_currentJobInfo){ 00142 this->currentJobInfo(); 00143 } 00144 // Ensure input job info is initialized, if needed 00145 if(m_readFromFile && !m_fileIsInitialized){ 00146 StatusCode sc = this->readDataFromFile(); 00147 sc.ignore(); 00148 } 00149 return m_jobInfoList; 00150 }
StatusCode JobInfoSvc::queryInterface | ( | const InterfaceID & | id, | |
void ** | interface | |||
) | [virtual] |
Methods required by ServiceManager.
Reimplemented from Service.
Definition at line 33 of file JobInfoSvc.cc.
00034 { 00035 if (IJobInfoSvc::interfaceID().versionMatch(id)) { 00036 // If good enough match return this object. 00037 *interface = (IJobInfoSvc*)this; 00038 addRef(); 00039 } else { 00040 // Interface is not directly available: try out a base class. 00041 return Service::queryInterface(id, 00042 interface); 00043 } 00044 00045 return StatusCode::SUCCESS; 00046 }
StatusCode JobInfoSvc::readDataFromDatabase | ( | const DayaBay::JobId & | jobId | ) | [private] |
Definition at line 152 of file JobInfoSvc.cc.
00152 { 00153 // Read the job info from the Database 00154 // FIXME: ADD database code here 00155 MsgStream log(msgSvc(), "JobInfoSvc"); 00156 log << MSG::WARNING << "readDataFromDatabase: Loading data from database is not yet implemented." << endreq; 00157 return StatusCode::SUCCESS; 00158 }
StatusCode JobInfoSvc::readDataFromFile | ( | ) | [private] |
Definition at line 160 of file JobInfoSvc.cc.
00160 { 00161 // Read job info from current input file 00162 00163 // If file already read, don't read again 00164 if( m_fileIsInitialized ) return StatusCode::SUCCESS; 00165 00166 MsgStream log(msgSvc(), "JobInfoSvc"); 00167 IService* isvc = 0; 00168 StatusCode sc = this->service("RootIOCnvSvc",isvc,true); 00169 if(sc.isFailure()){ 00170 log << MSG::ERROR << "Failed to get RootIOCnvSvc as IService" << endreq; 00171 return sc; 00172 } 00173 IRootIOSvc* m_rioSvc = 0; 00174 sc = isvc->queryInterface(IRootIOSvc::interfaceID(), (void**)&m_rioSvc); 00175 if (sc.isFailure()) { 00176 log << MSG::ERROR << "Conversion service RootIOCnvSvc" 00177 << " does not implement IRootIOCnvSvc" << endreq; 00178 return sc; 00179 } 00180 IConversionSvc* convSvc = 0; 00181 sc = isvc->queryInterface(IConversionSvc::interfaceID(), (void**)&convSvc); 00182 if (sc.isFailure()) { 00183 log << MSG::ERROR << "Conversion service RootIOCnvSvc" 00184 << " does not implement IConversionSvc" << endreq; 00185 return sc; 00186 } 00187 IRootIOSvc::InputStreamMap& ism = m_rioSvc->inputStreams(); 00188 IRootIOSvc::InputStreamMap::iterator it, done = ism.end(); 00189 for (it = ism.begin(); it != done; ++it) { 00190 log << MSG::DEBUG << "checking input stream: " << it->first << endreq; 00191 if( it->first == m_jobInfoLocation ){ 00192 // Get Persistent JobHeader from file 00193 RootInputStream* ris = it->second; 00194 ris->setEntry(0); 00195 log << MSG::DEBUG << "Return status of read: " << ris->read() << "\t" 00196 << ris->obj() << endreq; 00197 PerJobHeader* perJobHeader = (PerJobHeader*)(ris->obj()); 00198 if(!perJobHeader){ 00199 log << MSG::ERROR << "Failed to get persistent JobHeader" << endreq; 00200 return StatusCode::FAILURE; 00201 } 00202 log << MSG::DEBUG << "Got persistent job info for " 00203 << perJobHeader->jobInfoList.size() << " jobs" << endreq; 00204 // Convert Persistent JobHeader to Transient 00205 //DayaBay::JobHeader jobHeader; 00206 DayaBay::JobHeader* jobHeader = new DayaBay::JobHeader(); 00207 IConverter* converter = convSvc->converter(jobHeader->classID()); 00208 if (!converter) { 00209 log << MSG::ERROR << "Failed to get JobHeader converter" << endreq; 00210 return StatusCode::FAILURE; 00211 } 00212 RootIOTypedCnv<PerJobHeader, DayaBay::JobHeader>* jobHdrCnv = 0; 00213 jobHdrCnv = dynamic_cast< RootIOTypedCnv<PerJobHeader, DayaBay::JobHeader>* >(converter); 00214 if (!jobHdrCnv) { 00215 log << MSG::ERROR << "Failed to cast JobHeader converter" << endreq; 00216 return StatusCode::FAILURE; 00217 } 00218 sc = jobHdrCnv->PerToTran(*perJobHeader, *jobHeader); 00219 if (sc.isFailure()) { 00220 log << MSG::ERROR << "Failed to translate persistent JobHeader" 00221 << endreq; 00222 return sc; 00223 } 00224 const DayaBay::JobHeader::JobInfoContainer& jobInfoList 00225 = jobHeader->jobInfoList(); 00226 int nJobs = jobInfoList.size(); 00227 log << MSG::DEBUG << "Got job info for " << nJobs << " jobs" << endreq; 00228 for(int jobIdx=0; jobIdx < nJobs; jobIdx++){ 00229 // Add each job info to the current list 00230 m_jobInfoList.push_back(new DayaBay::JobInfo(*(jobInfoList[jobIdx]))); 00231 } 00232 } 00233 } 00234 m_fileIsInitialized = true; 00235 return StatusCode::SUCCESS; 00236 }
bool JobInfoSvc::m_readFromFile [private] |
Definition at line 43 of file JobInfoSvc.h.
bool JobInfoSvc::m_readFromDatabase [private] |
Definition at line 46 of file JobInfoSvc.h.
std::string JobInfoSvc::m_jobInfoLocation [private] |
Definition at line 49 of file JobInfoSvc.h.
std::vector<DayaBay::JobInfo*> JobInfoSvc::m_jobInfoList [private] |
Definition at line 52 of file JobInfoSvc.h.
DayaBay::JobInfo* JobInfoSvc::m_currentJobInfo [private] |
Definition at line 55 of file JobInfoSvc.h.
bool JobInfoSvc::m_fileIsInitialized [private] |
Definition at line 58 of file JobInfoSvc.h.
std::string JobInfoSvc::m_jobIdString [private] |
Definition at line 62 of file JobInfoSvc.h.
DayaBay::JobId JobInfoSvc::m_jobId [private] |
Definition at line 65 of file JobInfoSvc.h.
std::map<std::string, std::string> JobInfoSvc::m_jobConfig [private] |
Definition at line 69 of file JobInfoSvc.h.