CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
cond::service::PoolDBOutputService Class Reference

#include <PoolDBOutputService.h>

Inheritance diagram for cond::service::PoolDBOutputService:
cond::service::OnlineDBOutputService

Classes

struct  Record
 

Public Member Functions

template<typename T >
void appendOneIOV (const T &payload, cond::Time_t sinceTime, const std::string &recordName)
 
bool appendSinceTime (const std::string &payloadId, cond::Time_t sinceTime, const std::string &recordName)
 
cond::Time_t beginOfTime () const
 
void closeIOV (Time_t lastTill, const std::string &recordName)
 
void commitTransaction ()
 
void createNewIOV (const std::string &firstPayloadId, cond::Time_t firstSinceTime, const std::string &recordName)
 
template<typename T >
void createOneIOV (const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
 
cond::Time_t currentTime () const
 
cond::Time_t endOfTime () const
 
void eraseSinceTime (const std::string &payloadId, cond::Time_t sinceTime, const std::string &recordName)
 
void forceInit ()
 
bool isNewTagRequest (const std::string &recordName)
 
void lockRecords ()
 
cond::persistency::Loggerlogger ()
 
const RecordlookUpRecord (const std::string &recordName)
 
cond::persistency::Session newReadOnlySession (const std::string &connectionString, const std::string &transactionId)
 
 PoolDBOutputService (const edm::ParameterSet &iConfig, edm::ActivityRegistry &iAR)
 
void postEndJob ()
 
void releaseLocks ()
 
cond::persistency::Session session () const
 
void setLogHeaderForRecord (const std::string &recordName, const std::string &provenance, const std::string &usertext)
 
void startTransaction ()
 
std::string tag (const std::string &recordName)
 
bool tagInfo (const std::string &recordName, cond::TagInfo_t &result)
 
template<typename T >
void writeMany (const std::map< Time_t, std::shared_ptr< T > > &iovAndPayloads, const std::string &recordName)
 
template<typename T >
Hash writeOneIOV (const T &payload, Time_t time, const std::string &recordName)
 
virtual ~PoolDBOutputService ()
 

Private Member Functions

bool appendSinceTime (const std::string &payloadId, cond::Time_t sinceTime, const Record &record)
 
void createNewIOV (const std::string &firstPayloadId, const std::string payloadType, cond::Time_t firstSinceTime, Record &record)
 
void doCommitTransaction ()
 
void doStartTransaction ()
 
void fillRecord (edm::ParameterSet &pset, const std::string &gTimeTypeStr)
 
RecordgetRecord (const std::string &recordName)
 
bool getTagInfo (const std::string &recordName, cond::TagInfo_t &result)
 
bool initDB (bool readOnly=false)
 
cond::UserLogInfolookUpUserLogInfo (const std::string &recordName)
 
void postModuleEvent (edm::StreamContext const &, edm::ModuleCallingContext const &)
 
void preEventProcessing (edm::StreamContext const &)
 
void preGlobalBeginLumi (edm::GlobalContext const &)
 
void preGlobalBeginRun (edm::GlobalContext const &)
 
void preModuleEvent (edm::StreamContext const &, edm::ModuleCallingContext const &)
 

Private Attributes

bool m_autoCommit
 
cond::persistency::ConnectionPool m_connection
 
std::vector< cond::Time_tm_currentTimes
 
bool m_dbInitialised
 
cond::persistency::Logger m_logger
 
std::map< std::string, cond::UserLogInfom_logheaders
 
std::recursive_mutex m_mutex
 
std::map< std::string, Recordm_records
 
cond::persistency::Session m_session
 
cond::TimeType m_timetype
 
bool m_transactionActive
 
unsigned int m_writeTransactionDelay = 0
 

Detailed Description

Definition at line 33 of file PoolDBOutputService.h.

Constructor & Destructor Documentation

◆ PoolDBOutputService()

PoolDBOutputService::PoolDBOutputService ( const edm::ParameterSet iConfig,
edm::ActivityRegistry iAR 
)

Definition at line 39 of file PoolDBOutputService.cc.

40  : m_logger(iConfig.getUntrackedParameter<std::string>("jobName", "DBOutputService")),
42  m_session(),
43  m_transactionActive(false),
44  m_dbInitialised(false),
45  m_records(),
46  m_logheaders() {
47  std::string timetypestr = iConfig.getUntrackedParameter<std::string>("timetype", "runnumber");
49  m_autoCommit = iConfig.getUntrackedParameter<bool>("autoCommit", true);
50  m_writeTransactionDelay = iConfig.getUntrackedParameter<unsigned int>("writeTransactionDelay", 0);
51  edm::ParameterSet connectionPset = iConfig.getParameter<edm::ParameterSet>("DBParameters");
52  m_connection.setParameters(connectionPset);
57  bool saveLogsOnDb = iConfig.getUntrackedParameter<bool>("saveLogsOnDB", false);
58  if (saveLogsOnDb)
60  // implicit start
61  //doStartTransaction();
62  typedef std::vector<edm::ParameterSet> Parameters;
63  Parameters toPut = iConfig.getParameter<Parameters>("toPut");
64  for (Parameters::iterator itToPut = toPut.begin(); itToPut != toPut.end(); ++itToPut)
65  fillRecord(*itToPut, timetypestr);
66 
68  iAR.watchPreallocate(
69  [this](edm::service::SystemBounds const& iBounds) { m_currentTimes.resize(iBounds.maxNumberOfStreams()); });
70  if (m_timetype == cond::timestamp) { //timestamp
74  } else if (m_timetype == cond::runnumber) { //runnumber
75  //NOTE: this assumes only one run is being processed at a time.
76  // This is true for 7_1_X but plan are to allow multiple in flight at a time
77  s_streamIndex = 0;
79  } else if (m_timetype == cond::lumiid) {
80  //NOTE: this assumes only one lumi is being processed at a time.
81  // This is true for 7_1_X but plan are to allow multiple in flight at a time
82  s_streamIndex = 0;
84  }
85 }
static thread_local int s_streamIndex
void setLogDestination(Logger &logger)
void watchPreEvent(PreEvent::slot_type const &iSlot)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void watchPreallocate(Preallocate::slot_type const &iSlot)
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
void preEventProcessing(edm::StreamContext const &)
void fillRecord(edm::ParameterSet &pset, const std::string &gTimeTypeStr)
void watchPreModuleEvent(PreModuleEvent::slot_type const &iSlot)
std::map< std::string, cond::UserLogInfo > m_logheaders
unsigned int maxNumberOfStreams() const
Definition: SystemBounds.h:35
void watchPreGlobalBeginLumi(PreGlobalBeginLumi::slot_type const &iSlot)
std::vector< cond::Time_t > m_currentTimes
void watchPostModuleEvent(PostModuleEvent::slot_type const &iSlot)
void preGlobalBeginLumi(edm::GlobalContext const &)
void setParameters(const edm::ParameterSet &connectionPset)
T getUntrackedParameter(std::string const &, T const &) const
vector< ParameterSet > Parameters
TimeType timeTypeFromName(const std::string &name)
Definition: Time.cc:25
cond::persistency::ConnectionPool m_connection
Session createSession(const std::string &connectionString, bool writeCapable=false)
cond::persistency::Session m_session
std::map< std::string, Record > m_records
void watchPreGlobalBeginRun(PreGlobalBeginRun::slot_type const &iSlot)
cond::persistency::Logger m_logger
void preGlobalBeginRun(edm::GlobalContext const &)
void postModuleEvent(edm::StreamContext const &, edm::ModuleCallingContext const &)
void setDbDestination(const std::string &connectionString)
Definition: Logger.cc:66
void preModuleEvent(edm::StreamContext const &, edm::ModuleCallingContext const &)

◆ ~PoolDBOutputService()

PoolDBOutputService::~PoolDBOutputService ( )
virtual

Definition at line 239 of file PoolDBOutputService.cc.

239 {}

Member Function Documentation

◆ appendOneIOV()

template<typename T >
void cond::service::PoolDBOutputService::appendOneIOV ( const T payload,
cond::Time_t  sinceTime,
const std::string &  recordName 
)
inline

Definition at line 183 of file PoolDBOutputService.h.

References appendSinceTime(), doCommitTransaction(), doStartTransaction(), cppFunctionSkipper::exception, initDB(), CommonMethods::lock(), lookUpRecord(), m_autoCommit, m_mutex, m_session, jetsAK4_Puppi_cff::payload, cond::persistency::Session::storePayload(), AlCaHLTBitMon_QueryRunRegistry::string, cond::throwException(), and cond::persistency::Session::transaction().

Referenced by SiStripPedestalsBuilder::analyze(), SiStripThresholdBuilder::analyze(), SiStripSummaryBuilder::analyze(), SiStripNoisesBuilder::analyze(), DBWriter::analyze(), SiStripApvGainBuilder::analyze(), SiStripDetVOffFakeBuilder::analyze(), cms::SiPixelPerformanceSummaryBuilder::analyze(), SiPixelLorentzAngleDB::analyze(), SiPixelVCalDB::analyze(), SiPixelDynamicInefficiencyDB::analyze(), WriteEcalMiscalibConstants::analyze(), WriteEcalMiscalibConstantsMC::analyze(), SiStripNoiseNormalizedWithApvGainBuilder::analyze(), SiStripApvGainBuilderFromTag::analyze(), SiPixelCalibConfigurationObjectMaker::analyze(), EcalTestDevDB::analyze(), cms::SiPixelCondObjBuilder::analyze(), cms::SiPixelCondObjForHLTBuilder::analyze(), cms::SiPixelCondObjOfflineBuilder::analyze(), SiStripChannelGainFromDBMiscalibrator::analyze(), SiStripNoisesFromDBMiscalibrator::analyze(), SiStripApvGainFromFileBuilder::analyze(), SiStripFedCablingBuilder::beginRun(), SiPixelGainCalibScaler::computeAndStorePalyoads(), CocoaDBMgr::DumpCocoaResults(), BeamSpotWrite2DB::endJob(), StoreESCondition::endJob(), BeamSpotOnlineRecordsWriter::endJob(), StoreEcalCondition::endJob(), SiStripFedCablingManipulator::endRun(), SiPixelGainCalibrationReadDQMFile::fillDatabase(), SiPixelGainCalibrationRejectNoisyAndDead::fillDatabase(), SiStripBadChannelBuilder::getNewObject(), SiPhase2BadStripChannelBuilder::getNewObject(), CaloGeometryDBWriter::write(), BeamFitter::write2DB(), and CaloGeometryDBWriter::writeIndexed().

183  {
184  std::lock_guard<std::recursive_mutex> lock(m_mutex);
187  try {
188  bool dbexists = this->initDB(true);
189  if (!dbexists) {
190  cond::throwException(std::string("Target database does not exist."),
191  "PoolDBOutputService::appendSinceTime");
192  }
193  auto& myrecord = this->lookUpRecord(recordName);
194  if (myrecord.m_isNewTag) {
195  cond::throwException(std::string("Cannot append to non-existing tag ") + myrecord.m_tag,
196  "PoolDBOutputService::appendSinceTime");
197  }
198  appendSinceTime(m_session.storePayload(payload), sinceTime, myrecord);
199  if (m_autoCommit) {
201  }
202  } catch (const std::exception& er) {
203  cond::throwException(std::string(er.what()), "PoolDBOutputService::appendSinceTime");
204  }
205  scope.close();
206  }
const Record & lookUpRecord(const std::string &recordName)
Transaction & transaction()
Definition: Session.cc:52
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18
cond::persistency::Session m_session
bool appendSinceTime(const std::string &payloadId, cond::Time_t sinceTime, const std::string &recordName)
cond::Hash storePayload(const T &payload, const boost::posix_time::ptime &creationTime=boost::posix_time::microsec_clock::universal_time())
Definition: Session.h:186

◆ appendSinceTime() [1/2]

bool PoolDBOutputService::appendSinceTime ( const std::string &  payloadId,
cond::Time_t  sinceTime,
const std::string &  recordName 
)

Definition at line 312 of file PoolDBOutputService.cc.

References cppFunctionSkipper::exception, CommonMethods::lock(), align_cfg::recordName, runTheMatrix::ret, AlCaHLTBitMon_QueryRunRegistry::string, cond::throwException(), and protons_cff::time.

Referenced by appendOneIOV(), l1t::DataWriter::updateIOV(), l1t::DataWriterExt::updateIOV(), and writeOneIOV().

314  {
315  bool ret = false;
316  std::lock_guard<std::recursive_mutex> lock(m_mutex);
319  try {
320  bool dbexists = this->initDB();
321  if (!dbexists) {
322  cond::throwException(std::string("Target database does not exist."), "PoolDBOutputService::appendSinceTime");
323  }
324  auto& myrecord = this->lookUpRecord(recordName);
325  if (myrecord.m_isNewTag) {
326  cond::throwException(std::string("Cannot append to non-existing tag ") + myrecord.m_tag,
327  "PoolDBOutputService::appendSinceTime");
328  }
329  ret = appendSinceTime(payloadId, time, myrecord);
330  if (m_autoCommit) {
332  }
333  } catch (const std::exception& er) {
334  cond::throwException(std::string(er.what()), "PoolDBOutputService::appendSinceTime");
335  }
336  scope.close();
337  return ret;
338 }
const Record & lookUpRecord(const std::string &recordName)
ret
prodAgent to be discontinued
Transaction & transaction()
Definition: Session.cc:52
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18
cond::persistency::Session m_session
bool appendSinceTime(const std::string &payloadId, cond::Time_t sinceTime, const std::string &recordName)

◆ appendSinceTime() [2/2]

bool PoolDBOutputService::appendSinceTime ( const std::string &  payloadId,
cond::Time_t  sinceTime,
const Record record 
)
private

Definition at line 341 of file PoolDBOutputService.cc.

References a, cppFunctionSkipper::exception, cond::persistency::IOVEditor::flush(), cond::persistency::IOVEditor::insert(), cond::service::PoolDBOutputService::Record::m_idName, cond::service::PoolDBOutputService::Record::m_tag, AlCaHLTBitMon_QueryRunRegistry::string, cond::throwException(), and protons_cff::time.

343  {
344  m_logger.logInfo() << "Updating existing tag " << myrecord.m_tag << ", adding iov with since " << time;
345  try {
346  cond::persistency::IOVEditor editor = m_session.editIov(myrecord.m_tag);
347  editor.insert(time, payloadId);
348  cond::UserLogInfo a = this->lookUpUserLogInfo(myrecord.m_idName);
349  editor.flush(a.usertext);
350  } catch (const std::exception& er) {
351  cond::throwException(std::string(er.what()), "PoolDBOutputService::appendSinceTime");
352  }
353  return true;
354 }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18
cond::persistency::Session m_session
cond::persistency::Logger m_logger
IOVEditor editIov(const std::string &tag)
Definition: Session.cc:130
void insert(cond::Time_t since, const cond::Hash &payloadHash, bool checkType=false)
Definition: IOVEditor.cc:159
double a
Definition: hdecay.h:119
EchoedLogStream< edm::LogInfo > logInfo()
Definition: Logger.cc:157
cond::UserLogInfo & lookUpUserLogInfo(const std::string &recordName)

◆ beginOfTime()

cond::Time_t PoolDBOutputService::beginOfTime ( ) const

Definition at line 258 of file PoolDBOutputService.cc.

References cond::TimeTypeSpecs::beginValue, and cond::timeTypeSpecs.

Referenced by L1KeyListWriter::analyze(), L1KeyWriter::analyze(), L1TMuonOverlapParamsWriter::analyze(), L1TCaloParamsUpdater::analyze(), SiStripPedestalsBuilder::analyze(), SiStripThresholdBuilder::analyze(), L1TCaloStage2ParamsWriter::analyze(), L1TGlobalPrescalesVetosWriter::analyze(), L1TMuonGlobalParamsWriter::analyze(), SiStripNoisesBuilder::analyze(), SiStripSummaryBuilder::analyze(), L1MenuWriter::analyze(), L1TMuonEndCapForestWriter::analyze(), L1TMuonEndCapParamsWriter::analyze(), DBWriter::analyze(), SiStripApvGainBuilder::analyze(), L1TMuonBarrelParamsWriter::analyze(), SurveyInputTrackerFromDB::analyze(), L1TMuonOverlapFwVersionTester::analyze(), EcalPFRecHitThresholdsMaker::analyze(), SiStripDetVOffFakeBuilder::analyze(), GBRForestWriter::analyze(), cms::SiPixelPerformanceSummaryBuilder::analyze(), PPSGeometryBuilder::analyze(), SiPixelLorentzAngleDB::analyze(), SiPixelVCalDB::analyze(), SiPixelDynamicInefficiencyDB::analyze(), WriteEcalMiscalibConstantsMC::analyze(), WriteEcalMiscalibConstants::analyze(), SiStripNoiseNormalizedWithApvGainBuilder::analyze(), SiStripApvGainBuilderFromTag::analyze(), SiPixelGenErrorDBObjectUploader::analyze(), SiPixel2DTemplateDBObjectUploader::analyze(), SiPixelCalibConfigurationObjectMaker::analyze(), SiPixelTemplateDBObjectUploader::analyze(), EcalTestDevDB::analyze(), cms::SiPixelCondObjBuilder::analyze(), cms::SiPixelCondObjOfflineBuilder::analyze(), cms::SiPixelCondObjForHLTBuilder::analyze(), TrackerGeometryCompare::analyze(), TrackerSystematicMisalignments::analyze(), SiStripApvGainFromFileBuilder::analyze(), XMLGeometryBuilder::beginJob(), PTrackerAdditionalParametersPerDetDBBuilder::beginRun(), PTrackerParametersDBBuilder::beginRun(), HcalParametersDBBuilder::beginRun(), PHGCalParametersDBBuilder::beginRun(), RPCRecoIdealDBLoader::beginRun(), CSCRecoIdealDBLoader::beginRun(), ME0RecoIdealDBLoader::beginRun(), DTRecoIdealDBLoader::beginRun(), GEMRecoIdealDBLoader::beginRun(), PGeometricDetBuilder::beginRun(), SiStripFedCablingBuilder::beginRun(), SiPixelGainCalibScaler::computeAndStorePalyoads(), ESDBCopy::copyToDB(), EcalTPGDBCopy::copyToDB(), EcalDBCopy::copyToDB(), SiStripBadStripFromQualityDBWriter::dqmEndJob(), CocoaDBMgr::DumpCocoaResults(), BeamSpotWrite2DB::endJob(), StoreESCondition::endJob(), BeamProfile2DB::endJob(), BeamSpotOnlineRecordsWriter::endJob(), StoreEcalCondition::endJob(), SiStripFedCablingManipulator::endRun(), DummyCondDBWriter< TObject, TObjectO, TRecord >::endRun(), LaserAlignment::endRunProduce(), SiPixelGainCalibrationReadDQMFile::fillDatabase(), SiPixelGainCalibrationRejectNoisyAndDead::fillDatabase(), SiStripBadChannelBuilder::getNewObject(), SiPhase2BadStripChannelBuilder::getNewObject(), EcalLaserCondTools::processIov(), MuonMisalignedProducer::saveToDB(), ConditionDBWriter< SiStripApvGain >::storeOnDb(), l1t::DataWriter::updateIOV(), l1t::DataWriterExt::updateIOV(), CaloGeometryDBWriter::write(), BeamFitter::write2DB(), CaloGeometryDBWriter::writeIndexed(), and DTCalibDBUtils::writeToDB().

const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:16
Time_t beginValue
Definition: Time.h:41

◆ closeIOV()

void PoolDBOutputService::closeIOV ( Time_t  lastTill,
const std::string &  recordName 
)

Definition at line 405 of file PoolDBOutputService.cc.

References cppFunctionSkipper::exception, cond::persistency::IOVEditor::flush(), CommonMethods::lock(), align_cfg::recordName, cond::persistency::IOVEditor::setEndOfValidity(), AlCaHLTBitMon_QueryRunRegistry::string, and cond::throwException().

Referenced by popcon::PopCon::finalize().

405  {
406  std::lock_guard<std::recursive_mutex> lock(m_mutex);
409  try {
410  bool dbexists = this->initDB();
411  if (!dbexists) {
412  cond::throwException(std::string("Target database does not exist."), "PoolDBOutputService::closeIOV");
413  }
414  auto& myrecord = lookUpRecord(recordName);
415  if (myrecord.m_isNewTag) {
416  cond::throwException(std::string("Cannot close non-existing tag ") + myrecord.m_tag,
417  "PoolDBOutputService::closeIOV");
418  }
419  m_logger.logInfo() << "Updating existing tag " << myrecord.m_tag << ", closing with end of validity " << lastTill;
420  cond::persistency::IOVEditor editor = m_session.editIov(myrecord.m_tag);
421  editor.setEndOfValidity(lastTill);
422  editor.flush("Tag closed.");
423  if (m_autoCommit) {
425  }
426  } catch (const std::exception& er) {
427  cond::throwException(std::string(er.what()), "PoolDBOutputService::closeIOV");
428  }
429  scope.close();
430 }
const Record & lookUpRecord(const std::string &recordName)
Transaction & transaction()
Definition: Session.cc:52
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18
cond::persistency::Session m_session
cond::persistency::Logger m_logger
IOVEditor editIov(const std::string &tag)
Definition: Session.cc:130
void setEndOfValidity(cond::Time_t validity)
Definition: IOVEditor.cc:129
EchoedLogStream< edm::LogInfo > logInfo()
Definition: Logger.cc:157

◆ commitTransaction()

void PoolDBOutputService::commitTransaction ( )

Definition at line 178 of file PoolDBOutputService.cc.

References CommonMethods::lock().

Referenced by popcon::PopCon::finalize(), and cond::service::OnlineDBOutputService::writeIOVForNextLumisection().

178  {
179  std::lock_guard<std::recursive_mutex> lock(m_mutex);
181 }

◆ createNewIOV() [1/2]

void PoolDBOutputService::createNewIOV ( const std::string &  firstPayloadId,
cond::Time_t  firstSinceTime,
const std::string &  recordName 
)

Definition at line 265 of file PoolDBOutputService.cc.

References a, cppFunctionSkipper::exception, cond::persistency::IOVEditor::flush(), cond::persistency::IOVEditor::insert(), CommonMethods::lock(), align_cfg::recordName, cond::persistency::IOVEditor::setDescription(), AlCaHLTBitMon_QueryRunRegistry::string, cond::SYNCH_ANY, and cond::throwException().

Referenced by createOneIOV(), l1t::DataWriter::updateIOV(), l1t::DataWriterExt::updateIOV(), and writeOneIOV().

267  {
268  std::lock_guard<std::recursive_mutex> lock(m_mutex);
271  try {
272  this->initDB();
273  auto& myrecord = this->getRecord(recordName);
274  if (!myrecord.m_isNewTag) {
275  cond::throwException(myrecord.m_tag + " is not a new tag", "PoolDBOutputService::createNewIOV");
276  }
277  m_logger.logInfo() << "Creating new tag " << myrecord.m_tag << ", adding iov with since " << firstSinceTime
278  << " pointing to payload id " << firstPayloadId;
280  m_session.createIovForPayload(firstPayloadId, myrecord.m_tag, myrecord.m_timetype, cond::SYNCH_ANY);
281  editor.setDescription("New Tag");
282  editor.insert(firstSinceTime, firstPayloadId);
283  cond::UserLogInfo a = this->lookUpUserLogInfo(myrecord.m_idName);
284  editor.flush(a.usertext);
285  myrecord.m_isNewTag = false;
286  if (m_autoCommit) {
288  }
289  } catch (const std::exception& er) {
290  cond::throwException(std::string(er.what()), "PoolDBOutputService::createNewIov");
291  }
292  scope.close();
293 }
void setDescription(const std::string &description)
Definition: IOVEditor.cc:139
Transaction & transaction()
Definition: Session.cc:52
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18
cond::persistency::Session m_session
cond::persistency::Logger m_logger
void insert(cond::Time_t since, const cond::Hash &payloadHash, bool checkType=false)
Definition: IOVEditor.cc:159
Record & getRecord(const std::string &recordName)
double a
Definition: hdecay.h:119
IOVEditor createIovForPayload(const Hash &payloadHash, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.cc:114
EchoedLogStream< edm::LogInfo > logInfo()
Definition: Logger.cc:157
cond::UserLogInfo & lookUpUserLogInfo(const std::string &recordName)

◆ createNewIOV() [2/2]

void PoolDBOutputService::createNewIOV ( const std::string &  firstPayloadId,
const std::string  payloadType,
cond::Time_t  firstSinceTime,
Record record 
)
private

Definition at line 296 of file PoolDBOutputService.cc.

References a, cond::persistency::IOVEditor::flush(), cond::persistency::IOVEditor::insert(), cond::service::PoolDBOutputService::Record::m_idName, cond::service::PoolDBOutputService::Record::m_isNewTag, cond::service::PoolDBOutputService::Record::m_tag, cond::service::PoolDBOutputService::Record::m_timetype, HLT_2022v12_cff::payloadType, cond::persistency::IOVEditor::setDescription(), and cond::SYNCH_ANY.

299  {
300  m_logger.logInfo() << "Creating new tag " << myrecord.m_tag << " for payload type " << payloadType
301  << ", adding iov with since " << firstSinceTime;
302  // FIX ME: synchronization type and description have to be passed as the other parameters?
304  m_session.createIov(payloadType, myrecord.m_tag, myrecord.m_timetype, cond::SYNCH_ANY);
305  editor.setDescription("New Tag");
306  editor.insert(firstSinceTime, firstPayloadId);
307  cond::UserLogInfo a = this->lookUpUserLogInfo(myrecord.m_idName);
308  editor.flush(a.usertext);
309  myrecord.m_isNewTag = false;
310 }
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.h:179
void setDescription(const std::string &description)
Definition: IOVEditor.cc:139
cond::persistency::Session m_session
cond::persistency::Logger m_logger
void insert(cond::Time_t since, const cond::Hash &payloadHash, bool checkType=false)
Definition: IOVEditor.cc:159
double a
Definition: hdecay.h:119
EchoedLogStream< edm::LogInfo > logInfo()
Definition: Logger.cc:157
cond::UserLogInfo & lookUpUserLogInfo(const std::string &recordName)

◆ createOneIOV()

template<typename T >
void cond::service::PoolDBOutputService::createOneIOV ( const T payload,
cond::Time_t  firstSinceTime,
const std::string &  recordName 
)
inline

Definition at line 161 of file PoolDBOutputService.h.

References createNewIOV(), doCommitTransaction(), doStartTransaction(), cppFunctionSkipper::exception, getRecord(), initDB(), CommonMethods::lock(), m_autoCommit, m_mutex, m_session, jetsAK4_Puppi_cff::payload, cond::persistency::Session::storePayload(), AlCaHLTBitMon_QueryRunRegistry::string, cond::throwException(), and cond::persistency::Session::transaction().

Referenced by SiStripApvSimulationParametersBuilder::analyze(), SiStripPedestalsBuilder::analyze(), SiStripThresholdBuilder::analyze(), SiStripNoisesBuilder::analyze(), SiStripSummaryBuilder::analyze(), SiStripApvGainBuilder::analyze(), DBWriter::analyze(), SiStripDetVOffFakeBuilder::analyze(), EcalPFRecHitThresholdsMaker::analyze(), cms::SiPixelPerformanceSummaryBuilder::analyze(), SiPixelLorentzAngleDB::analyze(), SiPixelVCalDB::analyze(), SiPixelDynamicInefficiencyDB::analyze(), WriteEcalMiscalibConstantsMC::analyze(), WriteEcalMiscalibConstants::analyze(), SiStripNoiseNormalizedWithApvGainBuilder::analyze(), SiStripApvGainBuilderFromTag::analyze(), SiPixelCalibConfigurationObjectMaker::analyze(), EcalTestDevDB::analyze(), cms::SiPixelCondObjBuilder::analyze(), cms::SiPixelCondObjForHLTBuilder::analyze(), cms::SiPixelCondObjOfflineBuilder::analyze(), SiStripChannelGainFromDBMiscalibrator::analyze(), SiStripNoisesFromDBMiscalibrator::analyze(), SiStripApvGainFromFileBuilder::analyze(), XMLGeometryBuilder::beginJob(), PTrackerAdditionalParametersPerDetDBBuilder::beginRun(), PTrackerParametersDBBuilder::beginRun(), HcalParametersDBBuilder::beginRun(), ME0RecoIdealDBLoader::beginRun(), PHGCalParametersDBBuilder::beginRun(), RPCRecoIdealDBLoader::beginRun(), CSCRecoIdealDBLoader::beginRun(), DTRecoIdealDBLoader::beginRun(), GEMRecoIdealDBLoader::beginRun(), PGeometricDetBuilder::beginRun(), SiStripFedCablingBuilder::beginRun(), SiPixelGainCalibScaler::computeAndStorePalyoads(), ESDBCopy::copyToDB(), EcalTPGDBCopy::copyToDB(), EcalDBCopy::copyToDB(), CocoaDBMgr::DumpCocoaResults(), BeamSpotWrite2DB::endJob(), StoreESCondition::endJob(), BeamProfile2DB::endJob(), BeamSpotOnlineRecordsWriter::endJob(), StoreEcalCondition::endJob(), SiStripFedCablingManipulator::endRun(), SiPixelGainCalibrationReadDQMFile::fillDatabase(), SiPixelGainCalibrationRejectNoisyAndDead::fillDatabase(), SiStripBadChannelBuilder::getNewObject(), SiPhase2BadStripChannelBuilder::getNewObject(), CaloGeometryDBWriter::write(), BeamFitter::write2DB(), and CaloGeometryDBWriter::writeIndexed().

161  {
162  std::lock_guard<std::recursive_mutex> lock(m_mutex);
165  try {
166  this->initDB();
167  auto& myrecord = this->getRecord(recordName);
168  if (!myrecord.m_isNewTag) {
169  cond::throwException(myrecord.m_tag + " is not a new tag", "PoolDBOutputService::createNewIOV");
170  }
171  Hash payloadId = m_session.storePayload(payload);
172  createNewIOV(payloadId, cond::demangledName(typeid(payload)), firstSinceTime, myrecord);
173  if (m_autoCommit) {
175  }
176  } catch (const std::exception& er) {
177  cond::throwException(std::string(er.what()), "PoolDBOutputService::createNewIov");
178  }
179  scope.close();
180  }
Transaction & transaction()
Definition: Session.cc:52
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18
std::string Hash
Definition: Types.h:43
cond::persistency::Session m_session
Record & getRecord(const std::string &recordName)
void createNewIOV(const std::string &firstPayloadId, cond::Time_t firstSinceTime, const std::string &recordName)
cond::Hash storePayload(const T &payload, const boost::posix_time::ptime &creationTime=boost::posix_time::microsec_clock::universal_time())
Definition: Session.h:186

◆ currentTime()

cond::Time_t PoolDBOutputService::currentTime ( ) const

Definition at line 260 of file PoolDBOutputService.cc.

References cms::cuda::assert(), and s_streamIndex.

Referenced by L1MuonOverlapParamsDBProducer::analyze(), SiStripPedestalsBuilder::analyze(), SiStripThresholdBuilder::analyze(), SiStripNoisesBuilder::analyze(), SiStripSummaryBuilder::analyze(), L1MuonOverlapPhase1ParamsDBProducer::analyze(), SiStripApvGainBuilder::analyze(), DBWriter::analyze(), WritePPSAssociationCuts::analyze(), WritePPSAlignmentConfiguration::analyze(), SiStripDetVOffFakeBuilder::analyze(), cms::SiPixelPerformanceSummaryBuilder::analyze(), SiPixelLorentzAngleDB::analyze(), SiPixelVCalDB::analyze(), BufferedBoostIODBWriter::analyze(), PPSTimingCalibrationLUTWriter::analyze(), SiPixelDynamicInefficiencyDB::analyze(), PPSTimingCalibrationWriter::analyze(), WriteEcalMiscalibConstants::analyze(), WriteEcalMiscalibConstantsMC::analyze(), SiStripNoiseNormalizedWithApvGainBuilder::analyze(), SiStripApvGainBuilderFromTag::analyze(), SiPixelGenErrorDBObjectUploader::analyze(), SiPixel2DTemplateDBObjectUploader::analyze(), SiPixelCalibConfigurationObjectMaker::analyze(), SiPixelTemplateDBObjectUploader::analyze(), EcalMustacheSCParametersMaker::analyze(), EcalSCDynamicDPhiParametersMaker::analyze(), FFTJetCorrectorDBWriter::analyze(), cms::SiPixelCondObjBuilder::analyze(), BoostIODBWriter< DataType >::analyze(), cms::SiPixelCondObjForHLTBuilder::analyze(), cms::SiPixelCondObjOfflineBuilder::analyze(), SiStripApvGainRescaler::analyze(), SiPhase2OuterTrackerLorentzAngleWriter::analyze(), SiStripChannelGainFromDBMiscalibrator::analyze(), SiStripNoisesFromDBMiscalibrator::analyze(), SiStripApvGainFromFileBuilder::analyze(), SiStripFedCablingBuilder::beginRun(), PPSDiamondSampicTimingCalibrationPCLHarvester::calibDb(), SiPixelGainCalibScaler::computeAndStorePalyoads(), SiStripBadStripFromQualityDBWriter::dqmEndJob(), PPSTimingCalibrationPCLHarvester::dqmEndJob(), ECALpedestalPCLHarvester::dqmEndJob(), SiStripGainsPCLHarvester::dqmEndJob(), SiPixelLorentzAnglePCLHarvester::dqmEndJob(), PPSAlignmentHarvester::dqmEndRun(), CocoaDBMgr::DumpCocoaResults(), SurveyDBUploader::endJob(), BeamSpotWrite2DB::endJob(), Mixing2DB::endJob(), SiPixelQualityProbabilitiesTestWriter::endJob(), SiPixelQualityProbabilitiesWriteFromASCII::endJob(), SiPixelFEDChannelContainerWriteFromASCII::endJob(), SiPixelFEDChannelContainerFromQualityConverter::endJob(), BeamSpotOnlineRecordsWriter::endJob(), FastSiPixelFEDChannelContainerFromQuality::endJob(), SiStripFedCablingManipulator::endRun(), DummyCondDBWriter< TObject, TObjectO, TRecord >::endRun(), SiPixelGainCalibrationReadDQMFile::fillDatabase(), SiPixelGainCalibrationRejectNoisyAndDead::fillDatabase(), WriteCTPPSPixGainCalibrations::fillDB(), SiStripBadChannelBuilder::getNewObject(), SiPhase2BadStripChannelBuilder::getNewObject(), popcon::L1RPCHwConfigSourceHandler::getNewObjects(), popcon::RPCEMapSourceHandler::getNewObjects(), MisalignedTrackerESProducer::produce(), MuonAlignment::saveCSCSurveyToDB(), MuonAlignment::saveCSCtoDB(), MuonAlignment::saveDTSurveyToDB(), MuonAlignment::saveDTtoDB(), MuonAlignment::saveGEMtoDB(), TrackerAlignment::saveToDB(), ConditionDBWriter< SiStripApvGain >::setTime(), CaloGeometryDBWriter::write(), WriteESAlignments::write(), BeamFitter::write2DB(), SiStripHitEfficiencyHarvester::writeBadStripPayload(), GlobalTrackerMuonAlignment::writeGlPosRcd(), CaloGeometryDBWriter::writeIndexed(), AlignPCLThresholdsWriter< T >::writePayload(), and DTCalibDBUtils::writeToDB().

260  {
261  assert(-1 != s_streamIndex);
263 }
static thread_local int s_streamIndex
std::vector< cond::Time_t > m_currentTimes
assert(be >=bs)

◆ doCommitTransaction()

void PoolDBOutputService::doCommitTransaction ( )
private

Definition at line 162 of file PoolDBOutputService.cc.

Referenced by appendOneIOV(), createOneIOV(), writeMany(), and writeOneIOV().

162  {
163  if (m_transactionActive) {
165  m_logger.logWarning() << "Waiting " << m_writeTransactionDelay << "s before commit the changes...";
166  ::sleep(m_writeTransactionDelay);
167  }
169  m_transactionActive = false;
170  }
171 }
EchoedLogStream< edm::LogWarning > logWarning()
Definition: Logger.cc:169
Transaction & transaction()
Definition: Session.cc:52
cond::persistency::Session m_session
cond::persistency::Logger m_logger

◆ doStartTransaction()

void PoolDBOutputService::doStartTransaction ( )
private

Definition at line 155 of file PoolDBOutputService.cc.

Referenced by appendOneIOV(), createOneIOV(), writeMany(), and writeOneIOV().

155  {
156  if (!m_transactionActive) {
157  m_session.transaction().start(false);
158  m_transactionActive = true;
159  }
160 }
void start(bool readOnly=true)
Definition: Session.cc:18
Transaction & transaction()
Definition: Session.cc:52
cond::persistency::Session m_session

◆ endOfTime()

cond::Time_t PoolDBOutputService::endOfTime ( ) const

Definition at line 256 of file PoolDBOutputService.cc.

References cond::TimeTypeSpecs::endValue, and cond::timeTypeSpecs.

Referenced by EcalDQMStatusWriter::analyze(), and CocoaDBMgr::DumpCocoaResults().

256 { return timeTypeSpecs[m_timetype].endValue; }
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:16
Time_t endValue
Definition: Time.h:42

◆ eraseSinceTime()

void PoolDBOutputService::eraseSinceTime ( const std::string &  payloadId,
cond::Time_t  sinceTime,
const std::string &  recordName 
)

Definition at line 356 of file PoolDBOutputService.cc.

References a, cond::persistency::IOVEditor::erase(), cppFunctionSkipper::exception, cond::persistency::IOVEditor::flush(), CommonMethods::lock(), align_cfg::recordName, AlCaHLTBitMon_QueryRunRegistry::string, and cond::throwException().

Referenced by cond::service::OnlineDBOutputService::writeIOVForNextLumisection().

358  {
359  std::lock_guard<std::recursive_mutex> lock(m_mutex);
362  try {
363  bool dbexists = this->initDB();
364  if (!dbexists) {
365  cond::throwException(std::string("Target database does not exist."), "PoolDBOutputService::eraseSinceTime");
366  }
367  auto& myrecord = this->lookUpRecord(recordName);
368  if (myrecord.m_isNewTag) {
369  cond::throwException(std::string("Cannot delete from non-existing tag ") + myrecord.m_tag,
370  "PoolDBOutputService::appendSinceTime");
371  }
372  m_logger.logInfo() << "Updating existing tag " << myrecord.m_tag << ", removing iov with since " << sinceTime
373  << " pointing to payload id " << payloadId;
374  cond::persistency::IOVEditor editor = m_session.editIov(myrecord.m_tag);
375  editor.erase(sinceTime, payloadId);
377  editor.flush(a.usertext);
378  if (m_autoCommit) {
380  }
381  } catch (const std::exception& er) {
382  cond::throwException(std::string(er.what()), "PoolDBOutputService::eraseSinceTime");
383  }
384  scope.close();
385 }
const Record & lookUpRecord(const std::string &recordName)
Transaction & transaction()
Definition: Session.cc:52
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18
cond::persistency::Session m_session
void erase(cond::Time_t since, const cond::Hash &payloadHash)
Definition: IOVEditor.cc:174
cond::persistency::Logger m_logger
IOVEditor editIov(const std::string &tag)
Definition: Session.cc:130
double a
Definition: hdecay.h:119
EchoedLogStream< edm::LogInfo > logInfo()
Definition: Logger.cc:157
cond::UserLogInfo & lookUpUserLogInfo(const std::string &recordName)

◆ fillRecord()

void PoolDBOutputService::fillRecord ( edm::ParameterSet pset,
const std::string &  gTimeTypeStr 
)
private

Definition at line 20 of file PoolDBOutputService.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), cond::service::PoolDBOutputService::Record::m_idName, m_logheaders, cond::service::PoolDBOutputService::Record::m_onlyAppendUpdatePolicy, m_records, cond::service::PoolDBOutputService::Record::m_refreshTime, cond::service::PoolDBOutputService::Record::m_tag, cond::service::PoolDBOutputService::Record::m_timetype, AlCaHLTBitMon_QueryRunRegistry::string, and cond::time::timeTypeFromName().

