CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | Private Member Functions
cond::BasePayloadProxy Class Referenceabstract

#include <PayloadProxy.h>

Inheritance diagram for cond::BasePayloadProxy:
cond::PayloadProxy< DataT > cond::PayloadProxy< std::vector< cond::Time_t > > cond::PayloadProxy< cond::KeyList >

Classes

struct  ObjId
 
struct  Stats
 

Public Types

typedef std::vector< ObjIdObjIds
 

Public Member Functions

 BasePayloadProxy (cond::DbSession &session, bool errorPolicy)
 
 BasePayloadProxy (cond::DbSession &session, const std::string &token, bool errorPolicy)
 
virtual void invalidateCache ()=0
 
IOVProxy const & iov () const
 
bool isValid () const
 
cond::ValidityInterval loadFor (cond::Time_t time)
 
cond::ValidityInterval loadFor (size_t n)
 
void loadIov (const std::string iovToken)
 
virtual void loadMore (CondGetter const &)
 
void loadTag (const std::string tag)
 
void make ()
 
bool refresh ()
 
bool refresh (cond::DbSession &newSession)
 
cond::ValidityInterval setIntervalFor (cond::Time_t time)
 
TimeType timetype () const
 
std::string const & token () const
 
virtual ~BasePayloadProxy ()
 

Public Attributes

Stats stats
 

Static Public Attributes

static Stats gstats = {0,0,0,0,0,0,0}
 

Protected Attributes

bool m_doThrow
 
IOVElementProxy m_element
 
IOVProxy m_iov
 
DbSession m_session
 
std::string m_token
 

Private Member Functions

virtual bool load (cond::DbSession &session, std::string const &token)=0
 

Detailed Description

Definition at line 23 of file PayloadProxy.h.

Member Typedef Documentation

typedef std::vector<ObjId> cond::BasePayloadProxy::ObjIds

Definition at line 31 of file PayloadProxy.h.

Constructor & Destructor Documentation

cond::BasePayloadProxy::BasePayloadProxy ( cond::DbSession session,
bool  errorPolicy 
)

Definition at line 25 of file PayloadProxy.cc.

References gstats, cond::BasePayloadProxy::Stats::nProxy, alignCSCRings::s, and stats.

26  :
27  m_doThrow(errorPolicy), m_iov(session),m_session(session) {
28  ++gstats.nProxy;
29  BasePayloadProxy::Stats s = {0,0,0,0,0,0,0,ObjIds()};
30  stats = s;
31  }
std::vector< ObjId > ObjIds
Definition: PayloadProxy.h:31
cond::BasePayloadProxy::BasePayloadProxy ( cond::DbSession session,
const std::string &  token,
bool  errorPolicy 
)

Definition at line 33 of file PayloadProxy.cc.

References cond::DbTransaction::commit(), gstats, cond::IOVProxy::load(), m_iov, m_session, cond::BasePayloadProxy::Stats::nProxy, alignCSCRings::s, cond::DbTransaction::start(), stats, and cond::DbSession::transaction().

35  :
36  m_doThrow(errorPolicy), m_iov(session),m_session(session) {
37  m_session.transaction().start(true);
38  m_iov.load( iovToken );
40  ++gstats.nProxy;
41  BasePayloadProxy::Stats s = {0,0,0,0,0,0,0,ObjIds()};
42  stats = s;
43  }
DbTransaction & transaction()
Definition: DbSession.cc:189
int commit()
commit transaction.
int start(bool readOnly=false)
start transaction
std::vector< ObjId > ObjIds
Definition: PayloadProxy.h:31
void load(const std::string &token)
Definition: IOVProxy.cc:197
cond::BasePayloadProxy::~BasePayloadProxy ( )
virtual

Definition at line 46 of file PayloadProxy.cc.

46 {}

Member Function Documentation

virtual void cond::BasePayloadProxy::invalidateCache ( )
pure virtual
IOVProxy const& cond::BasePayloadProxy::iov ( ) const
inline

Definition at line 83 of file PayloadProxy.h.

References m_iov.

83 { return m_iov;}
bool cond::BasePayloadProxy::isValid ( void  ) const

Definition at line 118 of file PayloadProxy.cc.

References cond::invalidTime(), m_element, cond::IOVElementProxy::since(), cond::IOVElementProxy::till(), and cond::IOVElementProxy::token().

Referenced by make().

118  {
120  && !m_element.token().empty();
121  }
IOVElementProxy m_element
Definition: PayloadProxy.h:99
cond::Time_t till() const
Definition: IOVProxy.h:71
std::string const & token() const
Definition: IOVProxy.h:75
const Time_t invalidTime(0)
cond::Time_t since() const
Definition: IOVProxy.h:67
virtual bool cond::BasePayloadProxy::load ( cond::DbSession session,
std::string const &  token 
)
privatepure virtual
cond::ValidityInterval cond::BasePayloadProxy::loadFor ( cond::Time_t  time)

