CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
cond::persistency::Session Class Reference

#include <Session.h>

Public Member Functions

void addToMigrationLog (const std::string &sourceAccount, const std::string &sourceTag, const std::string &destinationTag, cond::MigrationStatus status)
 
bool checkMigrationLog (const std::string &sourceAccount, const std::string &sourceTag, std::string &destinationTag, cond::MigrationStatus &status)
 
void clearIov (const std::string &tag)
 
void close ()
 
std::string connectionString ()
 
coral::ISessionProxy & coralSession ()
 
void createDatabase ()
 
GTEditor createGlobalTag (const std::string &name)
 
template<typename T >
IOVEditor createIov (const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::OFFLINE)
 
IOVEditor createIov (const std::string &payloadType, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::OFFLINE)
 
IOVEditor createIovForPayload (const Hash &payloadHash, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::OFFLINE)
 
GTEditor editGlobalTag (const std::string &name)
 
IOVEditor editIov (const std::string &tag)
 
bool existsDatabase ()
 
bool existsGlobalTag (const std::string &name)
 
bool existsIov (const std::string &tag)
 
template<typename T >
boost::shared_ptr< TfetchPayload (const cond::Hash &payloadHash)
 
bool fetchPayloadData (const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
 
IOVProxy iovProxy ()
 
bool isOraSession ()
 
coral::ISchema & nominalSchema ()
 
Sessionoperator= (const Session &rhs)
 
GTProxy readGlobalTag (const std::string &name)
 
GTProxy readGlobalTag (const std::string &name, const std::string &preFix, const std::string &postFix)
 
IOVProxy readIov (const std::string &tag, bool full=false)
 
 Session ()
 
 Session (const std::shared_ptr< SessionImpl > &sessionImpl)
 
 Session (const Session &rhs)
 
template<typename T >
cond::Hash storePayload (const T &payload, const boost::posix_time::ptime &creationTime=boost::posix_time::microsec_clock::universal_time())
 
Transactiontransaction ()
 
void updateMigrationLog (const std::string &sourceAccount, const std::string &sourceTag, cond::MigrationStatus status)
 
virtual ~Session ()
 

Private Member Functions

cond::Hash storePayloadData (const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
 

Private Attributes

std::shared_ptr< SessionImplm_session
 
Transaction m_transaction
 

Detailed Description

Definition at line 59 of file Session.h.

Constructor & Destructor Documentation

Session::Session ( )

Definition at line 38 of file Session.cc.

38  :
39  m_session( new SessionImpl ),
41  }
Transaction m_transaction
Definition: Session.h:175
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
Session::Session ( const std::shared_ptr< SessionImpl > &  sessionImpl)
explicit

Definition at line 43 of file Session.cc.

43  :
44  m_session( sessionImpl ),
46  }
Transaction m_transaction
Definition: Session.h:175
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
Session::Session ( const Session rhs)

Definition at line 48 of file Session.cc.

48  :
49  m_session( rhs.m_session ),
50  m_transaction( rhs.m_transaction ){
51  }
Transaction m_transaction
Definition: Session.h:175
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
Session::~Session ( )
virtual

Definition at line 53 of file Session.cc.

53  {
54  }

Member Function Documentation

void Session::addToMigrationLog ( const std::string &  sourceAccount,
const std::string &  sourceTag,
const std::string &  destinationTag,
cond::MigrationStatus  status 
)

Definition at line 196 of file Session.cc.

References m_session.

199  {
200  m_session->openIovDb();
201  if(! m_session->iovSchema().tagMigrationTable().exists() ) m_session->iovSchema().tagMigrationTable().create();
202  m_session->iovSchema().tagMigrationTable().insert( sourceAccount, sourceTag, destTag, (int)status,
203  boost::posix_time::microsec_clock::universal_time() );
204  }
tuple status
Definition: ntuplemaker.py:245
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
bool Session::checkMigrationLog ( const std::string &  sourceAccount,
const std::string &  sourceTag,
std::string &  destinationTag,
cond::MigrationStatus status 
)