20  {
21  Record thisrecord;
22 
23  thisrecord.m_idName = recordPset.getParameter<std::string>("record");
24  thisrecord.m_tag = recordPset.getParameter<std::string>("tag");
25 
26  thisrecord.m_timetype =
27  cond::time::timeTypeFromName(recordPset.getUntrackedParameter<std::string>("timetype", gTimeTypeStr));
28 
29  thisrecord.m_onlyAppendUpdatePolicy = recordPset.getUntrackedParameter<bool>("onlyAppendUpdatePolicy", false);
30 
31  thisrecord.m_refreshTime = recordPset.getUntrackedParameter<unsigned int>("refreshTime", 1);
32 
33  m_records.insert(std::make_pair(thisrecord.m_idName, thisrecord));
34 
35  cond::UserLogInfo userloginfo;
36  m_logheaders.insert(std::make_pair(thisrecord.m_idName, userloginfo));
37 }
std::map< std::string, cond::UserLogInfo > m_logheaders
TimeType timeTypeFromName(const std::string &name)
Definition: Time.cc:25
std::map< std::string, Record > m_records

◆ forceInit()

void PoolDBOutputService::forceInit ( )

Definition at line 241 of file PoolDBOutputService.cc.

References cppFunctionSkipper::exception, CommonMethods::lock(), AlCaHLTBitMon_QueryRunRegistry::string, and cond::throwException().

