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  cond::SynchronizationType synchronizationType ){
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  }
119 
121  m_session->openIovDb();
123  editor.load( tag );
124  return editor;
125  }
126 
128  m_session->openIovDb();
129  m_session->iovSchema().iovTable().erase( tag );
130  }
131 
133  m_session->openGTDb();
134  return m_session->gtSchema().gtTable().select( name );
135  }
136 
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");
141  GTEditor editor( m_session, name );
142  return editor;
143  }
144 
146  m_session->openGTDb();
148  editor.load( name );
149  return editor;
150  }
151 
153  m_session->openGTDb();
154  GTProxy proxy( m_session );
155  proxy.load( name );
156  return proxy;
157  }
158 
159  GTProxy Session::readGlobalTag( const std::string& name, const std::string& preFix, const std::string& postFix ){
160  m_session->openGTDb();
161  GTProxy proxy( m_session );
162  proxy.load( name, preFix, postFix );
163  return proxy;
164  }
165 
167  const std::pair<Binary,Binary>& payloadAndStreamerInfoData,
168  const boost::posix_time::ptime& creationTime ){
169  m_session->openIovDb( SessionImpl::CREATE );
170  return m_session->iovSchema().payloadTable().insertIfNew( payloadObjectType, payloadAndStreamerInfoData.first,
171  payloadAndStreamerInfoData.second, creationTime );
172  }
173 
174  bool Session::fetchPayloadData( const cond::Hash& payloadHash,
175  std::string& payloadType,
176  cond::Binary& payloadData,
177  cond::Binary& streamerInfoData ){
178  m_session->openIovDb();
179  return m_session->iovSchema().payloadTable().select( payloadHash, payloadType, payloadData, streamerInfoData );
180  }
181 
183  return m_session->isOra();
184  }
185 
186  bool Session::checkMigrationLog( const std::string& sourceAccount,
187  const std::string& sourceTag,
188  std::string& destTag,
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  }
195 
196  void Session::addToMigrationLog( const std::string& sourceAccount,
197  const std::string& sourceTag,
198  const std::string& destTag,
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  }
205 
206  void Session::updateMigrationLog( const std::string& sourceAccount,
207  const std::string& sourceTag,
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  }
214 
216  return m_session->connectionString;
217  }
218 
219  coral::ISessionProxy& Session::coralSession(){
220  if( !m_session->coralSession.get() ) throwException( "The session is not active.","Session::coralSession");
221  return *m_session->coralSession;
222  }
223 
224  coral::ISchema& Session::nominalSchema(){
225  return coralSession().nominalSchema();
226  }
227 
229  m_transaction(transaction),m_status(true){
231  }
232 
234  if(!m_status && m_transaction.isActive() ) {
236  }
237  }
238 
239  void TransactionScope::start( bool readOnly ){
240  m_transaction.start( readOnly );
241  m_status = false;
242  }
243 
246  m_status = true;
247  }
248 
250  m_status = true;
251  }
252 
253  }
254 }
void addToMigrationLog(const std::string &sourceAccount, const std::string &sourceTag, const std::string &destinationTag, cond::MigrationStatus status)
Definition: Session.cc:196
GTEditor editGlobalTag(const std::string &name)
Definition: Session.cc:145
Transaction(SessionImpl &session)
Definition: Session.cc:9
bool existsGlobalTag(const std::string &name)
Definition: Session.cc:132
MigrationStatus
Definition: Types.h:26
void clearIov(const std::string &tag)
Definition: Session.cc:127
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:69
TransactionScope(Transaction &transaction)
Definition: Session.cc:228
Transaction & transaction()
Definition: Session.cc:66
void updateMigrationLog(const std::string &sourceAccount, const std::string &sourceTag, cond::MigrationStatus status)
Definition: Session.cc:206
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:224
Definition: GenABIO.cc:180
void start(bool readOnly=true)
Definition: Session.cc:239
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:174
std::string connectionString()
Definition: Session.cc:215
cond::Hash storePayloadData(const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
Definition: Session.cc:166
IOVEditor editIov(const std::string &tag)
Definition: Session.cc:120
void startTransaction(bool readOnly=true)
Definition: SessionImpl.cc:111
IOVEditor createIovForPayload(const Hash &payloadHash, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::OFFLINE)
Definition: Session.cc:108
tuple editor
Definition: idDealer.py:73
bool existsIov(const std::string &tag)
Definition: Session.cc:88
coral::ISessionProxy & coralSession()
Definition: Session.cc:219
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::OFFLINE)
Definition: Session.h:178
SynchronizationType
Definition: Types.h:31
bool isTransactionActive(bool deep=true) const
Definition: SessionImpl.cc:156
GTEditor createGlobalTag(const std::string &name)
Definition: Session.cc:137
tuple status
Definition: ntuplemaker.py:245
Session & operator=(const Session &rhs)
Definition: Session.cc:56
GTProxy readGlobalTag(const std::string &name)
Definition: Session.cc:152
void load(const std::string &gtName)
Definition: GTEditor.cc:60
Transaction m_transaction
Definition: Session.h:175
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:174
bool checkMigrationLog(const std::string &sourceAccount, const std::string &sourceTag, std::string &destinationTag, cond::MigrationStatus &status)
Definition: Session.cc:186