![]() |
![]() |
#include <CondCore/DBCommon/interface/PoolTransaction.h>
Public Member Functions | |
void | commit () |
commit transaction. Will disconnect from database if connection timeout==0 or connectted time close to the threshold | |
virtual bool | isReadOnly () const |
current transaction is active | |
virtual IConnectionProxy & | parentConnection () |
get handle to the parent connection | |
pool::IDataSvc & | poolDataSvc () |
get pool dataSvc handle | |
PoolTransaction (cond::PoolConnectionProxy *parentConnection) | |
void | resetPoolDataSvc (pool::IDataSvc *datasvc) const |
void | rollback () |
rollback transaction | |
void | start (bool readOnly) |
start transaction | |
~PoolTransaction () | |
Private Member Functions | |
void | forceCommit () |
void | upgrade () |
Private Attributes | |
int | m_count |
pool::IDataSvc * | m_datasvc |
cond::PoolConnectionProxy * | m_parentConnection |
Definition at line 19 of file PoolTransaction.h.
PoolTransaction::PoolTransaction | ( | cond::PoolConnectionProxy * | parentConnection | ) | [explicit] |
Definition at line 8 of file PoolTransaction.cc.
References cond::ITransaction::attach(), and m_parentConnection.
00008 :m_parentConnection(parentConnection),m_datasvc(0), m_count(0){ 00009 this->attach(m_parentConnection); 00010 }
PoolTransaction::~PoolTransaction | ( | ) |
void PoolTransaction::commit | ( | ) | [virtual] |
commit transaction. Will disconnect from database if connection timeout==0 or connectted time close to the threshold
Implements cond::ITransaction.
Definition at line 32 of file PoolTransaction.cc.
References forceCommit(), and m_count.
Referenced by cond::service::PoolDBOutputService::add(), cond::service::PoolDBOutputService::createNewIOV(), DTDBSession::disconnect(), cond::IOVServiceImpl::exportIOVRangeWithPayload(), l1t::DataReader::loadIntervals(), DataProxy< RecordT, DataT >::make(), DataProxy< IdealGeometryRecord, DDCompactView >::make(), l1t::DataReader::payloadToken(), l1t::DataReader::readKey(), l1t::DataReader::readPayload(), PoolDBESSource::setIntervalFor(), cond::service::PoolDBOutputService::tagInfo(), l1t::DataWriter::updateIOV(), l1t::DataWriter::writeKey(), l1t::DataWriter::writeKeyList(), l1t::DataWriter::writePayload(), CondBasicIter::~CondBasicIter(), cond::PoolTransactionSentry::Elem::~Elem(), cond::impl::IOVImpl::~IOVImpl(), and popcon::PopConSourceHandler< T >::Ref::~Ref().
00032 { 00033 if (0==m_count) return; 00034 m_count--; 00035 if (0==m_count) forceCommit(); 00036 }
void PoolTransaction::forceCommit | ( | ) | [private] |
Definition at line 46 of file PoolTransaction.cc.
References Exception, m_datasvc, and cond::ITransaction::NotifyEndOfTransaction().
Referenced by commit(), and upgrade().
00046 { 00047 if(!m_datasvc) throw cond::Exception("PoolTransaction::commit: database not connected"); 00048 if(!m_datasvc->transaction().commit()){ 00049 m_datasvc->transaction().rollback(); 00050 throw cond::TransactionException("cond::PoolTransaction::commit","An Error ocurred, transaction rolled back"); 00051 } 00052 this->NotifyEndOfTransaction(); 00053 }
bool PoolTransaction::isReadOnly | ( | ) | const [virtual] |
current transaction is active
current transaction is readonly
Implements cond::ITransaction.
Definition at line 63 of file PoolTransaction.cc.
References m_datasvc.
Referenced by cond::GenericRef::exportTo(), cond::GenericRef::GenericRef(), and start().
00063 { 00064 if(m_datasvc->transaction().type()==pool::ITransaction::READ) return true; 00065 return false; 00066 }
cond::IConnectionProxy & PoolTransaction::parentConnection | ( | ) | [virtual] |
get handle to the parent connection
Implements cond::ITransaction.
Definition at line 68 of file PoolTransaction.cc.
References m_parentConnection.
Referenced by cond::PoolContainerManager::exportContainer(), cond::GenericRef::exportTo(), cond::GenericRef::GenericRef(), and cond::PoolContainerManager::listAll().
00068 { 00069 return *m_parentConnection; 00070 }
pool::IDataSvc & PoolTransaction::poolDataSvc | ( | ) |
get pool dataSvc handle
Definition at line 76 of file PoolTransaction.cc.
References m_datasvc.
Referenced by cond::PoolContainerManager::exportContainer(), cond::GenericRef::exportTo(), cond::PoolContainerManager::listAll(), DataProxy< RecordT, DataT >::make(), and DataProxy< IdealGeometryRecord, DDCompactView >::make().
00076 { 00077 return *m_datasvc; 00078 }
void PoolTransaction::resetPoolDataSvc | ( | pool::IDataSvc * | datasvc | ) | const |
Definition at line 72 of file PoolTransaction.cc.
References m_datasvc.
00072 { 00073 m_datasvc=datasvc; 00074 }
void PoolTransaction::rollback | ( | ) | [virtual] |
rollback transaction
Implements cond::ITransaction.
Definition at line 57 of file PoolTransaction.cc.
References Exception, m_datasvc, and cond::ITransaction::NotifyEndOfTransaction().
00057 { 00058 if(!m_datasvc) throw cond::Exception("PoolTransaction::rollback: database not connected"); 00059 m_datasvc->transaction().rollback(); 00060 this->NotifyEndOfTransaction(); 00061 }
start transaction
Implements cond::ITransaction.
Definition at line 15 of file PoolTransaction.cc.
References Exception, isReadOnly(), m_count, m_datasvc, cond::ITransaction::NotifyStartOfTransaction(), UPDATE, and upgrade().
Referenced by cond::service::PoolDBOutputService::add(), DTDBSession::connect(), CondBasicIter::create(), cond::service::PoolDBOutputService::createNewIOV(), cond::PoolTransactionSentry::Elem::Elem(), cond::IOVServiceImpl::exportIOVRangeWithPayload(), cond::impl::IOVImpl::IOVImpl(), l1t::DataReader::loadIntervals(), DataProxy< RecordT, DataT >::make(), DataProxy< IdealGeometryRecord, DDCompactView >::make(), l1t::DataReader::payloadToken(), l1t::DataReader::readKey(), l1t::DataReader::readPayload(), popcon::PopConSourceHandler< T >::Ref::Ref(), PoolDBESSource::setIntervalFor(), cond::service::PoolDBOutputService::tagInfo(), l1t::DataWriter::updateIOV(), l1t::DataWriter::writeKey(), l1t::DataWriter::writeKeyList(), and l1t::DataWriter::writePayload().
00015 { 00016 m_count++; 00017 if (1==m_count) { 00018 this->NotifyStartOfTransaction(); 00019 if(!m_datasvc) throw cond::Exception("PoolTransaction::start: database not connected"); 00020 if(!readOnly){ 00021 m_datasvc->transaction().start( pool::ITransaction::UPDATE ); 00022 }else{ 00023 m_datasvc->transaction().start( pool::ITransaction::READ ); 00024 } 00025 return; 00026 } 00027 if (!readOnly && isReadOnly()) upgrade(); 00028 00029 }
void PoolTransaction::upgrade | ( | ) | [private] |
Definition at line 39 of file PoolTransaction.cc.
References forceCommit(), m_datasvc, cond::ITransaction::NotifyStartOfTransaction(), and UPDATE.
Referenced by start().
00039 { 00040 forceCommit(); 00041 this->NotifyStartOfTransaction(); 00042 m_datasvc->transaction().start( pool::ITransaction::UPDATE ); 00043 }
int cond::PoolTransaction::m_count [private] |
pool::IDataSvc* cond::PoolTransaction::m_datasvc [mutable, private] |
Definition at line 44 of file PoolTransaction.h.
Referenced by forceCommit(), isReadOnly(), poolDataSvc(), resetPoolDataSvc(), rollback(), start(), and upgrade().
Definition at line 43 of file PoolTransaction.h.
Referenced by parentConnection(), and PoolTransaction().