Referenced by popcon::PopCon::initialize(), l1t::DataWriterExt::readObject(), l1t::WriterProxyT< Record, Type >::save(), and l1t::DataWriterExt::writeKeyList().

241  {
242  std::lock_guard<std::recursive_mutex> lock(m_mutex);
245  try {
246  initDB();
247  if (m_autoCommit) {
249  }
250  } catch (const std::exception& er) {
251  cond::throwException(std::string(er.what()), "PoolDBOutputService::forceInit");
252  }
253  scope.close();
254 }
Transaction & transaction()
Definition: Session.cc:52
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18
cond::persistency::Session m_session

◆ getRecord()

cond::service::PoolDBOutputService::Record & PoolDBOutputService::getRecord ( const std::string &  recordName)
private

Definition at line 201 of file PoolDBOutputService.cc.

References align_cfg::recordName, and cond::throwException().

Referenced by createOneIOV(), writeMany(), and writeOneIOV().

202  {
203  std::map<std::string, Record>::iterator it = m_records.find(recordName);
204  if (it == m_records.end()) {
205  cond::throwException("The record \"" + recordName + "\" has not been registered.",
206  "PoolDBOutputService::getRecord");
207  }
208  return it->second;
209 }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18
std::map< std::string, Record > m_records

◆ getTagInfo()