Definition at line 64 of file PayloadProxy.cc.

References cond::IOVProxy::find(), m_element, m_iov, make(), cond::IOVElementProxy::since(), and cond::IOVElementProxy::till().

64  {
66  make();
68  }
IOVElementProxy m_element
Definition: PayloadProxy.h:99
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
cond::Time_t till() const
Definition: IOVProxy.h:71
const_iterator find(cond::Time_t time) const
Definition: IOVProxy.cc:264
cond::Time_t since() const
Definition: IOVProxy.h:67
cond::ValidityInterval cond::BasePayloadProxy::loadFor ( size_t  n)

Definition at line 70 of file PayloadProxy.cc.

References cond::IOVProxy::iov(), m_element, m_iov, make(), n, cond::IOVElementProxy::set(), cond::IOVElementProxy::since(), and cond::IOVElementProxy::till().

70  {
71  m_element.set(m_iov.iov(),n);
72  make();
74  }
IOVElementProxy m_element
Definition: PayloadProxy.h:99
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
cond::Time_t till() const
Definition: IOVProxy.h:71
void set(cond::Time_t is, cond::Time_t it, std::string const &itoken)
Definition: IOVProxy.h:59
IOVSequence const & iov() const
Definition: IOVProxy.cc:276
cond::Time_t since() const
Definition: IOVProxy.h:67
void cond::BasePayloadProxy::loadIov ( const std::string  iovToken)

Definition at line 48 of file PayloadProxy.cc.

References cond::DbTransaction::commit(), invalidateCache(), cond::IOVProxy::load(), m_iov, m_session, cond::DbTransaction::start(), and cond::DbSession::transaction().

48  {
49  m_session.transaction().start(true);
50  m_iov.load( iovToken );
53  }
DbTransaction & transaction()
Definition: DbSession.cc:189
int commit()
commit transaction.
int start(bool readOnly=false)
start transaction
virtual void invalidateCache()=0
void load(const std::string &token)
Definition: IOVProxy.cc:197
virtual void cond::BasePayloadProxy::loadMore ( CondGetter const &  )
inlinevirtual

Reimplemented in cond::PayloadProxy< cond::KeyList >.

Definition at line 85 of file PayloadProxy.h.

85 {}
void cond::BasePayloadProxy::loadTag ( const std::string  tag)
void cond::BasePayloadProxy::make ( )

Definition at line 77 of file PayloadProxy.cc.

References cond::DbTransaction::commit(), alignCSCRings::e, edm::hlt::Exception, gstats, cond::BasePayloadProxy::Stats::ids, cond::invalidTime(), isValid(), load(), m_doThrow, m_element, m_session, m_token, cond::BasePayloadProxy::Stats::nLoad, cond::BasePayloadProxy::Stats::nMake, convertSQLiteXML::ok, cond::IOVElementProxy::set(), cond::IOVElementProxy::since(), cond::DbTransaction::start(), stats, AlCaHLTBitMon_QueryRunRegistry::string, token(), cond::IOVElementProxy::token(), cond::DbSession::transaction(), and cms::Exception::what().

Referenced by loadFor().

77  {
78  ++gstats.nMake;
79  ++stats.nMake;
80  bool ok = false;
81  if ( isValid()) {
82  // check if (afterall) the payload is still the same...
83  if (m_element.token()==token()) return;
84  try {
85  m_session.transaction().start(true);
86  ok = load( m_session ,m_element.token());
88  if (ok) m_token = m_element.token();
89  } catch( const ora::Exception& e) {
90  if (m_doThrow) throw cond::Exception(std::string("Condition Payload loader: ")+ e.what());
91  ok = false;
92  }
93  }
94 
95  if (!ok) {
97  m_token.clear();
98  if (m_doThrow){
99  throw cond::Exception("Condition Payload loader: invalid data");
100  }
101  }
102  if (ok) {
103  ++gstats.nLoad; ++stats.nLoad;
104  stats.ids.push_back(ObjId());
105  fillIt(stats.ids.back(),m_token, m_element.since());
106  }
107  }
IOVElementProxy m_element
Definition: PayloadProxy.h:99
virtual char const * what() const
Definition: Exception.cc:141
DbTransaction & transaction()
Definition: DbSession.cc:189
int commit()
commit transaction.
Base exception class for the object to relational access.
Definition: Exception.h:10
int start(bool readOnly=false)
start transaction
void set(cond::Time_t is, cond::Time_t it, std::string const &itoken)
Definition: IOVProxy.h:59
std::string const & token() const
Definition: IOVProxy.h:75
const Time_t invalidTime(0)
virtual bool load(cond::DbSession &session, std::string const &token)=0
cond::Time_t since() const
Definition: IOVProxy.h:67
std::string const & token() const
Definition: PayloadProxy.h:65
bool cond::BasePayloadProxy::refresh ( )

