CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
cond::persistency::IOVEditor Class Reference

#include <IOVEditor.h>

Public Member Functions

std::string description () const
 
cond::Time_t endOfValidity () const
 
bool flush ()
 
bool flush (const boost::posix_time::ptime &operationTime)
 
bool flush (const std::string &logText)
 
bool flush (const std::string &logText, bool forceInsertion)
 
void insert (cond::Time_t since, const cond::Hash &payloadHash, bool checkType=false)
 
void insert (cond::Time_t since, const cond::Hash &payloadHash, const boost::posix_time::ptime &insertionTime, bool checkType=false)
 
 IOVEditor ()
 
 IOVEditor (const std::shared_ptr< SessionImpl > &session)
 
 IOVEditor (const std::shared_ptr< SessionImpl > &session, const std::string &tag, cond::TimeType timeType, const std::string &payloadType, cond::SynchronizationType synchronizationType, const boost::posix_time::ptime &creationTime=boost::posix_time::microsec_clock::universal_time())
 
 IOVEditor (const IOVEditor &rhs)
 
cond::Time_t lastValidatedTime () const
 
void load (const std::string &tag)
 
IOVEditoroperator= (const IOVEditor &rhs)
 
std::string payloadType () const
 
void setDescription (const std::string &description)
 
void setEndOfValidity (cond::Time_t validity)
 
void setLastValidatedTime (cond::Time_t time)
 
void setSynchronizationType (cond::SynchronizationType synchronizationType)
 
void setValidationMode ()
 
cond::SynchronizationType synchronizationType () const
 
std::string tag () const
 
cond::TimeType timeType () const
 

Private Member Functions

void checkTransaction (const std::string &ctx)
 
bool flush (const std::string &logText, const boost::posix_time::ptime &operationTime, bool forceInsertion)
 

Private Attributes

std::shared_ptr< IOVEditorDatam_data
 
std::shared_ptr< SessionImplm_session
 

Detailed Description

Definition at line 28 of file IOVEditor.h.

Constructor & Destructor Documentation

IOVEditor::IOVEditor ( )

Definition at line 38 of file IOVEditor.cc.