bool PoolDBOutputService::getTagInfo ( const std::string &  recordName,
cond::TagInfo_t result 
)
private

Definition at line 441 of file PoolDBOutputService.cc.

References cond::persistency::IOVProxy::getLast(), AlCaHarvesting_cff::record, align_cfg::recordName, mps_fire::result, and runTheMatrix::ret.

Referenced by writeMany(), and writeOneIOV().

441  {
442  auto& record = lookUpRecord(recordName);
443  result.name = record.m_tag;
444  m_logger.logDebug() << "Fetching tag info for " << record.m_tag;
445  bool ret = false;
446  //use iovproxy to find out.
447  if (m_session.existsIov(record.m_tag)) {
449  result.lastInterval = iov.getLast();
450  ret = true;
451  }
452  return ret;
453 }
const Record & lookUpRecord(const std::string &recordName)
ret
prodAgent to be discontinued
cond::persistency::Session m_session
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
cond::persistency::Logger m_logger
EchoedLogStream< edm::LogDebug_ > logDebug()
Definition: Logger.cc:161
bool existsIov(const std::string &tag)
Definition: Session.cc:77

◆ initDB()

bool PoolDBOutputService::initDB ( bool  readOnly = false)
private

Definition at line 183 of file PoolDBOutputService.cc.

