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