38  :
39  m_data(),
40  m_session(){
41  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVEditor.h:90
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
IOVEditor::IOVEditor ( const std::shared_ptr< SessionImpl > &  session)
explicit

Definition at line 43 of file IOVEditor.cc.

43  :
44  m_data( new IOVEditorData ),
45  m_session( session ){
46  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVEditor.h:90
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
IOVEditor::IOVEditor ( const std::shared_ptr< SessionImpl > &  session,
const std::string &  tag,
cond::TimeType  timeType,
const std::string &  payloadType,
cond::SynchronizationType  synchronizationType,
const boost::posix_time::ptime &  creationTime = boost::posix_time::microsec_clock::universal_time() 
)

Definition at line 48 of file IOVEditor.cc.

References m_data, synchronizationType(), tag(), and timeType().

53  :
54  m_data( new IOVEditorData ),
55  m_session( session ){
56  m_data->tag = tag;
57  m_data->timeType = timeType;
58  m_data->payloadType = payloadObjectType;
59  m_data->synchronizationType = synchronizationType;
60  m_data->creationTime = creationTime;
61  m_data->change = true;
62  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVEditor.h:90
cond::SynchronizationType synchronizationType() const
Definition: IOVEditor.cc:100
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
cond::TimeType timeType() const
Definition: IOVEditor.cc:92
std::string tag() const
Definition: IOVEditor.cc:87
IOVEditor::IOVEditor ( const IOVEditor rhs)

Definition at line 64 of file IOVEditor.cc.

64  :
65  m_data( rhs.m_data ),
66  m_session( rhs.m_session ){
67  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVEditor.h:90
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89

Member Function Documentation

void IOVEditor::checkTransaction ( const std::string &  ctx)
private

Definition at line 263 of file IOVEditor.cc.

References m_session, and cond::persistency::throwException().

Referenced by flush(), and load().

263  {
264  if( !m_session.get() ) throwException("The session is not active.",ctx );
265  if( !m_session->isTransactionActive( false ) ) throwException("The transaction is not active.",ctx );
266  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVEditor.h:90
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::string IOVEditor::description ( ) const

Definition at line 124 of file IOVEditor.cc.

References m_data.

Referenced by setDescription().

124  {
125  return m_data.get() ? m_data->description : "";
126  }
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
cond::Time_t IOVEditor::endOfValidity ( ) const

Definition at line 112 of file IOVEditor.cc.

References m_data, and cond::time::MIN_VAL().

112  {
113  return m_data.get() ? m_data->endOfValidity : cond::time::MIN_VAL;
114  }
const Time_t MIN_VAL(0)
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
bool IOVEditor::flush ( )
bool IOVEditor::flush ( const boost::posix_time::ptime &  operationTime)

Definition at line 251 of file IOVEditor.cc.

References flush(), and AlCaHLTBitMon_QueryRunRegistry::string.

251  {
252  return flush( std::string("-"), operationTime, false );
253  }
bool IOVEditor::flush ( const std::string &  logText)

Definition at line 247 of file IOVEditor.cc.

References flush().

247  {
248  return flush( logText, boost::posix_time::microsec_clock::universal_time(), false );
249  }
bool IOVEditor::flush ( const std::string &  logText,
bool  forceInsertion 
)

Definition at line 259 of file IOVEditor.cc.

References flush().

259  {
260  return flush( logText, boost::posix_time::microsec_clock::universal_time(), forceInsertion );
261  }
bool IOVEditor::flush ( const std::string &  logText,
const boost::posix_time::ptime &  operationTime,
bool  forceInsertion 
)
private

Definition at line 168 of file IOVEditor.cc.

References writedatasetfile::action, EnergyCorrector::c, checkTransaction(), h, mps_fire::i, cond::persistency::iovSorter(), checklumidiff::l, plotBeamSpotDB::last, m_data, m_session, mps_check::msg, jetUpdater_cfi::sort, AlCaHLTBitMon_QueryRunRegistry::string, cond::SYNCH_ANY, cond::SYNCH_VALIDATION, cond::synchronizationTypeNames(), and cond::persistency::throwException().

168  {
169  bool ret = false;
170  checkTransaction( "IOVEditor::flush" );
171  std::string lt = logText;
172  if( lt.empty() ) lt = "-";
173  if( m_data->change ){
174  if( m_data->description.empty() ) throwException( "A non-empty description string is mandatory.","IOVEditor::flush" );
175  if( m_data->validationMode ) m_session->iovSchema().tagTable().setValidationMode();
176  if( !m_data->exists ){
177  // set the creation time ( only available in the migration from v1...)
178  if( m_data->creationTime.is_not_a_date_time() ) m_data->creationTime = operationTime;
179  m_session->iovSchema().tagTable().insert( m_data->tag, m_data->timeType, m_data->payloadType,
180  m_data->synchronizationType, m_data->endOfValidity,
181  m_data->description, m_data->lastValidatedTime, m_data->creationTime );
182  if( m_session->iovSchema().tagLogTable().exists() )
183  m_session->iovSchema().tagLogTable().insert( m_data->tag, m_data->creationTime, cond::getUserName(),cond::getHostName(), cond::getCommand(),
184  std::string("New tag created."),lt );
185  m_data->exists = true;
186  ret = true;
187  } else {
188  m_session->iovSchema().tagTable().update( m_data->tag, m_data->synchronizationType, m_data->endOfValidity, m_data->description,
189  m_data->lastValidatedTime, operationTime );
190  if( m_session->iovSchema().tagLogTable().exists() ){
191  std::string action("Tag header updated. Changes involve: ");
192  size_t i = 0;
193  for( auto c: m_data->changes){
194  action += c;
195  if( i==(m_data->changes.size()-1) ) action += ".";
196  else action += ", ";
197  i++;
198  }
199  m_session->iovSchema().tagLogTable().insert( m_data->tag, operationTime, cond::getUserName(),cond::getHostName(), cond::getCommand(),
200  action,lt );
201  }
202  ret = true;
203  }
204  m_data->change = false;
205  }
206  if( !m_data->iovBuffer.empty() ) {
207  std::sort(m_data->iovBuffer.begin(),m_data->iovBuffer.end(),iovSorter);
208  cond::Time_t l = std::get<0>(m_data->iovBuffer.front());
209  //We do not allow for IOV updates (i.e. insertion in the past or overriding) on tags whose syncrosization is not "ANY" or "VALIDATION".
210  //This policy is stricter than the one deployed in the Condition Upload service,
211  //which allows insertions in the past or overriding for IOVs larger than the first condition safe run for HLT ("HLT"/"EXPRESS" synchronizations) and Tier0 ("PROMPT"/"PCL").
212  //This is intended: in the C++ API we have not got a way to determine the first condition safe runs.
213  if( !forceInsertion && m_data->synchronizationType != cond::SYNCH_ANY && m_data->synchronizationType != cond::SYNCH_VALIDATION ){
214  // retrieve the last since
215  cond::Time_t last = 0;
216  cond::Hash h;
217  boost::posix_time::ptime no_time;
218  m_session->iovSchema().iovTable().getLastIov( m_data->tag, no_time, last, h );
219  // check if the min iov is greater then the last since
220  if( l <= last ){
221  std::stringstream msg;
222  msg << "Can't insert iov since "<<l<<" on the tag "<< m_data->tag<<": last since is "<<last<<
223  " and synchronization is \""<<cond::synchronizationTypeNames( m_data->synchronizationType )<<"\"";
224  throwException( msg.str(),"IOVEditor::flush");
225  }
226  }
227  // set the insertion time ( only for the migration from v1 will be available... )
228  for( auto& iov : m_data->iovBuffer ){
229  boost::posix_time::ptime& insertionTime = std::get<2>(iov);
230  if( insertionTime.is_not_a_date_time() ) insertionTime = operationTime;
231  }
232  // insert the new iovs
233  m_session->iovSchema().iovTable().insertMany( m_data->tag, m_data->iovBuffer );
234  std::stringstream msg;
235  msg << m_data->iovBuffer.size() << " iov(s) inserted.";
236  if( m_session->iovSchema().tagLogTable().exists() ){
237  m_session->iovSchema().tagLogTable().insert( m_data->tag, operationTime, cond::getUserName(), cond::getHostName(), cond::getCommand(),
238  msg.str(),lt );
239  }
240  m_data->iovBuffer.clear();
241  m_data->changes.clear();
242  ret = true;
243  }
244  return ret;
245  }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::string synchronizationTypeNames(SynchronizationType type)
Definition: Types.cc:46
void checkTransaction(const std::string &ctx)
Definition: IOVEditor.cc:263
std::shared_ptr< SessionImpl > m_session
Definition: IOVEditor.h:90
unsigned long long Time_t
Definition: Time.h:16
std::string Hash
Definition: Types.h:45
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
tuple msg
Definition: mps_check.py:285
bool iovSorter(const std::tuple< cond::Time_t, cond::Hash, boost::posix_time::ptime > &f, const std::tuple< cond::Time_t, cond::Hash, boost::posix_time::ptime > &s)
Definition: IOVEditor.cc:164
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
void IOVEditor::insert ( cond::Time_t  since,
const cond::Hash payloadHash,
bool  checkType = false 
)
void IOVEditor::insert ( cond::Time_t  since,
const cond::Hash payloadHash,
const boost::posix_time::ptime &  insertionTime,
bool  checkType = false 
)

Definition at line 157 of file IOVEditor.cc.

References m_data.

Referenced by BeautifulSoup.PageElement::append().

157  {
158  if( m_data.get() ){
159  // here the type check could be added
160  m_data->iovBuffer.push_back( std::tie( since, payloadHash, insertionTime ) );
161  }
162  }
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
cond::Time_t IOVEditor::lastValidatedTime ( ) const

Definition at line 136 of file IOVEditor.cc.

References m_data, and cond::time::MIN_VAL().

136  {
137  return m_data.get() ? m_data->lastValidatedTime : cond::time::MIN_VAL;
138  }
const Time_t MIN_VAL(0)
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
void IOVEditor::load ( const std::string &  tag)

Definition at line 75 of file IOVEditor.cc.

References checkTransaction(), m_data, m_session, tag(), and cond::throwException().

Referenced by cond::persistency::Session::editIov(), MatrixToProcess.MatrixToProcess::getProcess(), MatrixToProcess.MatrixToProcess::listAll(), and ConfigBuilder.ConfigBuilder::prepare_FILTER().

75  {
76  checkTransaction( "IOVEditor::load" );
77  // loads the current header data in memory
78  if( !m_session->iovSchema().tagTable().select( tag, m_data->timeType, m_data->payloadType, m_data->synchronizationType,
79  m_data->endOfValidity, m_data->description, m_data->lastValidatedTime ) ){
80  cond::throwException( "Tag \""+tag+"\" has not been found in the database.","IOVEditor::load");
81  }
82  m_data->tag = tag;
83  m_data->exists = true;
84  m_data->change = false;
85  }
void checkTransaction(const std::string &ctx)
Definition: IOVEditor.cc:263
std::shared_ptr< SessionImpl > m_session
Definition: IOVEditor.h:90
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:21
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
std::string tag() const
Definition: IOVEditor.cc:87
IOVEditor & IOVEditor::operator= ( const IOVEditor rhs)

Definition at line 69 of file IOVEditor.cc.

References m_data, and m_session.

69  {
70  m_data = rhs.m_data;
71  m_session = rhs.m_session;
72  return *this;
73  }
std::shared_ptr< SessionImpl > m_session
Definition: IOVEditor.h:90
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
std::string IOVEditor::payloadType ( ) const

Definition at line 96 of file IOVEditor.cc.

References m_data.

Referenced by cond::service::PoolDBOutputService::appendSinceTime(), cond::persistency::copyIov(), cond::service::PoolDBOutputService::createNewIOV(), and cond::persistency::importIovs().

96  {
97  return m_data.get() ? m_data->payloadType : "";
98  }
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
void IOVEditor::setDescription ( const std::string &  description)
void IOVEditor::setEndOfValidity ( cond::Time_t  validity)

Definition at line 116 of file IOVEditor.cc.

References m_data, and protons_cff::time.

Referenced by cond::service::PoolDBOutputService::closeIOV().

116  {
117  if( m_data.get() ) {
118  m_data->endOfValidity = time;
119  m_data->change = true;
120  m_data->changes.insert("EndOfValidity");
121  }
122  }
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
void IOVEditor::setLastValidatedTime ( cond::Time_t  time)

Definition at line 140 of file IOVEditor.cc.

References m_data, and protons_cff::time.

140  {
141  if( m_data.get() ) {
142  m_data->lastValidatedTime = time;
143  m_data->change = true;
144  m_data->changes.insert("LastValidatedTime");
145  }
146  }
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
void IOVEditor::setSynchronizationType ( cond::SynchronizationType  synchronizationType)

Definition at line 104 of file IOVEditor.cc.

References m_data, and synchronizationType().

104  {
105  if( m_data.get() ) {
106  m_data->synchronizationType = synchronizationType;
107  m_data->change = true;
108  m_data->changes.insert("SynchronizationType");
109  }
110  }
cond::SynchronizationType synchronizationType() const
Definition: IOVEditor.cc:100
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
void IOVEditor::setValidationMode ( )

Definition at line 148 of file IOVEditor.cc.

References m_data.

148  {
149  if( m_data.get() ) m_data->validationMode = true;
150  }
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
cond::SynchronizationType IOVEditor::synchronizationType ( ) const

Definition at line 100 of file IOVEditor.cc.

References m_data, and cond::SYNCH_ANY.

Referenced by IOVEditor(), and setSynchronizationType().

100  {
101  return m_data.get()? m_data->synchronizationType : cond::SYNCH_ANY ;
102  }
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
std::string IOVEditor::tag ( ) const

Definition at line 87 of file IOVEditor.cc.

References m_data.

Referenced by IOVEditor(), and load().

87  {
88  return m_data.get()? m_data->tag : "" ;
89  }
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
cond::TimeType IOVEditor::timeType ( ) const

Definition at line 92 of file IOVEditor.cc.

References cond::invalid, and m_data.

Referenced by cond::persistency::copyIov(), cond::persistency::importIovs(), and IOVEditor().

92  {
93  return m_data.get() ? m_data->timeType : cond::invalid;
94  }
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89

Member Data Documentation

std::shared_ptr<IOVEditorData> cond::persistency::IOVEditor::m_data
private
std::shared_ptr<SessionImpl> cond::persistency::IOVEditor::m_session
private

Definition at line 90 of file IOVEditor.h.

Referenced by checkTransaction(), flush(), load(), and operator=().