Referenced by appendOneIOV(), createOneIOV(), writeMany(), and writeOneIOV().

183  {
184  if (!m_dbInitialised) {
185  if (!m_session.existsDatabase()) {
186  if (readOnly)
187  return false;
189  } else {
190  for (auto& iR : m_records) {
191  if (m_session.existsIov(iR.second.m_tag)) {
192  iR.second.m_isNewTag = false;
193  }
194  }
195  }
196  m_dbInitialised = true;
197  }
198  return m_dbInitialised;
199 }
cond::persistency::Session m_session
std::map< std::string, Record > m_records
bool existsIov(const std::string &tag)
Definition: Session.cc:77

◆ isNewTagRequest()

bool PoolDBOutputService::isNewTagRequest ( const std::string &  recordName)

Definition at line 134 of file PoolDBOutputService.cc.

References cppFunctionSkipper::exception, CommonMethods::lock(), align_cfg::recordName, AlCaHLTBitMon_QueryRunRegistry::string, and cond::throwException().

Referenced by SiStripPedestalsBuilder::analyze(), SiStripThresholdBuilder::analyze(), SiStripNoisesBuilder::analyze(), SiStripSummaryBuilder::analyze(), SiStripApvGainBuilder::analyze(), DBWriter::analyze(), SiStripDetVOffFakeBuilder::analyze(), cms::SiPixelPerformanceSummaryBuilder::analyze(), SiPixelLorentzAngleDB::analyze(), SiPixelVCalDB::analyze(), SiPixelDynamicInefficiencyDB::analyze(), WriteEcalMiscalibConstants::analyze(), WriteEcalMiscalibConstantsMC::analyze(), SiStripNoiseNormalizedWithApvGainBuilder::analyze(), SiStripApvGainBuilderFromTag::analyze(), SiPixelGenErrorDBObjectUploader::analyze(), SiPixelCalibConfigurationObjectMaker::analyze(), SiPixelTemplateDBObjectUploader::analyze(), SiPixel2DTemplateDBObjectUploader::analyze(), EcalTestDevDB::analyze(), cms::SiPixelCondObjBuilder::analyze(), cms::SiPixelCondObjForHLTBuilder::analyze(), cms::SiPixelCondObjOfflineBuilder::analyze(), SiStripChannelGainFromDBMiscalibrator::analyze(), SiStripNoisesFromDBMiscalibrator::analyze(), SiStripApvGainFromFileBuilder::analyze(), XMLGeometryBuilder::beginJob(), PTrackerAdditionalParametersPerDetDBBuilder::beginRun(), PTrackerParametersDBBuilder::beginRun(), HcalParametersDBBuilder::beginRun(), CSCRecoIdealDBLoader::beginRun(), ME0RecoIdealDBLoader::beginRun(), PHGCalParametersDBBuilder::beginRun(), RPCRecoIdealDBLoader::beginRun(), DTRecoIdealDBLoader::beginRun(), GEMRecoIdealDBLoader::beginRun(), PGeometricDetBuilder::beginRun(), SiStripFedCablingBuilder::beginRun(), SiPixelGainCalibScaler::computeAndStorePalyoads(), CocoaDBMgr::DumpCocoaResults(), BeamSpotWrite2DB::endJob(), StoreESCondition::endJob(), BeamSpotOnlineRecordsWriter::endJob(), StoreEcalCondition::endJob(), SiStripFedCablingManipulator::endRun(), AlcaBeamSpotHarvester::endRun(), SiPixelGainCalibrationReadDQMFile::fillDatabase(), SiPixelGainCalibrationRejectNoisyAndDead::fillDatabase(), SiStripBadChannelBuilder::getNewObject(), SiPhase2BadStripChannelBuilder::getNewObject(), EcalLaserCondTools::processIov(), ConditionDBWriter< SiStripApvGain >::storeOnDb(), l1t::DataWriter::updateIOV(), l1t::DataWriterExt::updateIOV(), CaloGeometryDBWriter::write(), BeamFitter::write2DB(), CaloGeometryDBWriter::writeIndexed(), writeMany(), writeOneIOV(), and DTCalibDBUtils::writeToDB().

