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 | 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
 

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 22 of file PayloadProxy.cc.

References alignCSCRings::s, and stats.

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

Definition at line 29 of file PayloadProxy.cc.

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

31  :
32  m_doThrow(errorPolicy), m_iov(session),m_session(session) {
33  m_session.transaction().start(true);
34  m_iov.load( iovToken );
36  BasePayloadProxy::Stats s = {0,0,0,0,0,0,0,ObjIds()};
37  stats = s;
38  }
DbTransaction & transaction()
Definition: DbSession.cc:208
int commit()
commit transaction.
void load(const std::string &token)
Definition: IOVProxy.cc:200
int start(bool readOnly=false)
start transaction
std::vector< ObjId > ObjIds
Definition: PayloadProxy.h:31
cond::BasePayloadProxy::~BasePayloadProxy ( )
virtual

Definition at line 41 of file PayloadProxy.cc.

41 {}

Member Function Documentation

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

Definition at line 81 of file PayloadProxy.h.

References m_iov.

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

Definition at line 112 of file PayloadProxy.cc.

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

Referenced by make().

112  {
114  && !m_element.token().empty();
115  }
IOVElementProxy m_element
Definition: PayloadProxy.h:97
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 59 of file PayloadProxy.cc.

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

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

Definition at line 65 of file PayloadProxy.cc.

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

65  {
66  m_element.set(m_iov.iov(),n);
67  make();
69  }
IOVElementProxy m_element
Definition: PayloadProxy.h:97
IOVSequence const & iov() const
Definition: IOVProxy.cc:276
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
cond::Time_t since() const
Definition: IOVProxy.h:67
void cond::BasePayloadProxy::loadIov ( const std::string  iovToken)

Definition at line 43 of file PayloadProxy.cc.

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

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

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

Definition at line 83 of file PayloadProxy.h.

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

Definition at line 72 of file PayloadProxy.cc.

References cond::DbTransaction::commit(), alignCSCRings::e, edm::hlt::Exception, 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().

72  {
73  ++stats.nMake;
74  bool ok = false;
75  if ( isValid()) {
76  // check if (afterall) the payload is still the same...
77  if (m_element.token()==token()) return;
78  try {
79  m_session.transaction().start(true);
80  ok = load( m_session ,m_element.token());
82  if (ok) m_token = m_element.token();
83  } catch( const ora::Exception& e) {
84  if (m_doThrow) throw cond::Exception(std::string("Condition Payload loader: ")+ e.what());
85  ok = false;
86  }
87  }
88 
89  if (!ok) {
91  m_token.clear();
92  if (m_doThrow){
93  throw cond::Exception("Condition Payload loader: invalid data");
94  }
95  }
96  if (ok) {
97  ++stats.nLoad;
98  stats.ids.push_back(ObjId());
99  fillIt(stats.ids.back(),m_token, m_element.since());
100  }
101  }
IOVElementProxy m_element
Definition: PayloadProxy.h:97
virtual char const * what() const
Definition: Exception.cc:141
DbTransaction & transaction()
Definition: DbSession.cc:208
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:63
bool cond::BasePayloadProxy::refresh ( )

Definition at line 118 of file PayloadProxy.cc.

References cond::DbTransaction::commit(), 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().

118  {
119  ++stats.nRefresh;
120  m_session.transaction().start(true);
121  bool anew = m_iov.refresh();
123  if (anew) {
124  m_element = IOVElementProxy();
125  ++stats.nArefresh;
126  }
127  return anew;
128  }
IOVElementProxy m_element
Definition: PayloadProxy.h:97
DbTransaction & transaction()
Definition: DbSession.cc:208
int commit()
commit transaction.
int start(bool readOnly=false)
start transaction
bool refresh()
Definition: IOVProxy.cc:205
bool cond::BasePayloadProxy::refresh ( cond::DbSession newSession)

Definition at line 130 of file PayloadProxy.cc.

References cond::DbTransaction::commit(), 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().

130  {
131  ++stats.nReconnect;
132  m_session = newSession;
133  m_session.transaction().start(true);
134  bool anew = m_iov.refresh( m_session );
136  if (anew) {
137  m_element = IOVElementProxy();
138  ++stats.nAreconnect;
139  }
140  return anew;
141  }
IOVElementProxy m_element
Definition: PayloadProxy.h:97
DbTransaction & transaction()
Definition: DbSession.cc:208
int commit()
commit transaction.
int start(bool readOnly=false)
start transaction
bool refresh()
Definition: IOVProxy.cc:205
cond::ValidityInterval cond::BasePayloadProxy::setIntervalFor ( cond::Time_t  time)

Definition at line 104 of file PayloadProxy.cc.

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

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

Definition at line 79 of file PayloadProxy.h.

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

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

Definition at line 63 of file PayloadProxy.h.

References m_token.

Referenced by make().

63 { return m_token;}

Member Data Documentation

bool cond::BasePayloadProxy::m_doThrow
protected

Definition at line 95 of file PayloadProxy.h.

Referenced by make().

IOVElementProxy cond::BasePayloadProxy::m_element
protected

Definition at line 97 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 98 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 44 of file PayloadProxy.h.

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