Definition at line 124 of file PayloadProxy.cc.

References cond::DbTransaction::commit(), gstats, m_element, m_iov, m_session, cond::BasePayloadProxy::Stats::nArefresh, cond::BasePayloadProxy::Stats::nRefresh, cond::IOVProxy::refresh(), cond::DbTransaction::start(), stats, and cond::DbSession::transaction().

Referenced by Vispa.Main.TabController.TabController::checkModificationTimestamp().

124  {
126  m_session.transaction().start(true);
127  bool anew = m_iov.refresh();
129  if (anew) {
130  m_element = IOVElementProxy();
132  }
133  return anew;
134  }
IOVElementProxy m_element
Definition: PayloadProxy.h:99
DbTransaction & transaction()
Definition: DbSession.cc:189
int commit()
commit transaction.
int start(bool readOnly=false)
start transaction
bool refresh()
Definition: IOVProxy.cc:202
bool cond::BasePayloadProxy::refresh ( cond::DbSession newSession)

Definition at line 136 of file PayloadProxy.cc.

References cond::DbTransaction::commit(), gstats, m_element, m_iov, m_session, cond::BasePayloadProxy::Stats::nAreconnect, cond::BasePayloadProxy::Stats::nReconnect, cond::IOVProxy::refresh(), cond::DbTransaction::start(), stats, and cond::DbSession::transaction().

Referenced by Vispa.Main.TabController.TabController::checkModificationTimestamp().

136  {
138  m_session = newSession;
139  m_session.transaction().start(true);
140  bool anew = m_iov.refresh( m_session );
142  if (anew) {
143  m_element = IOVElementProxy();
145  }
146  return anew;
147  }
IOVElementProxy m_element
Definition: PayloadProxy.h:99
DbTransaction & transaction()
Definition: DbSession.cc:189
int commit()
commit transaction.
int start(bool readOnly=false)
start transaction
bool refresh()
Definition: IOVProxy.cc:202
cond::ValidityInterval cond::BasePayloadProxy::setIntervalFor ( cond::Time_t  time)

Definition at line 110 of file PayloadProxy.cc.

References cond::IOVProxy::find(), m_element, m_iov, cond::IOVElementProxy::since(), and cond::IOVElementProxy::till().

110  {
111  //FIXME: shall handle truncation...
112  if ( (!(time<m_element.till())) || time<m_element.since() ){
113  m_element = *m_iov.find(time);
114  }
116  }
IOVElementProxy m_element
Definition: PayloadProxy.h:99
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
cond::Time_t till() const
Definition: IOVProxy.h:71
const_iterator find(cond::Time_t time) const
Definition: IOVProxy.cc:264
cond::Time_t since() const
Definition: IOVProxy.h:67
TimeType cond::BasePayloadProxy::timetype ( ) const
inline

Definition at line 81 of file PayloadProxy.h.

References m_iov, and cond::IOVProxy::timetype().

81 { return m_iov.timetype();}
TimeType timetype() const
Definition: IOVProxy.cc:280
std::string const& cond::BasePayloadProxy::token ( ) const
inline

Definition at line 65 of file PayloadProxy.h.

References m_token.

Referenced by make().

65 { return m_token;}

Member Data Documentation

BasePayloadProxy::Stats cond::BasePayloadProxy::gstats = {0,0,0,0,0,0,0}
static

Definition at line 44 of file PayloadProxy.h.

Referenced by BasePayloadProxy(), make(), refresh(), and CondDBESSource::~CondDBESSource().

bool cond::BasePayloadProxy::m_doThrow
protected

Definition at line 97 of file PayloadProxy.h.

Referenced by make().

IOVElementProxy cond::BasePayloadProxy::m_element
protected

Definition at line 99 of file PayloadProxy.h.

Referenced by isValid(), loadFor(), make(), refresh(), and setIntervalFor().

IOVProxy cond::BasePayloadProxy::m_iov
protected
DbSession cond::BasePayloadProxy::m_session
mutableprotected

Definition at line 100 of file PayloadProxy.h.

Referenced by BasePayloadProxy(), loadIov(), loadTag(), make(), and refresh().

std::string cond::BasePayloadProxy::m_token
protected
Stats cond::BasePayloadProxy::stats

Definition at line 46 of file PayloadProxy.h.

Referenced by BasePayloadProxy(), make(), and refresh().