134  {
135  std::lock_guard<std::recursive_mutex> lock(m_mutex);
136  bool doCommit = false;
137  if (!m_transactionActive) {
138  m_session.transaction().start(true);
139  doCommit = true;
140  }
141  bool dbexists = false;
142  try {
143  dbexists = initDB(true);
144  } catch (const std::exception& er) {
145  cond::throwException(std::string(er.what()), "PoolDBOutputService::isNewTagRequest");
146  }
147  if (doCommit)
149  if (!dbexists)
150  return true;
151  auto& myrecord = this->lookUpRecord(recordName);
152  return myrecord.m_isNewTag;
153 }
const Record & lookUpRecord(const std::string &recordName)
void start(bool readOnly=true)
Definition: Session.cc:18
Transaction & transaction()
Definition: Session.cc:52
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18
cond::persistency::Session m_session

◆ lockRecords()

void PoolDBOutputService::lockRecords ( )

Definition at line 96 of file PoolDBOutputService.cc.

References CommonMethods::lock(), and cond::persistency::IOVEditor::lock().

Referenced by FakeBeamMonitor::dqmBeginRun(), and BeamMonitor::dqmBeginRun().

96  {
97  std::lock_guard<std::recursive_mutex> lock(m_mutex);
100  this->initDB();
101  for (auto& iR : m_records) {
102  if (iR.second.m_isNewTag == false) {
103  cond::persistency::IOVEditor editor = m_session.editIov(iR.second.m_tag);
104  editor.lock();
105  }
106  }
107  if (m_autoCommit) {
109  }
110  scope.close();
111 }
Transaction & transaction()
Definition: Session.cc:52
cond::persistency::Session m_session
std::map< std::string, Record > m_records
IOVEditor editIov(const std::string &tag)
Definition: Session.cc:130

◆ logger()

cond::persistency::Logger& cond::service::PoolDBOutputService::logger ( )
inline

◆ lookUpRecord()

const cond::service::PoolDBOutputService::Record & PoolDBOutputService::lookUpRecord ( const std::string &  recordName)

Definition at line 387 of file PoolDBOutputService.cc.

References align_cfg::recordName, and cond::throwException().

Referenced by appendOneIOV(), and cond::service::OnlineDBOutputService::writeIOVForNextLumisection().

388  {
389  std::map<std::string, Record>::const_iterator it = m_records.find(recordName);
390  if (it == m_records.end()) {
391  cond::throwException("The record \"" + recordName + "\" has not been registered.",
392  "PoolDBOutputService::lookUpRecord");
393  }
394  return it->second;
395 }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18
std::map< std::string, Record > m_records

◆ lookUpUserLogInfo()

cond::UserLogInfo & PoolDBOutputService::lookUpUserLogInfo ( const std::string &  recordName)
private

Definition at line 397 of file PoolDBOutputService.cc.

References align_cfg::recordName.

Referenced by writeMany().

397  {
398  std::map<std::string, cond::UserLogInfo>::iterator it = m_logheaders.find(recordName);
399  if (it == m_logheaders.end())
400  throw cond::Exception("Log db was not set for record " + recordName +
401  " from PoolDBOutputService::lookUpUserLogInfo");
402  return it->second;
403 }
Base exception class for the object to relational access.
Definition: Exception.h:11
std::map< std::string, cond::UserLogInfo > m_logheaders

◆ newReadOnlySession()

cond::persistency::Session PoolDBOutputService::newReadOnlySession ( const std::string &  connectionString,
const std::string &  transactionId 
)

Definition at line 87 of file PoolDBOutputService.cc.

References l1RCTOmdsFedVectorProducer_cfi::connectionString, and runTheMatrix::ret.

Referenced by cond::service::OnlineDBOutputService::preLoadIov().

88  {
91  return ret;
92 }
ret
prodAgent to be discontinued
cond::persistency::ConnectionPool m_connection
Session createReadOnlySession(const std::string &connectionString, const std::string &transactionId)

◆ postEndJob()

void PoolDBOutputService::postEndJob ( )

◆ postModuleEvent()

void PoolDBOutputService::postModuleEvent ( edm::StreamContext const &  iContext,
edm::ModuleCallingContext const &   
)
private

Definition at line 222 of file PoolDBOutputService.cc.

References s_streamIndex.

223  {
224  s_streamIndex = -1;
225 }
static thread_local int s_streamIndex

◆ preEventProcessing()

void PoolDBOutputService::preEventProcessing ( edm::StreamContext const &  iContext)
private

Definition at line 213 of file PoolDBOutputService.cc.

References edm::StreamContext::streamID(), edm::StreamContext::timestamp(), edm::StreamID::value(), and edm::Timestamp::value().

213  {
214  m_currentTimes[iContext.streamID().value()] = iContext.timestamp().value();
215 }
std::vector< cond::Time_t > m_currentTimes

◆ preGlobalBeginLumi()

void PoolDBOutputService::preGlobalBeginLumi ( edm::GlobalContext const &  iContext)
private

Definition at line 233 of file PoolDBOutputService.cc.

References edm::GlobalContext::luminosityBlockID(), protons_cff::time, and edm::LuminosityBlockID::value().

233  {
234  for (auto& time : m_currentTimes) {
235  time = iContext.luminosityBlockID().value();
236  }
237 }
std::vector< cond::Time_t > m_currentTimes

◆ preGlobalBeginRun()

void PoolDBOutputService::preGlobalBeginRun ( edm::GlobalContext const &  iContext)
private

Definition at line 227 of file PoolDBOutputService.cc.

References edm::GlobalContext::luminosityBlockID(), edm::LuminosityBlockID::run(), and protons_cff::time.

227  {
228  for (auto& time : m_currentTimes) {
229  time = iContext.luminosityBlockID().run();
230  }
231 }
std::vector< cond::Time_t > m_currentTimes

◆ preModuleEvent()

void PoolDBOutputService::preModuleEvent ( edm::StreamContext const &  iContext,
edm::ModuleCallingContext const &   
)
private

Definition at line 217 of file PoolDBOutputService.cc.

References s_streamIndex, edm::StreamContext::streamID(), and edm::StreamID::value().

218  {
219  s_streamIndex = iContext.streamID().value();
220 }
static thread_local int s_streamIndex

◆ releaseLocks()

void PoolDBOutputService::releaseLocks ( )

Definition at line 113 of file PoolDBOutputService.cc.

