CMS 3D CMS Logo

cond::Connection Class Reference

#include <CondCore/DBCommon/interface/Connection.h>

List of all members.

Public Member Functions

void connect (cond::DBSession *session)
 pass on the connection service handle to the proxy, do not connect for real.
 Connection (const std::string &con, int connectionTimeout=0)
 Constructor. If connectionTimeout=0, the commit method will close the database connection; if connectionTimeout=-1, the connection is not closed untill explict user call of disconnect method; if connectionTimeout=n, the connection will be closed by the commit method that holds the closest value of n.
std::string connectStr () const
 return connection string in use
CoralTransactioncoralTransaction ()
 return handle to the underlying coral transaction
void disconnect ()
 disconnect open connection by hand if connectionTimeout <0, otherwise, no real action taken
PoolTransactionpoolTransaction ()
 return handle to the underlying pool transaction
 ~Connection ()
 Destructor.

Private Attributes

std::string m_con
coral::IConnectionService * m_connectionServiceHandle
int m_connectionTimeOut
std::vector
< CoralConnectionProxy * > 
m_coralConnectionPool
int m_idleConnectionCleanupPeriod
std::vector
< PoolConnectionProxy * > 
m_poolConnectionPool


Detailed Description

Definition at line 26 of file Connection.h.


Constructor & Destructor Documentation

Connection::Connection ( const std::string &  con,
int  connectionTimeout = 0 
)

Constructor. If connectionTimeout=0, the commit method will close the database connection; if connectionTimeout=-1, the connection is not closed untill explict user call of disconnect method; if connectionTimeout=n, the connection will be closed by the commit method that holds the closest value of n.

Definition at line 10 of file Connection.cc.

References m_coralConnectionPool.

