CMS 3D CMS Logo

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 ),
46  }
47 
48  Session::Session( const Session& rhs ):
49  m_session( rhs.m_session ),
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  std::vector<std::tuple<cond::Time_t,cond::Hash> >& range ){
110  m_session->openIovDb();
111  boost::posix_time::ptime snapshotTime;
112  return m_session->iovSchema().iovTable().getRange( tag, begin, end, snapshotTime, range );
113  }
114 
116  cond::SynchronizationType synchronizationType ){
117  m_session->openDb();
118  if( m_session->iovSchema().tagTable().select( tag ) )
119  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIov");
120  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType );
121  return editor;
122  }
123 
125  const std::string& tag,
126  cond::TimeType timeType,
127  cond::SynchronizationType synchronizationType,
128  const boost::posix_time::ptime& creationTime ){
129  m_session->openDb();
130  if( m_session->iovSchema().tagTable().select( tag ) )
131  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIov");
132  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType, creationTime );
133  return editor;
134  }
135 
137  cond::SynchronizationType synchronizationType ){
138  m_session->openDb();
139  if( m_session->iovSchema().tagTable().select( tag ) )
140  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIovForPayload");
142  if( !m_session->iovSchema().payloadTable().getType( payloadHash, payloadType ) )
143  throwException( "The specified payloadId \""+payloadHash+"\" does not exist in the database.","Session::createIovForPayload");
144  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType );
145  return editor;
146  }
147 
149  m_session->openIovDb();
151  editor.load( tag );
152  return editor;
153  }
154 
156  m_session->openIovDb();
157  m_session->iovSchema().iovTable().erase( tag );
158  }
159 
161  m_session->openGTDb();
162  return m_session->gtSchema().gtTable().select( name );
163  }
164 
166  m_session->openGTDb();
167  if( m_session->gtSchema().gtTable().select( name ) )
168  throwException( "The specified Global Tag \""+name+"\" already exist in the database.","Session::createGlobalTag");
169  GTEditor editor( m_session, name );
170  return editor;
171  }
172 
174  m_session->openGTDb();
176  editor.load( name );
177  return editor;
178  }
179 
181  m_session->openGTDb();
182  GTProxy proxy( m_session );
183  proxy.load( name );
184  return proxy;
185  }
186 
187  GTProxy Session::readGlobalTag( const std::string& name, const std::string& preFix, const std::string& postFix ){
188  m_session->openGTDb();
189  GTProxy proxy( m_session );
190  proxy.load( name, preFix, postFix );
191  return proxy;
192  }
193 
195  const std::pair<Binary,Binary>& payloadAndStreamerInfoData,
196  const boost::posix_time::ptime& creationTime ){
197  m_session->openDb();
198  return m_session->iovSchema().payloadTable().insertIfNew( payloadObjectType, payloadAndStreamerInfoData.first,
199  payloadAndStreamerInfoData.second, creationTime );
200  }
201 
202  bool Session::fetchPayloadData( const cond::Hash& payloadHash,
204  cond::Binary& payloadData,
205  cond::Binary& streamerInfoData ){
206  m_session->openIovDb();
207  return m_session->iovSchema().payloadTable().select( payloadHash, payloadType, payloadData, streamerInfoData );
208  }
209 
211  if(!m_session->transaction.get())
212  throwException( "The transaction is not active.","Session::getRunInfo" );
213  RunInfoProxy proxy( m_session );
214  proxy.load( start, end );
215  return proxy;
216  }
217 
220  editor.init();
221  return editor;
222  }
223 
225  return m_session->connectionString;
226  }
227 
228  coral::ISessionProxy& Session::coralSession(){
229  if( !m_session->coralSession.get() ) throwException( "The session is not active.","Session::coralSession");
230  return *m_session->coralSession;
231  }
232 
233  coral::ISchema& Session::nominalSchema(){
234  return coralSession().nominalSchema();
235  }
236 
238  m_transaction(transaction),m_status(true){
240  }
241 
243  if(!m_status && m_transaction.isActive() ) {
245  }
246  }
247 
248  void TransactionScope::start( bool readOnly ){
249  m_transaction.start( readOnly );
250  m_status = false;
251  }
252 
255  m_status = true;
256  }
257 
259  m_status = true;
260  }
261 
262  }
263 }
Definition: start.py:1
GTEditor editGlobalTag(const std::string &name)
Definition: Session.cc:173
Transaction(SessionImpl &session)
Definition: Session.cc:9
bool existsGlobalTag(const std::string &name)
Definition: Session.cc:160
void clearIov(const std::string &tag)
Definition: Session.cc:155
void load(const std::string &tag, bool full=false)
Definition: IOVProxy.cc:132
void start(bool readOnly=true)
Definition: Session.cc:22
RunInfoEditor editRunInfo()
Definition: Session.cc:218
void load(Time_t low, Time_t up)
Definition: RunInfoProxy.cc:86
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.h:185
void load(const std::string &tag)
Definition: IOVEditor.cc:75
TransactionScope(Transaction &transaction)
Definition: Session.cc:237
Transaction & transaction()
Definition: Session.cc:66
TimeType
Definition: Time.h:21
IOVProxy readIov(const std::string &tag, bool full=false)
Definition: Session.cc:81
unsigned long long Time_t
Definition: Time.h:16
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:233
Definition: GenABIO.cc:180
void start(bool readOnly=true)
Definition: Session.cc:248
std::string Hash
Definition: Types.h:45
bool fetchPayloadData(const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
Definition: Session.cc:202
#define end
Definition: vmac.h:39
std::string connectionString()
Definition: Session.cc:224
cond::Hash storePayloadData(const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
Definition: Session.cc:194
IOVEditor editIov(const std::string &tag)
Definition: Session.cc:148
void startTransaction(bool readOnly=true)
Definition: SessionImpl.cc:63
bool existsIov(const std::string &tag)
Definition: Session.cc:97
coral::ISessionProxy & coralSession()
Definition: Session.cc:228
Definition: plugin.cc:24
#define begin
Definition: vmac.h:32
SynchronizationType
Definition: Types.h:29
bool getIovRange(const std::string &tag, cond::Time_t begin, cond::Time_t end, std::vector< std::tuple< cond::Time_t, cond::Hash > > &range)
Definition: Session.cc:108
bool isTransactionActive(bool deep=true) const
Definition: SessionImpl.cc:100
IOVEditor createIovForPayload(const Hash &payloadHash, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.cc:136
GTEditor createGlobalTag(const std::string &name)
Definition: Session.cc:165
Session & operator=(const Session &rhs)
Definition: Session.cc:56
GTProxy readGlobalTag(const std::string &name)
Definition: Session.cc:180
void load(const std::string &gtName)
Definition: GTEditor.cc:60
Transaction m_transaction
Definition: Session.h:182
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:181
RunInfoProxy getRunInfo(cond::Time_t start, cond::Time_t end)
Definition: Session.cc:210