References CommonMethods::lock(), and cond::persistency::IOVEditor::unlock().

Referenced by FakeBeamMonitor::dqmEndRun(), and BeamMonitor::dqmEndRun().

113  {
114  std::lock_guard<std::recursive_mutex> lock(m_mutex);
117  this->initDB();
118  for (auto& iR : m_records) {
119  if (iR.second.m_isNewTag == false) {
120  cond::persistency::IOVEditor editor = m_session.editIov(iR.second.m_tag);
121  editor.unlock();
122  }
123  }
124  if (m_autoCommit) {
126  }
127  scope.close();
128 }
Transaction & transaction()
Definition: Session.cc:52
cond::persistency::Session m_session
std::map< std::string, Record > m_records
IOVEditor editIov(const std::string &tag)
Definition: Session.cc:130

◆ session()

cond::persistency::Session PoolDBOutputService::session ( ) const

◆ setLogHeaderForRecord()

void PoolDBOutputService::setLogHeaderForRecord ( const std::string &  recordName,
const std::string &  provenance,
const std::string &  usertext 
)

Definition at line 432 of file PoolDBOutputService.cc.

References cond::UserLogInfo::provenance, align_cfg::recordName, and cond::UserLogInfo::usertext.

Referenced by popcon::PopCon::write().

434  {
435  cond::UserLogInfo& myloginfo = this->lookUpUserLogInfo(recordName);
436  myloginfo.provenance = dataprovenance;
437  myloginfo.usertext = usertext;
438 }
std::string provenance
Definition: Types.h:23
std::string usertext
Definition: Types.h:24
cond::UserLogInfo & lookUpUserLogInfo(const std::string &recordName)

◆ startTransaction()

void PoolDBOutputService::startTransaction ( )

Definition at line 173 of file PoolDBOutputService.cc.

References CommonMethods::lock().

Referenced by popcon::PopCon::initialize().

173  {
174  std::lock_guard<std::recursive_mutex> lock(m_mutex);
176 }

◆ tag()

std::string PoolDBOutputService::tag ( const std::string &  recordName)

◆ tagInfo()

bool PoolDBOutputService::tagInfo ( const std::string &  recordName,
cond::TagInfo_t result 
)

Definition at line 456 of file PoolDBOutputService.cc.

References cppFunctionSkipper::exception, CommonMethods::lock(), align_cfg::recordName, mps_fire::result, runTheMatrix::ret, AlCaHLTBitMon_QueryRunRegistry::string, and cond::throwException().

Referenced by l1t::DataWriter::lastPayloadToken(), l1t::DataWriterExt::lastPayloadToken(), l1t::DataWriter::updateIOV(), and l1t::DataWriterExt::updateIOV().

456  {
457  std::lock_guard<std::recursive_mutex> lock(m_mutex);
458  bool ret = false;
459  bool doCommit = false;
460  if (!m_transactionActive) {
461  m_session.transaction().start(true);
462  doCommit = true;
463  }
464  bool dbexists = false;
466  try {
467  dbexists = initDB(true);
468  if (dbexists) {
470  }
471  } catch (const std::exception& er) {
472  cond::throwException(std::string(er.what()), "PoolDBOutputService::tagInfo");
473  }
474  if (doCommit)
476  scope.close();
477  return ret;
478 }
ret
prodAgent to be discontinued
void start(bool readOnly=true)
Definition: Session.cc:18
Transaction & transaction()
Definition: Session.cc:52
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18
cond::persistency::Session m_session
bool getTagInfo(const std::string &recordName, cond::TagInfo_t &result)

◆ writeMany()

template<typename T >
void cond::service::PoolDBOutputService::writeMany ( const std::map< Time_t, std::shared_ptr< T > > &  iovAndPayloads,
const std::string &  recordName 
)
inline

Definition at line 105 of file PoolDBOutputService.h.

References a, cond::persistency::Session::createIov(), doCommitTransaction(), doStartTransaction(), cond::persistency::Session::editIov(), cppFunctionSkipper::exception, cond::persistency::IOVEditor::flush(), getRecord(), getTagInfo(), initDB(), cond::persistency::IOVEditor::insert(), isNewTagRequest(), cond::TagInfo_t::lastInterval, CommonMethods::lock(), cond::persistency::Logger::logInfo(), lookUpUserLogInfo(), m_autoCommit, m_logger, m_mutex, m_session, cond::time::MAX_VAL(), jetsAK4_Puppi_cff::payload, HLT_2022v12_cff::payloadType, align_cfg::recordName, cond::persistency::IOVEditor::setDescription(), cond::Iov_t::since, cond::persistency::Session::storePayload(), AlCaHLTBitMon_QueryRunRegistry::string, cond::SYNCH_ANY, cond::throwException(), protons_cff::time, cond::impl::to_string(), and cond::persistency::Session::transaction().

Referenced by popcon::PopCon::write().

105  {
106  if (iovAndPayloads.empty())
107  return;
108  std::lock_guard<std::recursive_mutex> lock(m_mutex);
111  try {
112  this->initDB();
113  auto& myrecord = this->getRecord(recordName);
114  m_logger.logInfo() << "Tag mapped to record " << recordName << ": " << myrecord.m_tag;
115  bool newTag = isNewTagRequest(recordName);
116  cond::Time_t lastSince;
118  if (newTag) {
119  std::string payloadType = cond::demangledName(typeid(T));
120  editor = m_session.createIov(payloadType, myrecord.m_tag, myrecord.m_timetype, cond::SYNCH_ANY);
121  editor.setDescription("New Tag");
122  } else {
123  editor = m_session.editIov(myrecord.m_tag);
124  if (myrecord.m_onlyAppendUpdatePolicy) {
125  cond::TagInfo_t tInfo;
126  this->getTagInfo(myrecord.m_idName, tInfo);
127  lastSince = tInfo.lastInterval.since;
128  if (lastSince == cond::time::MAX_VAL)
129  lastSince = 0;
130  }
131  }
132  for (auto& iovEntry : iovAndPayloads) {
133  Time_t time = iovEntry.first;
134  auto payload = iovEntry.second;
135  if (myrecord.m_onlyAppendUpdatePolicy && !newTag) {
136  if (time <= lastSince) {
137  m_logger.logInfo() << "Won't append iov with since " << std::to_string(time)
138  << ", because is less or equal to last available since = " << lastSince;
139  continue;
140  }
141  }
142  auto payloadHash = m_session.storePayload(*payload);
143  editor.insert(time, payloadHash);
144  }
145  cond::UserLogInfo a = this->lookUpUserLogInfo(myrecord.m_idName);
146  editor.flush(a.usertext);
147  if (m_autoCommit) {
149  }
150  } catch (const std::exception& er) {
151  cond::throwException(std::string(er.what()), "PoolDBOutputService::writeMany");
152  }
153  scope.close();
154  return;
155  }
Iov_t lastInterval
Definition: Types.h:73
Time_t since
Definition: Types.h:53
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.h:179
std::string to_string(const V &value)
Definition: OMSAccess.h:71
void setDescription(const std::string &description)
Definition: IOVEditor.cc:139
Transaction & transaction()
Definition: Session.cc:52
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18
unsigned long long Time_t
Definition: Time.h:14
bool isNewTagRequest(const std::string &recordName)
cond::persistency::Session m_session
cond::persistency::Logger m_logger
IOVEditor editIov(const std::string &tag)
Definition: Session.cc:130
void insert(cond::Time_t since, const cond::Hash &payloadHash, bool checkType=false)
Definition: IOVEditor.cc:159
Record & getRecord(const std::string &recordName)
bool getTagInfo(const std::string &recordName, cond::TagInfo_t &result)
cond::Hash storePayload(const T &payload, const boost::posix_time::ptime &creationTime=boost::posix_time::microsec_clock::universal_time())
Definition: Session.h:186
double a
Definition: hdecay.h:119
EchoedLogStream< edm::LogInfo > logInfo()
Definition: Logger.cc:157
long double T
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())
cond::UserLogInfo & lookUpUserLogInfo(const std::string &recordName)

◆ writeOneIOV()

template<typename T >
Hash cond::service::PoolDBOutputService::writeOneIOV ( const T payload,
Time_t  time,
const std::string &  recordName 
)
inline

Definition at line 62 of file PoolDBOutputService.h.

References appendSinceTime(), createNewIOV(), doCommitTransaction(), doStartTransaction(), cppFunctionSkipper::exception, getRecord(), getTagInfo(), initDB(), isNewTagRequest(), cond::TagInfo_t::lastInterval, CommonMethods::lock(), cond::persistency::Logger::logInfo(), m_autoCommit, m_logger, m_mutex, m_session, cond::time::MAX_VAL(), jetsAK4_Puppi_cff::payload, HLT_2022v12_cff::payloadType, align_cfg::recordName, cond::Iov_t::since, cond::persistency::Session::storePayload(), AlCaHLTBitMon_QueryRunRegistry::string, cond::throwException(), protons_cff::time, cond::impl::to_string(), and cond::persistency::Session::transaction().

