test
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->openDb();
79  }
80 
82  m_session->openIovDb();
83  IOVProxy proxy( m_session );
84  proxy.load( tag, full );
85  return proxy;
86  }
87 
89  const boost::posix_time::ptime& snapshottime,
90  bool full ){
91  m_session->openIovDb();
92  IOVProxy proxy( m_session );
93  proxy.load( tag, snapshottime, full );
94  return proxy;
95  }
96 
98  m_session->openIovDb();
99  return m_session->iovSchema().tagTable().select( tag );
100  }
101 
103  m_session->openIovDb();
104  IOVProxy proxy( m_session );
105  return proxy;
106  }
107 
109  cond::SynchronizationType synchronizationType ){
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  }
116 
118  const std::string& tag,
119  cond::TimeType timeType,
120  cond::SynchronizationType synchronizationType,
121  const boost::posix_time::ptime& creationTime ){
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  }
128 
130  cond::SynchronizationType synchronizationType ){
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  }
140 
142  m_session->openIovDb();
144  editor.load( tag );
145  return editor;
146  }
147 
149  m_session->openIovDb();
150  m_session->iovSchema().iovTable().erase( tag );
151  }
152 
154  m_session->openGTDb();
155  return m_session->gtSchema().gtTable().select( name );
156  }
157 
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");
162  GTEditor editor( m_session, name );
163  return editor;
164  }
165 
167  m_session->openGTDb();
169  editor.load( name );
170  return editor;
171  }
172 
174  m_session->openGTDb();
175  GTProxy proxy( m_session );
176  proxy.load( name );
177  return proxy;
178  }
179 
180  GTProxy Session::readGlobalTag( const std::string& name, const std::string& preFix, const std::string& postFix ){
181  m_session->openGTDb();
182  GTProxy proxy( m_session );
183  proxy.load( name, preFix, postFix );
184  return proxy;
185  }
186 
188  const std::pair<Binary,Binary>& payloadAndStreamerInfoData,
189  const boost::posix_time::ptime& creationTime ){
190  m_session->openDb();
191  return m_session->iovSchema().payloadTable().insertIfNew( payloadObjectType, payloadAndStreamerInfoData.first,
192  payloadAndStreamerInfoData.second, creationTime );
193  }
194 
195  bool Session::fetchPayloadData( const cond::Hash& payloadHash,
197  cond::Binary& payloadData,
198  cond::Binary& streamerInfoData ){
199  m_session->openIovDb();
200  return m_session->iovSchema().payloadTable().select( payloadHash, payloadType, payloadData, streamerInfoData );
201  }
202 
204  return m_session->isOra();
205  }
206 
207  bool Session::checkMigrationLog( const std::string& sourceAccount,
208  const std::string& sourceTag,
209  std::string& destTag,
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  }
216 
217  void Session::addToMigrationLog( const std::string& sourceAccount,
218  const std::string& sourceTag,
219  const std::string& destTag,
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  }
226 
227  void Session::updateMigrationLog( const std::string& sourceAccount,
228  const std::string& sourceTag,
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  }
235 
236  bool Session::lookupMigratedPayload( const std::string& sourceAccount,
237  const std::string& sourceToken,
238  std::string& payloadId ){
239  m_session->openIovDb();
240  if(! m_session->iovSchema().payloadMigrationTable().exists() ) return false;
241  return m_session->iovSchema().payloadMigrationTable().select( sourceAccount, sourceToken, payloadId );
242  }
243 
244  void Session::addMigratedPayload( 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() ) m_session->iovSchema().payloadMigrationTable().create();
249  m_session->iovSchema().payloadMigrationTable().insert( sourceAccount, sourceToken, payloadId,
250  boost::posix_time::microsec_clock::universal_time() );
251  }
252 
253  void Session::updateMigratedPayload( const std::string& sourceAccount,
254  const std::string& sourceToken,
255  const std::string& payloadId ){
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  }
262 
264  m_session->openIovDb();
265  return m_session->iovSchema().parsePoolToken( poolToken );
266  }
267 
269  return m_session->connectionString;
270  }
271 
272  coral::ISessionProxy& Session::coralSession(){
273  if( !m_session->coralSession.get() ) throwException( "The session is not active.","Session::coralSession");
274  return *m_session->coralSession;
275  }
276 
277  coral::ISchema& Session::nominalSchema(){
278  return coralSession().nominalSchema();
279  }
280 
282  m_transaction(transaction),m_status(true){
284  }
285 
287  if(!m_status && m_transaction.isActive() ) {
289  }
290  }
291 
292  void TransactionScope::start( bool readOnly ){
293  m_transaction.start( readOnly );
294  m_status = false;
295  }
296 
299  m_status = true;
300  }
301 
303  m_status = true;
304  }
305 
306  }
307 }
void addToMigrationLog(const std::string &sourceAccount, const std::string &sourceTag, const std::string &destinationTag, cond::MigrationStatus status)
Definition: Session.cc:217
GTEditor editGlobalTag(const std::string &name)
Definition: Session.cc:166
Transaction(SessionImpl &session)
Definition: Session.cc:9
bool existsGlobalTag(const std::string &name)
Definition: Session.cc:153
MigrationStatus
Definition: Types.h:26
void updateMigratedPayload(const std::string &sourceAccount, const std::string &sourceToken, const std::string &payloadId)
Definition: Session.cc:253
void addMigratedPayload(const std::string &sourceAccount, const std::string &sourceToken, const std::string &payloadId)
Definition: Session.cc:244
void clearIov(const std::string &tag)
Definition: Session.cc:148
void load(const std::string &tag, bool full=false)
Definition: IOVProxy.cc:130
void start(bool readOnly=true)
Definition: Session.cc:22
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.h:198
void load(const std::string &tag)
Definition: IOVEditor.cc:72
TransactionScope(Transaction &transaction)
Definition: Session.cc:281
Transaction & transaction()
Definition: Session.cc:66
void updateMigrationLog(const std::string &sourceAccount, const std::string &sourceTag, cond::MigrationStatus status)
Definition: Session.cc:227
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:130
coral::ISchema & nominalSchema()
Definition: Session.cc:277
Definition: GenABIO.cc:180
void start(bool readOnly=true)
Definition: Session.cc:292
std::string Hash
Definition: Types.h:47
bool fetchPayloadData(const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
Definition: Session.cc:195
std::string connectionString()
Definition: Session.cc:268
cond::Hash storePayloadData(const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
Definition: Session.cc:187
IOVEditor editIov(const std::string &tag)
Definition: Session.cc:141
void startTransaction(bool readOnly=true)
Definition: SessionImpl.cc:112
std::string parsePoolToken(const std::string &poolToken)
Definition: Session.cc:263
tuple editor
Definition: idDealer.py:73
bool existsIov(const std::string &tag)
Definition: Session.cc:97
coral::ISessionProxy & coralSession()
Definition: Session.cc:272
bool lookupMigratedPayload(const std::string &sourceAccount, const std::string &sourceToken, std::string &payloadId)
Definition: Session.cc:236
SynchronizationType
Definition: Types.h:31
bool isTransactionActive(bool deep=true) const
Definition: SessionImpl.cc:157
IOVEditor createIovForPayload(const Hash &payloadHash, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.cc:129
GTEditor createGlobalTag(const std::string &name)
Definition: Session.cc:158
tuple status
Definition: ntuplemaker.py:245
Session & operator=(const Session &rhs)
Definition: Session.cc:56
GTProxy readGlobalTag(const std::string &name)
Definition: Session.cc:173
void load(const std::string &gtName)
Definition: GTEditor.cc:60
Transaction m_transaction
Definition: Session.h:195
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:194
bool checkMigrationLog(const std::string &sourceAccount, const std::string &sourceTag, std::string &destinationTag, cond::MigrationStatus &status)
Definition: Session.cc:207