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 addMigratedPayload (const std::string &sourceAccount, const std::string &sourceToken, const std::string &payloadId)
 
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::SYNCH_ANY)
 
IOVEditor createIov (const std::string &payloadType, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
 
IOVEditor createIov (const std::string &payloadType, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType, const boost::posix_time::ptime &creationTime)
 
IOVEditor createIovForPayload (const Hash &payloadHash, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
 
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 ()
 
bool lookupMigratedPayload (const std::string &sourceAccount, const std::string &sourceToken, std::string &payloadId)
 
coral::ISchema & nominalSchema ()
 
Sessionoperator= (const Session &rhs)
 
std::string parsePoolToken (const std::string &poolToken)
 
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)
 
IOVProxy readIov (const std::string &tag, const boost::posix_time::ptime &snapshottime, 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 updateMigratedPayload (const std::string &sourceAccount, const std::string &sourceToken, const std::string &payloadId)
 
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:195
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
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:195
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
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:195
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
Session::~Session ( )
virtual

Definition at line 53 of file Session.cc.

53  {
54  }

Member Function Documentation

void Session::addMigratedPayload ( const std::string &  sourceAccount,
const std::string &  sourceToken,
const std::string &  payloadId 
)

Definition at line 244 of file Session.cc.

References m_session.

246  {
247  m_session->openIovDb();
248  if(! m_session->iovSchema().payloadMigrationTable().exists() ) m_session->iovSchema().payloadMigrationTable().create();
249  m_session->iovSchema().payloadMigrationTable().insert( sourceAccount, sourceToken, payloadId,
250  boost::posix_time::microsec_clock::universal_time() );
251  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
void Session::addToMigrationLog ( const std::string &  sourceAccount,
const std::string &  sourceTag,
const std::string &  destinationTag,
cond::MigrationStatus  status 
)

Definition at line 217 of file Session.cc.

References m_session.

220  {
221  m_session->openIovDb();
222  if(! m_session->iovSchema().tagMigrationTable().exists() ) m_session->iovSchema().tagMigrationTable().create();
223  m_session->iovSchema().tagMigrationTable().insert( sourceAccount, sourceTag, destTag, (int)status,
224  boost::posix_time::microsec_clock::universal_time() );
225  }
tuple status
Definition: ntuplemaker.py:245
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
bool Session::checkMigrationLog ( const std::string &  sourceAccount,
const std::string &  sourceTag,
std::string &  destinationTag,
cond::MigrationStatus status 
)

Definition at line 207 of file Session.cc.

References m_session.

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

Definition at line 148 of file Session.cc.

References m_session.

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

148  {
149  m_session->openIovDb();
150  m_session->iovSchema().iovTable().erase( tag );
151  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
void Session::close ( void  )
std::string Session::connectionString ( )
coral::ISessionProxy & Session::coralSession ( )

Definition at line 272 of file Session.cc.

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

Referenced by nominalSchema().

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

Definition at line 77 of file Session.cc.

References m_session.

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

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

Definition at line 158 of file Session.cc.

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

158  {
159  m_session->openGTDb();
160  if( m_session->gtSchema().gtTable().select( name ) )
161  throwException( "The specified Global Tag \""+name+"\" already exist in the database.","Session::createGlobalTag");
163  return editor;
164  }
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:194
template<typename T >
IOVEditor Session::createIov ( const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::SYNCH_ANY 
)
inline

Definition at line 198 of file Session.h.

References ora::ClassUtils::demangledName().

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

198  {
199  return createIov( cond::demangledName( typeid(T) ), tag, timeType, synchronizationType );
200  }
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.h:198
std::string demangledName(const std::type_info &typeInfo)
Definition: ClassUtils.cc:159
long double T
IOVEditor Session::createIov ( const std::string &  payloadType,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::SYNCH_ANY 
)

Definition at line 108 of file Session.cc.

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

109  {
110  m_session->openDb();
111  if( m_session->iovSchema().tagTable().select( tag ) )
112  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIov");
113  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType );
114  return editor;
115  }
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:194
IOVEditor Session::createIov ( const std::string &  payloadType,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType,
const boost::posix_time::ptime &  creationTime 
)

Definition at line 117 of file Session.cc.

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

121  {
122  m_session->openDb();
123  if( m_session->iovSchema().tagTable().select( tag ) )
124  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIov");
125  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType, creationTime );
126  return editor;
127  }
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:194
IOVEditor Session::createIovForPayload ( const Hash payloadHash,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::SYNCH_ANY 
)

Definition at line 129 of file Session.cc.

References idDealer::editor, m_session, HLT_25ns14e33_v1_cff::payloadType, AlCaHLTBitMon_QueryRunRegistry::string, and cond::persistency::throwException().

130  {
131  m_session->openDb();
132  if( m_session->iovSchema().tagTable().select( tag ) )
133  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIovForPayload");
135  if( !m_session->iovSchema().payloadTable().getType( payloadHash, payloadType ) )
136  throwException( "The specified payloadId \""+payloadHash+"\" does not exist in the database.","Session::createIovForPayload");
137  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType );
138  return editor;
139  }
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:194
GTEditor Session::editGlobalTag ( const std::string &  name)

Definition at line 166 of file Session.cc.

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

166  {
167  m_session->openGTDb();
169  editor.load( name );
170  return editor;
171  }
tuple editor
Definition: idDealer.py:73
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
IOVEditor Session::editIov ( const std::string &  tag)
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(), cond::persistency::importIovs(), and cond::persistency::migrateTag().

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

Definition at line 153 of file Session.cc.

References m_session.

153  {
154  m_session->openGTDb();
155  return m_session->gtSchema().gtTable().select( name );
156  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
bool Session::existsIov ( const std::string &  tag)

Definition at line 97 of file Session.cc.

References m_session.

Referenced by cond::persistency::copyIov(), cond::persistency::copyTag(), cond::persistency::importIovs(), popcon::PopCon::initialize(), and cond::persistency::migrateTag().

97  {
98  m_session->openIovDb();
99  return m_session->iovSchema().tagTable().select( tag );
100  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
template<typename T >
boost::shared_ptr< T > Session::fetchPayload ( const cond::Hash payloadHash)
inline

Definition at line 215 of file Session.h.

References alignCSCRings::e, fetchPayloadData(), isOraSession(), HLT_25ns14e33_v1_cff::payloadType, run_regression::ret, AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::throwException(), and cms::Exception::what().

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

215  {
216  cond::Binary payloadData;
217  cond::Binary streamerInfoData;
219  if(! fetchPayloadData( payloadHash, payloadType, payloadData, streamerInfoData ) )
220  throwException( "Payload with id "+payloadHash+" has not been found in the database.",
221  "Session::fetchPayload" );
222  boost::shared_ptr<T> ret;
223  try{
224  ret = deserialize<T>( payloadType, payloadData, streamerInfoData, isOraSession() );
225  } catch ( const cond::persistency::Exception& e ){
226  std::string em(e.what());
227  throwException( "Payload of type "+payloadType+" with id "+payloadHash+" could not be loaded. "+em,"Session::fetchPayload");
228  }
229  return ret;
230  }
virtual char const * what() const
Definition: Exception.cc:141
Base exception class for the object to relational access.
Definition: Exception.h:13
bool fetchPayloadData(const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
Definition: Session.cc:195
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 195 of file Session.cc.

References m_session.

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

198  {
199  m_session->openIovDb();
200  return m_session->iovSchema().payloadTable().select( payloadHash, payloadType, payloadData, streamerInfoData );
201  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
IOVProxy Session::iovProxy ( )

Definition at line 102 of file Session.cc.

References m_session.

102  {
103  m_session->openIovDb();
104  IOVProxy proxy( m_session );
105  return proxy;
106  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
bool Session::isOraSession ( )

Definition at line 203 of file Session.cc.

References m_session.

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

203  {
204  return m_session->isOra();
205  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
bool Session::lookupMigratedPayload ( const std::string &  sourceAccount,
const std::string &  sourceToken,
std::string &  payloadId 
)

Definition at line 236 of file Session.cc.

References m_session.

238  {
239  m_session->openIovDb();
240  if(! m_session->iovSchema().payloadMigrationTable().exists() ) return false;
241  return m_session->iovSchema().payloadMigrationTable().select( sourceAccount, sourceToken, payloadId );
242  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
coral::ISchema & Session::nominalSchema ( )

Definition at line 277 of file Session.cc.

References coralSession().

277  {
278  return coralSession().nominalSchema();
279  }
coral::ISessionProxy & coralSession()
Definition: Session.cc:272
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:195
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
std::string Session::parsePoolToken ( const std::string &  poolToken)

Definition at line 263 of file Session.cc.

References m_session.

263  {
264  m_session->openIovDb();
265  return m_session->iovSchema().parsePoolToken( poolToken );
266  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
GTProxy Session::readGlobalTag ( const std::string &  name)

Definition at line 173 of file Session.cc.

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

Referenced by CondDBESSource::fillTagCollectionFromGT().

173  {
174  m_session->openGTDb();
175  GTProxy proxy( m_session );
176  proxy.load( name );
177  return proxy;
178  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
GTProxy Session::readGlobalTag ( const std::string &  name,
const std::string &  preFix,
const std::string &  postFix 
)

Definition at line 180 of file Session.cc.

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

180  {
181  m_session->openGTDb();
182  GTProxy proxy( m_session );
183  proxy.load( name, preFix, postFix );
184  return proxy;
185  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
IOVProxy Session::readIov ( const std::string &  tag,
bool  full = false 
)
IOVProxy Session::readIov ( const std::string &  tag,
const boost::posix_time::ptime &  snapshottime,
bool  full = false 
)

Definition at line 88 of file Session.cc.

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

90  {
91  m_session->openIovDb();
92  IOVProxy proxy( m_session );
93  proxy.load( tag, snapshottime, full );
94  return proxy;
95  }
Definition: GenABIO.cc:180
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
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 202 of file Session.h.

References ora::ClassUtils::demangledName(), alignCSCRings::e, isOraSession(), run_regression::ret, cond::serialize(), storePayloadData(), AlCaHLTBitMon_QueryRunRegistry::string, cond::persistency::throwException(), and cms::Exception::what().

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

202  {
203 
204  std::string payloadObjectType = cond::demangledName(typeid(payload));
205  cond::Hash ret;
206  try{
207  ret = storePayloadData( payloadObjectType, serialize( payload, isOraSession() ), creationTime );
208  } catch ( const cond::persistency::Exception& e ){
209  std::string em(e.what());
210  throwException( "Payload of type "+payloadObjectType+" could not be stored. "+em,"Session::storePayload");
211  }
212  return ret;
213  }
virtual char const * what() const
Definition: Exception.cc:141
Base exception class for the object to relational access.
Definition: Exception.h:13
std::string demangledName(const std::type_info &typeInfo)
Definition: ClassUtils.cc:159
std::string Hash
Definition: Types.h:47
cond::Hash storePayloadData(const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
Definition: Session.cc:187
std::pair< Binary, Binary > serialize(const T &payload, bool packingOnly=false)
Definition: Serialization.h:55
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
cond::Hash Session::storePayloadData ( const std::string &  payloadObjectType,
const std::pair< Binary, Binary > &  payloadAndStreamerInfoData,
const boost::posix_time::ptime &  creationTime 
)
private

Definition at line 187 of file Session.cc.

References m_session.

Referenced by storePayload().

189  {
190  m_session->openDb();
191  return m_session->iovSchema().payloadTable().insertIfNew( payloadObjectType, payloadAndStreamerInfoData.first,
192  payloadAndStreamerInfoData.second, creationTime );
193  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
Transaction & Session::transaction ( )
void Session::updateMigratedPayload ( const std::string &  sourceAccount,
const std::string &  sourceToken,
const std::string &  payloadId 
)

Definition at line 253 of file Session.cc.

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

255  {
256  m_session->openIovDb();
257  if(! m_session->iovSchema().payloadMigrationTable().exists() )
258  throwException( "Payload Migration Table does not exist in this schema.","Session::updateMigratedPayload");
259  m_session->iovSchema().payloadMigrationTable().update( sourceAccount, sourceToken, payloadId,
260  boost::posix_time::microsec_clock::universal_time() );
261  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
void Session::updateMigrationLog ( const std::string &  sourceAccount,
const std::string &  sourceTag,
cond::MigrationStatus  status 
)

Definition at line 227 of file Session.cc.

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

229  {
230  m_session->openIovDb();
231  if(! m_session->iovSchema().tagMigrationTable().exists() )
232  throwException( "Migration Log Table does not exist in this schema.","Session::updateMigrationLog");
233  m_session->iovSchema().tagMigrationTable().updateValidationCode( sourceAccount, sourceTag, (int)status );
234  }
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:194

Member Data Documentation

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

Definition at line 195 of file Session.h.

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