Definition at line 186 of file Session.cc.

References m_session.

189  {
190  m_session->openIovDb();
191  if(! m_session->iovSchema().tagMigrationTable().exists() ) m_session->iovSchema().tagMigrationTable().create();
192  //throwException( "Migration Log Table does not exist in this schema.","Session::checkMigrationLog");
193  return m_session->iovSchema().tagMigrationTable().select( sourceAccount, sourceTag, destTag, (int&)status );
194  }
tuple status
Definition: ntuplemaker.py:245
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
void Session::clearIov ( const std::string &  tag)

Definition at line 127 of file Session.cc.

References m_session.

Referenced by cond::persistency::copyTag().

127  {
128  m_session->openIovDb();
129  m_session->iovSchema().iovTable().erase( tag );
130  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
void Session::close ( void  )
std::string Session::connectionString ( )
coral::ISessionProxy & Session::coralSession ( )

Definition at line 219 of file Session.cc.

References m_session, and cond::persistency::throwException().

Referenced by nominalSchema().

219  {
220  if( !m_session->coralSession.get() ) throwException( "The session is not active.","Session::coralSession");
221  return *m_session->coralSession;
222  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
void Session::createDatabase ( )

Definition at line 77 of file Session.cc.

References cond::persistency::SessionImpl::CREATE, and m_session.

Referenced by cond::persistency::copyTag(), and cond::persistency::importIovs().

77  {
78  m_session->openIovDb( SessionImpl::CREATE );
79  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
GTEditor Session::createGlobalTag ( const std::string &  name)

Definition at line 137 of file Session.cc.

References idDealer::editor, m_session, and cond::persistency::throwException().

137  {
138  m_session->openGTDb();
139  if( m_session->gtSchema().gtTable().select( name ) )
140  throwException( "The specified Global Tag \""+name+"\" already exist in the database.","Session::createGlobalTag");
142  return editor;
143  }
tuple editor
Definition: idDealer.py:73
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
template<typename T >
IOVEditor Session::createIov ( const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::OFFLINE 
)
inline

Definition at line 178 of file Session.h.

References ora::ClassUtils::demangledName().

Referenced by cond::persistency::copyIov(), cond::persistency::copyTag(), and cond::persistency::importIovs().

178  {
179  return createIov( cond::demangledName( typeid(T) ), tag, timeType, synchronizationType );
180  }
std::string demangledName(const std::type_info &typeInfo)
Definition: ClassUtils.cc:82
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::OFFLINE)
Definition: Session.h:178
long double T
IOVEditor Session::createIov ( const std::string &  payloadType,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::OFFLINE 
)

Definition at line 99 of file Session.cc.

References cond::persistency::SessionImpl::CREATE, idDealer::editor, m_session, and cond::persistency::throwException().

100  {
101  m_session->openIovDb( SessionImpl::CREATE );
102  if( m_session->iovSchema().tagTable().select( tag ) )
103  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIov");
104  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType );
105  return editor;
106  }
tuple editor
Definition: idDealer.py:73
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
IOVEditor Session::createIovForPayload ( const Hash payloadHash,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::OFFLINE 
)

Definition at line 108 of file Session.cc.

References cond::persistency::SessionImpl::CREATE, idDealer::editor, m_session, AlCaHLTBitMon_QueryRunRegistry::string, and cond::persistency::throwException().

109  {
110  m_session->openIovDb( SessionImpl::CREATE );
111  if( m_session->iovSchema().tagTable().select( tag ) )
112  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIovForPayload");
113  std::string payloadType("");
114  if( !m_session->iovSchema().payloadTable().getType( payloadHash, payloadType ) )
115  throwException( "The specified payloadId \""+payloadHash+"\" does not exist in the database.","Session::createIovForPayload");
116  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType );
117  return editor;
118  }
tuple editor
Definition: idDealer.py:73
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
GTEditor Session::editGlobalTag ( const std::string &  name)

