CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Session.cc
Go to the documentation of this file.
2 #include "SessionImpl.h"
3 //
4 
5 namespace cond {
6 
7  namespace persistency {
8 
10  m_session( &session ){
11  }
12 
14  m_session( rhs.m_session ){
15  }
16 
18  m_session = rhs.m_session;
19  return *this;
20  }
21 
22  void Transaction::start( bool readOnly ){
23  m_session->startTransaction( readOnly );
24  }
25 
28  }
29 
32  }
33 
36  }
37 
39  m_session( new SessionImpl ),
40  m_transaction( *m_session ){
41  }
42 
43  Session::Session( const std::shared_ptr<SessionImpl>& sessionImpl ):
44  m_session( sessionImpl ),
45  m_transaction( *m_session ){
46  }
47 
48  Session::Session( const Session& rhs ):
49  m_session( rhs.m_session ),
50  m_transaction( rhs.m_transaction ){
51  }
52 
54  }
55 
57  m_session = rhs.m_session;
59  return *this;
60  }
61 
63  m_session->close();
64  }
65 
67  return m_transaction;
68  }
69 
70  //
73  return m_session->transaction->iovDbExists;
74  }
75 
76  //
78  m_session->openIovDb( SessionImpl::CREATE );
79  }
80 
82  m_session->openIovDb();
83  IOVProxy proxy( m_session );
84  proxy.load( tag, full );
85  return proxy;
86  }
87 
89  m_session->openIovDb();
90  return m_session->iovSchema().tagTable().select( tag );
91  }
92 
94  m_session->openIovDb();
95  IOVProxy proxy( m_session );
96  return proxy;
97  }
98 
99  IOVEditor Session::createIov( const std::string& payloadType, const std::string& tag, cond::TimeType timeType,
100  cond::SynchronizationType synchronizationType ){
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  }
107 
109  const std::string& tag,
110  cond::TimeType timeType,
111  cond::SynchronizationType synchronizationType,
112  const boost::posix_time::ptime& creationTime ){
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  }
119 
121  cond::SynchronizationType synchronizationType ){
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");
125  std::string payloadType("");
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  }
131 
133  m_session->openIovDb();
135  editor.load( tag );
136  return editor;
137  }
138 
140  m_session->openIovDb();
141  m_session->iovSchema().iovTable().erase( tag );
142  }
143 
145  m_session->openGTDb();
146  return m_session->gtSchema().gtTable().select( name );
147  }
148 
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");
153  GTEditor editor( m_session, name );
154  return editor;
155  }
156 
158  m_session->openGTDb();
160  editor.load( name );
161  return editor;
162  }
163 
165  m_session->openGTDb();
166  GTProxy proxy( m_session );
167  proxy.load( name );
168  return proxy;
169  }
170 
171  GTProxy Session::readGlobalTag( const std::string& name, const std::string& preFix, const std::string& postFix ){
172  m_session->openGTDb();
173  GTProxy proxy( m_session );
174  proxy.load( name, preFix, postFix );
175  return proxy;
176  }
177 
179  const std::pair<Binary,Binary>& payloadAndStreamerInfoData,
180  const boost::posix_time::ptime& creationTime ){
181  m_session->openIovDb( SessionImpl::CREATE );
182  return m_session->iovSchema().payloadTable().insertIfNew( payloadObjectType, payloadAndStreamerInfoData.first,
183  payloadAndStreamerInfoData.second, creationTime );
184  }
185 
186  bool Session::fetchPayloadData( const cond::Hash& payloadHash,
187  std::string& payloadType,
188  cond::Binary& payloadData,
189  cond::Binary& streamerInfoData ){
190  m_session->openIovDb();
191  return m_session->iovSchema().payloadTable().select( payloadHash, payloadType, payloadData, streamerInfoData );
192  }
193 
195  return m_session->isOra();
196  }
197 
198  bool Session::checkMigrationLog( const std::string& sourceAccount,
199  const std::string& sourceTag,
200  std::string& destTag,
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  }
207 
208  void Session::addToMigrationLog( const std::string& sourceAccount,
209  const std::string& sourceTag,
210  const std::string& destTag,
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  }
217 
218  void Session::updateMigrationLog( const std::string& sourceAccount,
219  const std::string& sourceTag,
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  }
226 
227  bool Session::lookupMigratedPayload( const std::string& sourceAccount,
228  const std::string& sourceToken,
229  std::string& payloadId ){
230  m_session->openIovDb();
231  if(! m_session->iovSchema().payloadMigrationTable().exists() ) return false;
232  return m_session->iovSchema().payloadMigrationTable().select( sourceAccount, sourceToken, payloadId );
233  }
234 
235  void Session::addMigratedPayload( const std::string& sourceAccount,
236  const std::string& sourceToken,
237  const std::string& payloadId ){
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  }
243 
244  void Session::updateMigratedPayload( const std::string& sourceAccount,
245  const std::string& sourceToken,
246  const std::string& payloadId ){
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  }
253 
255  m_session->openIovDb();
256  return m_session->iovSchema().parsePoolToken( poolToken );
257  }
258 
260  return m_session->connectionString;
261  }
262 
263  coral::ISessionProxy& Session::coralSession(){
264  if( !m_session->coralSession.get() ) throwException( "The session is not active.","Session::coralSession");
265  return *m_session->coralSession;
266  }
267 
268  coral::ISchema& Session::nominalSchema(){
269  return coralSession().nominalSchema();
270  }
271 
273  m_transaction(transaction),m_status(true){
275  }
276 
278  if(!m_status && m_transaction.isActive() ) {
280  }
281  }
282 
283  void TransactionScope::start( bool readOnly ){
284  m_transaction.start( readOnly );
285  m_status = false;
286  }
287 
290  m_status = true;
291  }
292 
294  m_status = true;
295  }
296 
297  }
298 }
void addToMigrationLog(const std::string &sourceAccount, const std::string &sourceTag, const std::string &destinationTag, cond::MigrationStatus status)
Definition: Session.cc:208
GTEditor editGlobalTag(const std::string &name)
Definition: Session.cc:157
Transaction(SessionImpl &session)
Definition: Session.cc:9
bool existsGlobalTag(const std::string &name)
Definition: Session.cc:144
MigrationStatus
Definition: Types.h:26
void updateMigratedPayload(const std::string &sourceAccount, const std::string &sourceToken, const std::string &payloadId)
Definition: Session.cc:244
void addMigratedPayload(const std::string &sourceAccount, const std::string &sourceToken, const std::string &payloadId)
Definition: Session.cc:235
void clearIov(const std::string &tag)
Definition: Session.cc:139
void load(const std::string &tag, bool full=false)
Definition: IOVProxy.cc:124
void start(bool readOnly=true)
Definition: Session.cc:22
void load(const std::string &tag)
Definition: IOVEditor.cc:72
TransactionScope(Transaction &transaction)
Definition: Session.cc:272
Transaction & transaction()
Definition: Session.cc:66
void updateMigrationLog(const std::string &sourceAccount, const std::string &sourceTag, cond::MigrationStatus status)
Definition: Session.cc:218
TimeType
Definition: Time.h:21
IOVProxy readIov(const std::string &tag, bool full=false)
Definition: Session.cc:81
Transaction & operator=(const Transaction &rhs)
Definition: Session.cc:17
void load(const std::string &gtName, const std::string &preFix="", const std::string &postFix="")
Definition: GTProxy.cc:125
coral::ISchema & nominalSchema()
Definition: Session.cc:268
Definition: GenABIO.cc:180
void start(bool readOnly=true)
Definition: Session.cc:283
std::string Hash
Definition: Types.h:43
bool fetchPayloadData(const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
Definition: Session.cc:186
std::string connectionString()
Definition: Session.cc:259
cond::Hash storePayloadData(const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
Definition: Session.cc:178
IOVEditor editIov(const std::string &tag)
Definition: Session.cc:132
void startTransaction(bool readOnly=true)
Definition: SessionImpl.cc:117
std::string parsePoolToken(const std::string &poolToken)
Definition: Session.cc:254
IOVEditor createIovForPayload(const Hash &payloadHash, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::OFFLINE)
Definition: Session.cc:120
tuple editor
Definition: idDealer.py:73
bool existsIov(const std::string &tag)
Definition: Session.cc:88
coral::ISessionProxy & coralSession()
Definition: Session.cc:263
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::OFFLINE)
Definition: Session.h:194
bool lookupMigratedPayload(const std::string &sourceAccount, const std::string &sourceToken, std::string &payloadId)
Definition: Session.cc:227
SynchronizationType
Definition: Types.h:31
bool isTransactionActive(bool deep=true) const
Definition: SessionImpl.cc:162
GTEditor createGlobalTag(const std::string &name)
Definition: Session.cc:149
tuple status
Definition: ntuplemaker.py:245
Session & operator=(const Session &rhs)
Definition: Session.cc:56
GTProxy readGlobalTag(const std::string &name)
Definition: Session.cc:164
void load(const std::string &gtName)
Definition: GTEditor.cc:60
Transaction m_transaction
Definition: Session.h:191
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:190
bool checkMigrationLog(const std::string &sourceAccount, const std::string &sourceTag, std::string &destinationTag, cond::MigrationStatus &status)
Definition: Session.cc:198