Referenced by EcalDQMStatusWriter::analyze(), L1MuonOverlapParamsDBProducer::analyze(), L1MuonOverlapPhase1ParamsDBProducer::analyze(), SurveyInputTrackerFromDB::analyze(), WritePPSAlignmentConfiguration::analyze(), L1TMuonOverlapFwVersionTester::analyze(), WritePPSAssociationCuts::analyze(), GBRForestWriter::analyze(), PPSGeometryBuilder::analyze(), PPSTimingCalibrationWriter::analyze(), PPSTimingCalibrationLUTWriter::analyze(), BufferedBoostIODBWriter::analyze(), WriteCTPPSPixelAnalysisMask::analyze(), ProduceDropBoxMetadata::analyze(), CTPPSRPAlignmentInfoAnalyzer::analyze(), WriteCTPPSPixelDAQMapping::analyze(), SiPixelGenErrorDBObjectUploader::analyze(), SiPixel2DTemplateDBObjectUploader::analyze(), SiPixelTemplateDBObjectUploader::analyze(), WriteCTPPSBeamParameters::analyze(), EcalMustacheSCParametersMaker::analyze(), EcalSCDynamicDPhiParametersMaker::analyze(), FFTJetCorrectorDBWriter::analyze(), BoostIODBWriter< DataType >::analyze(), SiStripApvGainRescaler::analyze(), TrackerSystematicMisalignments::analyze(), TrackerGeometryCompare::analyze(), SiPhase2OuterTrackerLorentzAngleWriter::analyze(), MCMisalignmentScaler::analyze(), DTCCablingMapTestProducer::beginJob(), PPSDiamondSampicTimingCalibrationPCLHarvester::calibDb(), DTUserKeyedConfigHandler::chkConfigList(), DTKeyedConfigHandler::chkConfigList(), SiPixelStatusHarvester::constructTag(), EcalDBCopy::copyToDB(), SiStripBadStripFromQualityDBWriter::dqmEndJob(), PPSTimingCalibrationPCLHarvester::dqmEndJob(), ECALpedestalPCLHarvester::dqmEndJob(), SiStripGainsPCLHarvester::dqmEndJob(), SiPixelLorentzAnglePCLHarvester::dqmEndJob(), SiPixelStatusHarvester::dqmEndRun(), PPSAlignmentHarvester::dqmEndRun(), CorrPCCProducer::dqmEndRunProduce(), SurveyDBUploader::endJob(), SiPixelQualityProbabilitiesTestWriter::endJob(), Mixing2DB::endJob(), SiPixelQualityProbabilitiesWriteFromASCII::endJob(), SiPixelFEDChannelContainerWriteFromASCII::endJob(), DTKeyedConfigDBInit::endJob(), SiPixelFEDChannelContainerFromQualityConverter::endJob(), FastSiPixelFEDChannelContainerFromQuality::endJob(), DTCCablingMapProducer::endJob(), SiStripLorentzAngleCalibration::endOfJob(), SiPixelLorentzAngleCalibration::endOfJob(), SiStripBackplaneCalibration::endOfJob(), DummyCondDBWriter< TObject, TObjectO, TRecord >::endRun(), AlcaBeamSpotHarvester::endRun(), cond::BTransitionAnalyzer< EcalADCToGeVConstant, EcalADCToGeVConstantRcd >::endRun(), HLTPrescaleRecorder::endRun(), LaserAlignment::endRunProduce(), WriteCTPPSPixGainCalibrations::fillDB(), EcalLaserCondTools::from_hdf_to_db(), EcalLaserCondTools::processIov(), MisalignedTrackerESProducer::produce(), MuonAlignment::saveCSCSurveyToDB(), MuonAlignment::saveCSCtoDB(), MuonAlignment::saveDTSurveyToDB(), MuonAlignment::saveDTtoDB(), MuonAlignment::saveGEMtoDB(), TrackerAlignment::saveToDB(), MuonMisalignedProducer::saveToDB(), ConditionDBWriter< SiStripApvGain >::storeOnDb(), WriteESAlignments::write(), SiStripHitEfficiencyHarvester::writeBadStripPayload(), AlCaRecoTriggerBitsRcdUpdate::writeBitsToDB(), AlignmentProducerBase::writeDB(), GlobalTrackerMuonAlignment::writeGlPosRcd(), AlignPCLThresholdsWriter< T >::writePayload(), DTCalibDBUtils::writeToDB(), and CreateIdealTkAlRecords::writeToDB().

62  {
63  std::lock_guard<std::recursive_mutex> lock(m_mutex);
66  Hash thePayloadHash("");
67  try {
68  this->initDB();
69  auto& myrecord = this->getRecord(recordName);
70  m_logger.logInfo() << "Tag mapped to record " << recordName << ": " << myrecord.m_tag;
71  bool newTag = isNewTagRequest(recordName);
72  if (myrecord.m_onlyAppendUpdatePolicy && !newTag) {
73  cond::TagInfo_t tInfo;
74  this->getTagInfo(myrecord.m_idName, tInfo);
75  cond::Time_t lastSince = tInfo.lastInterval.since;
76  if (lastSince == cond::time::MAX_VAL)
77  lastSince = 0;
78  if (time <= lastSince) {
79  m_logger.logInfo() << "Won't append iov with since " << std::to_string(time)
80  << ", because is less or equal to last available since = " << lastSince;
81  if (m_autoCommit)
83  scope.close();
84  return thePayloadHash;
85  }
86  }
87  thePayloadHash = m_session.storePayload(payload);
88  std::string payloadType = cond::demangledName(typeid(payload));
89  if (newTag) {
90  createNewIOV(thePayloadHash, payloadType, time, myrecord);
91  } else {
92  appendSinceTime(thePayloadHash, time, myrecord);
93  }
94  if (m_autoCommit) {
96  }
97  } catch (const std::exception& er) {
98  cond::throwException(std::string(er.what()), "PoolDBOutputService::writeOne");
99  }
100  scope.close();
101  return thePayloadHash;
102  }
Iov_t lastInterval
Definition: Types.h:73
Time_t since
Definition: Types.h:53
std::string to_string(const V &value)
Definition: OMSAccess.h:71
Transaction & transaction()
Definition: Session.cc:52
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:18
unsigned long long Time_t
Definition: Time.h:14
bool isNewTagRequest(const std::string &recordName)
std::string Hash
Definition: Types.h:43
cond::persistency::Session m_session
cond::persistency::Logger m_logger
Record & getRecord(const std::string &recordName)
bool appendSinceTime(const std::string &payloadId, cond::Time_t sinceTime, const std::string &recordName)
void createNewIOV(const std::string &firstPayloadId, cond::Time_t firstSinceTime, const std::string &recordName)
bool getTagInfo(const std::string &recordName, cond::TagInfo_t &result)
cond::Hash storePayload(const T &payload, const boost::posix_time::ptime &creationTime=boost::posix_time::microsec_clock::universal_time())
Definition: Session.h:186
EchoedLogStream< edm::LogInfo > logInfo()
Definition: Logger.cc:157
const Time_t MAX_VAL(std::numeric_limits< Time_t >::max())

Member Data Documentation

◆ m_autoCommit

bool cond::service::PoolDBOutputService::m_autoCommit
private

Definition at line 304 of file PoolDBOutputService.h.

Referenced by appendOneIOV(), createOneIOV(), writeMany(), and writeOneIOV().

◆ m_connection

cond::persistency::ConnectionPool cond::service::PoolDBOutputService::m_connection
private

Definition at line 301 of file PoolDBOutputService.h.

◆ m_currentTimes

std::vector<cond::Time_t> cond::service::PoolDBOutputService::m_currentTimes
private

Definition at line 299 of file PoolDBOutputService.h.

◆ m_dbInitialised

bool cond::service::PoolDBOutputService::m_dbInitialised
private

Definition at line 306 of file PoolDBOutputService.h.

◆ m_logger

cond::persistency::Logger cond::service::PoolDBOutputService::m_logger
private

Definition at line 296 of file PoolDBOutputService.h.

Referenced by logger(), writeMany(), and writeOneIOV().

◆ m_logheaders

std::map<std::string, cond::UserLogInfo> cond::service::PoolDBOutputService::m_logheaders
private

Definition at line 309 of file PoolDBOutputService.h.

Referenced by fillRecord().

◆ m_mutex

std::recursive_mutex cond::service::PoolDBOutputService::m_mutex
private

Definition at line 297 of file PoolDBOutputService.h.

Referenced by appendOneIOV(), createOneIOV(), writeMany(), and writeOneIOV().

◆ m_records

std::map<std::string, Record> cond::service::PoolDBOutputService::m_records
private

Definition at line 308 of file PoolDBOutputService.h.

Referenced by fillRecord().

◆ m_session

cond::persistency::Session cond::service::PoolDBOutputService::m_session
private

Definition at line 302 of file PoolDBOutputService.h.

Referenced by appendOneIOV(), createOneIOV(), writeMany(), and writeOneIOV().

◆ m_timetype

cond::TimeType cond::service::PoolDBOutputService::m_timetype
private

Definition at line 298 of file PoolDBOutputService.h.

◆ m_transactionActive

bool cond::service::PoolDBOutputService::m_transactionActive
private

Definition at line 303 of file PoolDBOutputService.h.

◆ m_writeTransactionDelay

unsigned int cond::service::PoolDBOutputService::m_writeTransactionDelay = 0
private

Definition at line 305 of file PoolDBOutputService.h.