Definition at line 145 of file Session.cc.

References idDealer::editor, cond::persistency::GTEditor::load(), and m_session.

145  {
146  m_session->openGTDb();
148  editor.load( name );
149  return editor;
150  }
tuple editor
Definition: idDealer.py:73
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
IOVEditor Session::editIov ( const std::string &  tag)

Definition at line 120 of file Session.cc.

References idDealer::editor, cond::persistency::IOVEditor::load(), and m_session.

Referenced by cond::persistency::copyIov(), cond::persistency::copyTag(), and cond::persistency::importIovs().

120  {
121  m_session->openIovDb();
123  editor.load( tag );
124  return editor;
125  }
tuple editor
Definition: idDealer.py:73
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
bool Session::existsDatabase ( )

Definition at line 71 of file Session.cc.

References cond::persistency::SessionImpl::DO_NOT_THROW, and m_session.

Referenced by cond::persistency::copyTag(), and cond::persistency::importIovs().

71  {
73  return m_session->transaction->iovDbExists;
74  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
bool Session::existsGlobalTag ( const std::string &  name)

Definition at line 132 of file Session.cc.

References m_session.

132  {
133  m_session->openGTDb();
134  return m_session->gtSchema().gtTable().select( name );
135  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
bool Session::existsIov ( const std::string &  tag)

Definition at line 88 of file Session.cc.

References m_session.

Referenced by cond::persistency::copyIov(), cond::persistency::copyTag(), and cond::persistency::importIovs().

88  {
89  m_session->openIovDb();
90  return m_session->iovSchema().tagTable().select( tag );
91  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
template<typename T >
boost::shared_ptr< T > Session::fetchPayload ( const cond::Hash payloadHash)
inline

Definition at line 188 of file Session.h.

References fetchPayloadData(), isOraSession(), AlCaHLTBitMon_QueryRunRegistry::string, and cond::persistency::throwException().

Referenced by cond::persistency::PayloadProxy< std::vector< cond::Time_t > >::loadPayload(), l1t::DataWriter::readObject(), and popcon::PopConSourceHandler< T >::Ref::Ref().

188  {
189  cond::Binary payloadData;
190  cond::Binary streamerInfoData;
191  std::string payloadType;
192  if(! fetchPayloadData( payloadHash, payloadType, payloadData, streamerInfoData ) )
193  throwException( "Payload with id="+payloadHash+" has not been found in the database.",
194  "Session::fetchPayload" );
195  return deserialize<T>( payloadType, payloadData, streamerInfoData, isOraSession() );
196  }
bool fetchPayloadData(const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
Definition: Session.cc:174
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
bool Session::fetchPayloadData ( const cond::Hash payloadHash,
std::string &  payloadType,
cond::Binary payloadData,
cond::Binary streamerInfoData 
)

Definition at line 174 of file Session.cc.

References m_session.

Referenced by cond::persistency::fetch(), fetchPayload(), and cond::persistency::KeyList::load().

177  {
178  m_session->openIovDb();
179  return m_session->iovSchema().payloadTable().select( payloadHash, payloadType, payloadData, streamerInfoData );
180  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
IOVProxy Session::iovProxy ( )

Definition at line 93 of file Session.cc.

References m_session.

93  {
94  m_session->openIovDb();
95  IOVProxy proxy( m_session );
96  return proxy;
97  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
bool Session::isOraSession ( )

Definition at line 182 of file Session.cc.

References m_session.

Referenced by cond::persistency::fetch(), fetchPayload(), cond::persistency::KeyList::load(), and storePayload().

182  {
183  return m_session->isOra();
184  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
coral::ISchema & Session::nominalSchema ( )

Definition at line 224 of file Session.cc.

References coralSession().

Referenced by DTUserKeyedConfigHandler::chkConfigList(), DTKeyedConfigHandler::chkConfigList(), DTUserKeyedConfigHandler::getNewObjects(), and DTKeyedConfigHandler::getNewObjects().

224  {
225  return coralSession().nominalSchema();
226  }
coral::ISessionProxy & coralSession()
Definition: Session.cc:219
Session & Session::operator= ( const Session rhs)

Definition at line 56 of file Session.cc.

References m_session, and m_transaction.

56  {
57  m_session = rhs.m_session;
58  m_transaction = rhs.m_transaction;
59  return *this;
60  }
Transaction m_transaction
Definition: Session.h:175
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
GTProxy Session::readGlobalTag ( const std::string &  name)

Definition at line 152 of file Session.cc.

References cond::persistency::GTProxy::load(), and m_session.

Referenced by CondDBESSource::fillTagCollectionFromGT().

152  {
153  m_session->openGTDb();
154  GTProxy proxy( m_session );
155  proxy.load( name );
156  return proxy;
157  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
GTProxy Session::readGlobalTag ( const std::string &  name,
const std::string &  preFix,
const std::string &  postFix 
)

Definition at line 159 of file Session.cc.

References cond::persistency::GTProxy::load(), and m_session.

159  {
160  m_session->openGTDb();
161  GTProxy proxy( m_session );
162  proxy.load( name, preFix, postFix );
163  return proxy;
164  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
IOVProxy Session::readIov ( const std::string &  tag,
bool  full = false 
)
template<typename T >
cond::Hash Session::storePayload ( const T payload,
const boost::posix_time::ptime &  creationTime = boost::posix_time::microsec_clock::universal_time() 
)
inline

Definition at line 182 of file Session.h.

References ora::ClassUtils::demangledName(), isOraSession(), cond::serialize(), storePayloadData(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by cond::service::PoolDBOutputService::appendSinceTime(), cond::service::PoolDBOutputService::createNewIOV(), l1t::WriterProxyT< Record, Type >::save(), l1t::DataWriter::writeKeyList(), and cond::service::PoolDBOutputService::writeOne().

182  {
183 
184  std::string payloadObjectType = cond::demangledName(typeid(payload));
185  return storePayloadData( payloadObjectType, serialize( payload, isOraSession() ), creationTime );
186  }
std::string demangledName(const std::type_info &typeInfo)
Definition: ClassUtils.cc:82
cond::Hash storePayloadData(const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
Definition: Session.cc:166
std::pair< Binary, Binary > serialize(const T &payload, bool packingOnly=false)
Definition: Serialization.h:92
cond::Hash Session::storePayloadData ( const std::string &  payloadObjectType,
const std::pair< Binary, Binary > &  payloadAndStreamerInfoData,
const boost::posix_time::ptime &  creationTime 
)
private

Definition at line 166 of file Session.cc.

References cond::persistency::SessionImpl::CREATE, and m_session.

Referenced by storePayload().

168  {
169  m_session->openIovDb( SessionImpl::CREATE );
170  return m_session->iovSchema().payloadTable().insertIfNew( payloadObjectType, payloadAndStreamerInfoData.first,
171  payloadAndStreamerInfoData.second, creationTime );
172  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
Transaction & Session::transaction ( )
void Session::updateMigrationLog ( const std::string &  sourceAccount,
const std::string &  sourceTag,
cond::MigrationStatus  status 
)

Definition at line 206 of file Session.cc.

References m_session, and cond::persistency::throwException().

208  {
209  m_session->openIovDb();
210  if(! m_session->iovSchema().tagMigrationTable().exists() )
211  throwException( "Migration Log Table does not exist in this schema.","Session::updateMigrationLog");
212  m_session->iovSchema().tagMigrationTable().updateValidationCode( sourceAccount, sourceTag, (int)status );
213  }
tuple status
Definition: ntuplemaker.py:245
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174

Member Data Documentation

std::shared_ptr<SessionImpl> cond::persistency::Session::m_session
private
Transaction cond::persistency::Session::m_transaction
private

Definition at line 175 of file Session.h.

Referenced by operator=(), and transaction().