00011                                                    :
00012   m_con( con ),
00013   m_connectionTimeOut ( connectionTimeOut )
00014 {
00015   m_coralConnectionPool.reserve(10);
00016 }
cond::Connection::~Connection(){

Connection::~Connection (  ) 

Destructor.

Definition at line 17 of file Connection.cc.

References disconnect().

00017                            {
00018   this->disconnect();
00019 }


Member Function Documentation

void Connection::connect ( cond::DBSession session  ) 

pass on the connection service handle to the proxy, do not connect for real.

This method must be called after

Definition at line 20 of file Connection.cc.

References cond::DBSession::configuration(), cond::SessionConfiguration::connectionConfiguration(), cond::DBSession::connectionService(), cond::ConnectionConfiguration::idleConnectionCleanupPeriod(), m_connectionServiceHandle, and m_idleConnectionCleanupPeriod.

Referenced by DTDBSession::connect(), popcon::L1RPCHwConfigSourceHandler::ConnectOnlineDB(), popcon::RPCEMapSourceHandler::ConnectOnlineDB(), CondBasicIter::create(), l1t::DataManager::DataManager(), cond::RDBMS::getDB(), DTCCBConfigHandler::getNewObjects(), PixelPopConCalibSourceHandler::getNewObjects_coral(), and cond::RDBMS::setLogger().

00020                                                     {
00021   m_connectionServiceHandle=&(session->connectionService());
00022   m_idleConnectionCleanupPeriod=session->configuration().connectionConfiguration()->idleConnectionCleanupPeriod();
00023 }

std::string Connection::connectStr (  )  const

return connection string in use

Definition at line 57 of file Connection.cc.

References m_con.

Referenced by cond::service::PoolDBOutputService::add(), and cond::service::PoolDBOutputService::createNewIOV().

00057                                 {
00058   return m_con;
00059 }

cond::CoralTransaction & Connection::coralTransaction (  ) 

return handle to the underlying coral transaction

if first time, init everything, start timer if not first time,

Definition at line 29 of file Connection.cc.

References it, m_con, m_connectionServiceHandle, m_connectionTimeOut, m_coralConnectionPool, m_idleConnectionCleanupPeriod, me, and cond::CoralConnectionProxy::transaction().

Referenced by l1t::DataWriter::addMappings(), cond::CondDB::allTags(), popcon::L1RPCHwConfigSourceHandler::ConnectOnlineDB(), popcon::RPCEMapSourceHandler::ConnectOnlineDB(), CondBasicIter::create(), cond::service::PoolDBOutputService::createNewIOV(), l1t::DataManager::DataManager(), PoolDBESSource::fillRecordToIOVInfo(), l1t::DataWriter::findTokenForTag(), DTCCBConfigHandler::getNewObjects(), PixelPopConCalibSourceHandler::getNewObjects_coral(), cond::service::PoolDBOutputService::initDB(), cond::CondDB::iovToken(), l1t::DataReader::loadIntervals(), l1t::OMDSReader::OMDSReader(), and l1t::DataReader::payloadToken().

00029                                 {
00030   if( !m_coralConnectionPool.empty() ){
00031     std::vector<cond::CoralConnectionProxy*>::iterator it;
00032     std::vector<cond::CoralConnectionProxy*>::iterator itEnd=m_coralConnectionPool.end();
00033     for( it=m_coralConnectionPool.begin(); it!=itEnd; ++it ){
00034       return static_cast<cond::CoralTransaction&>((*it)->transaction());
00035     }
00036   }
00037   cond::CoralConnectionProxy* me=new cond::CoralConnectionProxy(
00038              m_connectionServiceHandle,m_con,m_connectionTimeOut,m_idleConnectionCleanupPeriod);
00039   m_coralConnectionPool.push_back(me);
00040   return static_cast<cond::CoralTransaction&>( me->transaction() );
00041 }

void Connection::disconnect ( void   ) 

disconnect open connection by hand if connectionTimeout <0, otherwise, no real action taken

Definition at line 61 of file Connection.cc.

References it, m_coralConnectionPool, and m_poolConnectionPool.

Referenced by DTDBSession::disconnect(), popcon::RPCEMapSourceHandler::DisconnectOnlineDB(), popcon::L1RPCHwConfigSourceHandler::DisconnectOnlineDB(), cond::CondDB::operator=(), cond::CondDB::~CondDB(), ~Connection(), and l1t::DataManager::~DataManager().

00061                           {
00062   if(!m_coralConnectionPool.empty()){
00063     std::vector<cond::CoralConnectionProxy*>::iterator it;
00064     std::vector<cond::CoralConnectionProxy*>::iterator itEnd=m_coralConnectionPool.end();
00065     for( it=m_coralConnectionPool.begin(); it!=itEnd; ++it){
00066       if( *it!=0 ) {
00067         delete *it;
00068         *it=0;
00069       } 
00070     }
00071     m_coralConnectionPool.clear();
00072   }
00073   if(!m_poolConnectionPool.empty()){
00074     std::vector<cond::PoolConnectionProxy*>::iterator poolit;
00075     std::vector<cond::PoolConnectionProxy*>::iterator poolitEnd=m_poolConnectionPool.end();
00076     for( poolit=m_poolConnectionPool.begin(); poolit!=poolitEnd; ++poolit){
00077       if( *poolit!=0 ) {
00078         delete *poolit;
00079         *poolit=0;
00080       } 
00081     }
00082     m_poolConnectionPool.clear();
00083   }
00084 }

cond::PoolTransaction & Connection::poolTransaction (  ) 

return handle to the underlying pool transaction

Definition at line 44 of file Connection.cc.

References it, m_con, m_connectionServiceHandle, m_connectionTimeOut, m_idleConnectionCleanupPeriod, m_poolConnectionPool, me, and cond::PoolConnectionProxy::transaction().

Referenced by cond::service::PoolDBOutputService::add(), DTDBSession::connect(), CondBasicIter::create(), cond::service::PoolDBOutputService::createNewIOV(), cond::CondDB::iov(), cond::CondDB::iovWithLib(), popcon::PopConSourceHandler< DTT0 >::lastPayload(), l1t::DataReader::loadIntervals(), DataProxy< RecordT, DataT >::make(), DataProxy< IdealGeometryRecord, DDCompactView >::make(), cond::CondDB::payLoad(), l1t::DataReader::payloadToken(), l1t::DataReader::readKey(), l1t::DataReader::readPayload(), PoolDBESSource::setIntervalFor(), cond::service::PoolDBOutputService::tagInfo(), l1t::DataWriter::updateIOV(), l1t::DataWriter::writeKey(), l1t::DataWriter::writeKeyList(), and l1t::DataWriter::writePayload().

00044                                {
00045   if( !m_poolConnectionPool.empty() ){
00046     std::vector<cond::PoolConnectionProxy*>::iterator it;
00047     std::vector<cond::PoolConnectionProxy*>::iterator itEnd=m_poolConnectionPool.end();
00048     for( it=m_poolConnectionPool.begin(); it!=itEnd; ++it ){
00049       return static_cast<cond::PoolTransaction&>((*it)->transaction());
00050     }
00051   }
00052   cond::PoolConnectionProxy* me=new cond::PoolConnectionProxy(m_connectionServiceHandle,m_con,m_connectionTimeOut,m_idleConnectionCleanupPeriod); 
00053   m_poolConnectionPool.push_back(me);
00054   return static_cast<cond::PoolTransaction&>(me->transaction());
00055 }


Member Data Documentation

std::string cond::Connection::m_con [private]

Definition at line 46 of file Connection.h.

Referenced by connectStr(), coralTransaction(), and poolTransaction().

coral::IConnectionService* cond::Connection::m_connectionServiceHandle [private]

Definition at line 51 of file Connection.h.

Referenced by connect(), coralTransaction(), and poolTransaction().

int cond::Connection::m_connectionTimeOut [private]

Definition at line 47 of file Connection.h.

Referenced by coralTransaction(), and poolTransaction().

std::vector<CoralConnectionProxy*> cond::Connection::m_coralConnectionPool [private]

Definition at line 50 of file Connection.h.

Referenced by Connection(), coralTransaction(), and disconnect().

int cond::Connection::m_idleConnectionCleanupPeriod [private]

Definition at line 48 of file Connection.h.

Referenced by connect(), coralTransaction(), and poolTransaction().

std::vector<PoolConnectionProxy*> cond::Connection::m_poolConnectionPool [private]

Definition at line 49 of file Connection.h.

Referenced by disconnect(), and poolTransaction().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:36:43 2009 for CMSSW by  doxygen 1.5.4