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::OFFLINE)
 
IOVEditor createIov (const std::string &payloadType, 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, const boost::posix_time::ptime &creationTime)
 
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 ()
 
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)
 
 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:191
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
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:191
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
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:191
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
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 235 of file Session.cc.

References m_session.

237  {
238  m_session->openIovDb();
239  if(! m_session->iovSchema().payloadMigrationTable().exists() ) m_session->iovSchema().payloadMigrationTable().create();
240  m_session->iovSchema().payloadMigrationTable().insert( sourceAccount, sourceToken, payloadId,
241  boost::posix_time::microsec_clock::universal_time() );
242  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
void Session::addToMigrationLog ( const std::string &  sourceAccount,
const std::string &  sourceTag,
const std::string &  destinationTag,
cond::MigrationStatus  status 
)

Definition at line 208 of file Session.cc.

References m_session.

211  {
212  m_session->openIovDb();
213  if(! m_session->iovSchema().tagMigrationTable().exists() ) m_session->iovSchema().tagMigrationTable().create();
214  m_session->iovSchema().tagMigrationTable().insert( sourceAccount, sourceTag, destTag, (int)status,
215  boost::posix_time::microsec_clock::universal_time() );
216  }
tuple status
Definition: ntuplemaker.py:245
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
bool Session::checkMigrationLog ( const std::string &  sourceAccount,
const std::string &  sourceTag,
std::string &  destinationTag,
cond::MigrationStatus status 
)

Definition at line 198 of file Session.cc.

References m_session.

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

Definition at line 139 of file Session.cc.

References m_session.

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

139  {
140  m_session->openIovDb();
141  m_session->iovSchema().iovTable().erase( tag );
142  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
void Session::close ( void  )
std::string Session::connectionString ( )

Definition at line 259 of file Session.cc.

References m_session.

Referenced by cond::persistency::compareTags(), cond::persistency::copyTag(), PCLMetadataWriter::endRun(), cond::persistency::importIovs(), popcon::PopCon::initialize(), and cond::persistency::validateTag().

259  {
260  return m_session->connectionString;
261  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
coral::ISessionProxy & Session::coralSession ( )

Definition at line 263 of file Session.cc.

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

Referenced by nominalSchema().

263  {
264  if( !m_session->coralSession.get() ) throwException( "The session is not active.","Session::coralSession");
265  return *m_session->coralSession;
266  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
void Session::createDatabase ( )
GTEditor Session::createGlobalTag ( const std::string &  name)

Definition at line 149 of file Session.cc.

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

149  {
150  m_session->openGTDb();
151  if( m_session->gtSchema().gtTable().select( name ) )
152  throwException( "The specified Global Tag \""+name+"\" already exist in the database.","Session::createGlobalTag");
154  return editor;
155  }
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:190
template<typename T >
IOVEditor Session::createIov ( const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::OFFLINE 
)
inline

Definition at line 194 of file Session.h.

References ora::ClassUtils::demangledName().

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

194  {
195  return createIov( cond::demangledName( typeid(T) ), tag, timeType, synchronizationType );
196  }
std::string demangledName(const std::type_info &typeInfo)
Definition: ClassUtils.cc:156
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::OFFLINE)
Definition: Session.h:194
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:190
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 108 of file Session.cc.

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

112  {
113  m_session->openIovDb( SessionImpl::CREATE );
114  if( m_session->iovSchema().tagTable().select( tag ) )
115  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIov");
116  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType, creationTime );
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:190
IOVEditor Session::createIovForPayload ( const Hash payloadHash,
const std::string &  tag,
cond::TimeType  timeType,
cond::SynchronizationType  synchronizationType = cond::OFFLINE 
)

Definition at line 120 of file Session.cc.

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

121  {
122  m_session->openIovDb( SessionImpl::CREATE );
123  if( m_session->iovSchema().tagTable().select( tag ) )
124  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIovForPayload");
126  if( !m_session->iovSchema().payloadTable().getType( payloadHash, payloadType ) )
127  throwException( "The specified payloadId \""+payloadHash+"\" does not exist in the database.","Session::createIovForPayload");
128  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType );
129  return editor;
130  }
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:190
GTEditor Session::editGlobalTag ( const std::string &  name)

Definition at line 157 of file Session.cc.

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

157  {
158  m_session->openGTDb();
160  editor.load( name );
161  return editor;
162  }
tuple editor
Definition: idDealer.py:73
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
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:190
bool Session::existsGlobalTag ( const std::string &  name)

Definition at line 144 of file Session.cc.

References m_session.

144  {
145  m_session->openGTDb();
146  return m_session->gtSchema().gtTable().select( name );
147  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
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(), cond::persistency::importIovs(), popcon::PopCon::initialize(), and cond::persistency::migrateTag().

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

Definition at line 211 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::PayloadProxy< std::vector< cond::Time_t > >::loadPayload(), l1t::DataWriter::readObject(), and popcon::PopConSourceHandler< T >::Ref::Ref().

211  {
212  cond::Binary payloadData;
213  cond::Binary streamerInfoData;
215  if(! fetchPayloadData( payloadHash, payloadType, payloadData, streamerInfoData ) )
216  throwException( "Payload with id="+payloadHash+" has not been found in the database.",
217  "Session::fetchPayload" );
218  boost::shared_ptr<T> ret;
219  try{
220  ret = deserialize<T>( payloadType, payloadData, streamerInfoData, isOraSession() );
221  } catch ( const cond::persistency::Exception& e ){
222  std::string em(e.what());
223  throwException( "Payload of type "+payloadType+" with id "+payloadHash+" could not be loaded. "+em,"Session::fetchPayload");
224  }
225  return ret;
226  }
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:186
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 186 of file Session.cc.

References m_session.

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

189  {
190  m_session->openIovDb();
191  return m_session->iovSchema().payloadTable().select( payloadHash, payloadType, payloadData, streamerInfoData );
192  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
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:190
bool Session::isOraSession ( )

Definition at line 194 of file Session.cc.

References m_session.

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

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

Definition at line 227 of file Session.cc.

References m_session.

229  {
230  m_session->openIovDb();
231  if(! m_session->iovSchema().payloadMigrationTable().exists() ) return false;
232  return m_session->iovSchema().payloadMigrationTable().select( sourceAccount, sourceToken, payloadId );
233  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
coral::ISchema & Session::nominalSchema ( )

Definition at line 268 of file Session.cc.

References coralSession().

268  {
269  return coralSession().nominalSchema();
270  }
coral::ISessionProxy & coralSession()
Definition: Session.cc:263
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:191
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
std::string Session::parsePoolToken ( const std::string &  poolToken)

Definition at line 254 of file Session.cc.

References m_session.

254  {
255  m_session->openIovDb();
256  return m_session->iovSchema().parsePoolToken( poolToken );
257  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
GTProxy Session::readGlobalTag ( const std::string &  name)

Definition at line 164 of file Session.cc.

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

Referenced by CondDBESSource::fillTagCollectionFromGT().

164  {
165  m_session->openGTDb();
166  GTProxy proxy( m_session );
167  proxy.load( name );
168  return proxy;
169  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
GTProxy Session::readGlobalTag ( const std::string &  name,
const std::string &  preFix,
const std::string &  postFix 
)

Definition at line 171 of file Session.cc.

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

171  {
172  m_session->openGTDb();
173  GTProxy proxy( m_session );
174  proxy.load( name, preFix, postFix );
175  return proxy;
176  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
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 198 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().

198  {
199 
200  std::string payloadObjectType = cond::demangledName(typeid(payload));
201  cond::Hash ret;
202  try{
203  ret = storePayloadData( payloadObjectType, serialize( payload, isOraSession() ), creationTime );
204  } catch ( const cond::persistency::Exception& e ){
205  std::string em(e.what());
206  throwException( "Payload of type "+payloadObjectType+" could not be stored. "+em,"Session::storePayload");
207  }
208  return ret;
209  }
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:156
std::string Hash
Definition: Types.h:43
cond::Hash storePayloadData(const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
Definition: Session.cc:178
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 178 of file Session.cc.

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

Referenced by storePayload().

180  {
181  m_session->openIovDb( SessionImpl::CREATE );
182  return m_session->iovSchema().payloadTable().insertIfNew( payloadObjectType, payloadAndStreamerInfoData.first,
183  payloadAndStreamerInfoData.second, creationTime );
184  }
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
Transaction & Session::transaction ( )
void Session::updateMigratedPayload ( const std::string &  sourceAccount,
const std::string &  sourceToken,
const std::string &  payloadId 
)

Definition at line 244 of file Session.cc.

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

246  {
247  m_session->openIovDb();
248  if(! m_session->iovSchema().payloadMigrationTable().exists() )
249  throwException( "Payload Migration Table does not exist in this schema.","Session::updateMigratedPayload");
250  m_session->iovSchema().payloadMigrationTable().update( sourceAccount, sourceToken, payloadId,
251  boost::posix_time::microsec_clock::universal_time() );
252  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
void Session::updateMigrationLog ( const std::string &  sourceAccount,
const std::string &  sourceTag,
cond::MigrationStatus  status 
)

Definition at line 218 of file Session.cc.

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

220  {
221  m_session->openIovDb();
222  if(! m_session->iovSchema().tagMigrationTable().exists() )
223  throwException( "Migration Log Table does not exist in this schema.","Session::updateMigrationLog");
224  m_session->iovSchema().tagMigrationTable().updateValidationCode( sourceAccount, sourceTag, (int)status );
225  }
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:190

Member Data Documentation

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

Definition at line 191 of file Session.h.

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