CMS 3D CMS Logo

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

#include <OnlineDBOutputService.h>

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

Public Member Functions

 OnlineDBOutputService (const edm::ParameterSet &iConfig, edm::ActivityRegistry &iAR)
 
cond::Iov_t preLoadIov (const std::string &recordName, cond::Time_t targetTime)
 
template<typename PayloadType >
bool writeForNextLumisection (const PayloadType *payload, const std::string &recordName)
 
 ~OnlineDBOutputService () override
 
- Public Member Functions inherited from cond::service::PoolDBOutputService
bool appendSinceTime (const std::string &payloadId, cond::Time_t sinceTime, const std::string &recordName)
 
template<typename T >
void appendSinceTime (const T *payloadObj, 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 createNewIOV (const T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t, 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)
 
cond::persistency::Loggerlogger ()
 
cond::persistency::Session newReadOnlySession (const std::string &connectionString, const std::string &transactionId)
 
 PoolDBOutputService (const edm::ParameterSet &iConfig, edm::ActivityRegistry &iAR)
 
void postEndJob ()
 
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 >
Hash writeOne (const T *payload, Time_t time, const std::string &recordName)
 
virtual ~PoolDBOutputService ()
 

Private Member Functions

cond::Time_t getLastLumiProcessed ()
 
cond::persistency::Session getReadOnlyCache (cond::Time_t targetTime)
 

Private Attributes

bool m_debug
 
std::string m_lastLumiFile
 
std::string m_lastLumiUrl
 
size_t m_latencyInLumisections
 
std::string m_omsServiceUrl
 
std::string m_preLoadConnectionString
 
cond::Time_t m_runNumber
 

Detailed Description

Definition at line 30 of file OnlineDBOutputService.h.

Constructor & Destructor Documentation

◆ OnlineDBOutputService()

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

Definition at line 80 of file OnlineDBOutputService.cc.

82  : PoolDBOutputService(iConfig, iAR),
83  m_runNumber(iConfig.getUntrackedParameter<unsigned long long>("runNumber", 0)),
84  m_latencyInLumisections(iConfig.getUntrackedParameter<unsigned int>("latency", 1)),
85  m_omsServiceUrl(iConfig.getUntrackedParameter<std::string>("omsServiceUrl", "")),
86  m_lastLumiUrl(iConfig.getUntrackedParameter<std::string>("lastLumiUrl", "")),
87  m_preLoadConnectionString(iConfig.getUntrackedParameter<std::string>("preLoadConnectionString", "")),
88  m_debug(iConfig.getUntrackedParameter<bool>("debugLogging", false)) {
89  if (m_omsServiceUrl.empty()) {
90  if (!m_lastLumiUrl.empty()) {
93  if (lastRun.isOnGoing()) {
94  m_runNumber = lastRun.run;
95  }
96  } else {
97  m_lastLumiFile = iConfig.getUntrackedParameter<std::string>("lastLumiFile", "");
98  }
99  }
100 }

References cond::persistency::Session::getLastRun(), edm::ParameterSet::getUntrackedParameter(), SiStripBadComponentsDQMServiceTemplate_cfg::lastRun, m_lastLumiFile, m_lastLumiUrl, m_omsServiceUrl, m_runNumber, cond::service::PoolDBOutputService::session(), cond::service::PoolDBOutputService::startTransaction(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~OnlineDBOutputService()

OnlineDBOutputService::~OnlineDBOutputService ( )
override

Definition at line 102 of file OnlineDBOutputService.cc.

102 {}

Member Function Documentation

◆ getLastLumiProcessed()

cond::Time_t OnlineDBOutputService::getLastLumiProcessed ( )
private

Definition at line 104 of file OnlineDBOutputService.cc.

104  {
105  cond::Time_t lastLumiProcessed = cond::time::MIN_VAL;
106  std::string info("");
107  if (!m_omsServiceUrl.empty()) {
108  lastLumiProcessed = cond::getLastLumiFromOMS(m_omsServiceUrl);
109  logger().logInfo() << "Last lumi: " << lastLumiProcessed
110  << " Current run: " << cond::time::unpack(lastLumiProcessed).first
111  << " lumi id:" << cond::time::unpack(lastLumiProcessed).second;
112  } else {
113  if (!m_lastLumiUrl.empty()) {
114  std::string info("");
116  throw Exception("Can't get last Lumisection from DAQ.");
117  unsigned int lastL = boost::lexical_cast<unsigned int>(info);
118  lastLumiProcessed = cond::time::lumiTime(m_runNumber, lastL);
119  logger().logInfo() << "Last lumi: " << lastLumiProcessed << " Current run: " << m_runNumber
120  << " lumi id:" << lastL;
121  } else {
122  if (m_lastLumiFile.empty()) {
123  throw Exception("File name for last lumi has not been provided.");
124  } else {
125  lastLumiProcessed = cond::getLatestLumiFromFile(m_lastLumiFile);
126  auto upkTime = cond::time::unpack(lastLumiProcessed);
127  logger().logInfo() << "Last lumi: " << lastLumiProcessed << " Current run: " << upkTime.first
128  << " lumi id:" << upkTime.second;
129  }
130  }
131  }
132  return lastLumiProcessed;
133 }

References getInfoFromDAQ(), cond::getLastLumiFromOMS(), cond::getLatestLumiFromFile(), info(), fwlog::logger(), cond::time::lumiTime(), cond::time::MIN_VAL(), AlCaHLTBitMon_QueryRunRegistry::string, and cond::time::unpack().

Referenced by writeForNextLumisection().

◆ getReadOnlyCache()

cond::persistency::Session OnlineDBOutputService::getReadOnlyCache ( cond::Time_t  targetTime)
private

Definition at line 145 of file OnlineDBOutputService.cc.

145  {
146  return PoolDBOutputService::newReadOnlySession(m_preLoadConnectionString, std::to_string(targetTime));
147 }

References cond::service::PoolDBOutputService::newReadOnlySession().

◆ preLoadIov()

cond::Iov_t OnlineDBOutputService::preLoadIov ( const std::string &  recordName,
cond::Time_t  targetTime 
)

◆ writeForNextLumisection()

template<typename PayloadType >
bool cond::service::OnlineDBOutputService::writeForNextLumisection ( const PayloadType *  payload,
const std::string &  recordName 
)
inline

Definition at line 40 of file OnlineDBOutputService.h.

40  {
43  logger().logInfo() << "Updating lumisection " << targetTime;
44  cond::Hash payloadId = PoolDBOutputService::writeOne<PayloadType>(payload, targetTime, recordName);
45  bool ret = true;
46  if (payloadId.empty()) {
47  return false;
48  }
50  auto w_lat = std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count();
51  logger().logInfo() << "Update has taken " << w_lat << " microsecs.";
52  // check for late updates...
53  cond::Time_t lastProcessed = getLastLumiProcessed();
54  logger().logInfo() << "Last lumisection processed after update: " << lastProcessed;
55  // check the pre-loaded iov
56  logger().logInfo() << "Preloading lumisection " << targetTime;
58  cond::Iov_t usedIov = preLoadIov(recordName, targetTime);
60  logger().logInfo() << "Iov for preloaded lumisection " << targetTime << " is " << usedIov.since;
61  auto p_lat = std::chrono::duration_cast<std::chrono::microseconds>(t3 - t2).count();
62  logger().logInfo() << "Preload has taken " << p_lat << " microsecs.";
63  if (usedIov.since < targetTime) {
64  logger().logWarning() << "Found a late update for lumisection " << targetTime << "(found since "
65  << usedIov.since << "). A revert is required.";
66  PoolDBOutputService::eraseSinceTime(payloadId, targetTime, recordName);
68  ret = false;
69  }
71  auto t_lat = std::chrono::duration_cast<std::chrono::microseconds>(t4 - t0).count();
72  logger().logInfo() << "Total update time: " << t_lat << " microsecs.";
73  return ret;
74  }

References cond::service::PoolDBOutputService::commitTransaction(), cond::service::PoolDBOutputService::eraseSinceTime(), getLastLumiProcessed(), cond::service::PoolDBOutputService::logger(), cond::persistency::Logger::logInfo(), cond::persistency::Logger::logWarning(), m_latencyInLumisections, fileCollector::now, jets_cff::payload, preLoadIov(), align_cfg::recordName, runTheMatrix::ret, cond::Iov_t::since, FrontierCondition_GT_autoExpress_cfi::t0, RandomServiceHelper::t1, RandomServiceHelper::t2, and RandomServiceHelper::t3.

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

Member Data Documentation

◆ m_debug

bool cond::service::OnlineDBOutputService::m_debug
private

Definition at line 88 of file OnlineDBOutputService.h.

◆ m_lastLumiFile

std::string cond::service::OnlineDBOutputService::m_lastLumiFile
private

Definition at line 86 of file OnlineDBOutputService.h.

Referenced by OnlineDBOutputService().

◆ m_lastLumiUrl

std::string cond::service::OnlineDBOutputService::m_lastLumiUrl
private

Definition at line 85 of file OnlineDBOutputService.h.

Referenced by OnlineDBOutputService().

◆ m_latencyInLumisections

size_t cond::service::OnlineDBOutputService::m_latencyInLumisections
private

Definition at line 83 of file OnlineDBOutputService.h.

Referenced by writeForNextLumisection().

◆ m_omsServiceUrl

std::string cond::service::OnlineDBOutputService::m_omsServiceUrl
private

Definition at line 84 of file OnlineDBOutputService.h.

Referenced by OnlineDBOutputService().

◆ m_preLoadConnectionString

std::string cond::service::OnlineDBOutputService::m_preLoadConnectionString
private

Definition at line 87 of file OnlineDBOutputService.h.

◆ m_runNumber

cond::Time_t cond::service::OnlineDBOutputService::m_runNumber
private

Definition at line 82 of file OnlineDBOutputService.h.

Referenced by OnlineDBOutputService().

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
cond::persistency::TransactionScope
Definition: Session.h:231
RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
cond::time::MIN_VAL
const Time_t MIN_VAL(0)
cond::service::OnlineDBOutputService::m_preLoadConnectionString
std::string m_preLoadConnectionString
Definition: OnlineDBOutputService.h:87
cond::service::PoolDBOutputService::tag
std::string tag(const std::string &recordName)
Definition: PoolDBOutputService.cc:96
cond::service::OnlineDBOutputService::m_latencyInLumisections
size_t m_latencyInLumisections
Definition: OnlineDBOutputService.h:83
cond::Hash
std::string Hash
Definition: Types.h:43
cond::persistency::IOVProxy::getInterval
cond::Iov_t getInterval(cond::Time_t time)
Definition: IOVProxy.cc:317
cond::service::PoolDBOutputService::eraseSinceTime
void eraseSinceTime(const std::string &payloadId, cond::Time_t sinceTime, const std::string &recordName)
Definition: PoolDBOutputService.cc:275
cond::service::OnlineDBOutputService::m_debug
bool m_debug
Definition: OnlineDBOutputService.h:88
cond::service::OnlineDBOutputService::m_omsServiceUrl
std::string m_omsServiceUrl
Definition: OnlineDBOutputService.h:84
align_cfg.recordName
recordName
Definition: align_cfg.py:66
cond::getLastLumiFromOMS
cond::Time_t getLastLumiFromOMS(const std::string &omsServiceUrl)
Definition: OnlineDBOutputService.cc:58
cond::getLatestLumiFromFile
cond::Time_t getLatestLumiFromFile(const std::string &fileName)
Definition: OnlineDBOutputService.cc:47
SiStripBadComponentsDQMServiceTemplate_cfg.lastRun
lastRun
Definition: SiStripBadComponentsDQMServiceTemplate_cfg.py:27
cond::persistency::TransactionScope::start
void start(bool readOnly=true)
Definition: Session.cc:236
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
cond::persistency::Logger::logInfo
EchoedLogStream< edm::LogInfo > logInfo()
Definition: Logger.cc:153
cond::service::OnlineDBOutputService::m_lastLumiUrl
std::string m_lastLumiUrl
Definition: OnlineDBOutputService.h:85
fileCollector.now
now
Definition: fileCollector.py:207
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
cond::persistency::Session::getLastRun
cond::RunInfo_t getLastRun()
Definition: Session.cc:201
FrontierCondition_GT_autoExpress_cfi.t0
t0
Definition: FrontierCondition_GT_autoExpress_cfi.py:148
cond::service::PoolDBOutputService::session
cond::persistency::Session session() const
Definition: PoolDBOutputService.cc:94
cond::service::OnlineDBOutputService::getReadOnlyCache
cond::persistency::Session getReadOnlyCache(cond::Time_t targetTime)
Definition: OnlineDBOutputService.cc:145
cond::service::PoolDBOutputService::commitTransaction
void commitTransaction()
Definition: PoolDBOutputService.cc:124
jets_cff.payload
payload
Definition: jets_cff.py:34
RandomServiceHelper.t3
t3
Definition: RandomServiceHelper.py:258
cond::persistency::Session::readIov
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond::persistency::IOVProxy
Definition: IOVProxy.h:92
cond::persistency::Logger::logWarning
EchoedLogStream< edm::LogWarning > logWarning()
Definition: Logger.cc:165
cond::service::OnlineDBOutputService::getLastLumiProcessed
cond::Time_t getLastLumiProcessed()
Definition: OnlineDBOutputService.cc:104
cond::persistency::Session
Definition: Session.h:63
cond::Iov_t::since
Time_t since
Definition: Types.h:53
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
cond::Exception
persistency::Exception Exception
Definition: Exception.h:25
cond::time::lumiTime
Time_t lumiTime(unsigned int run, unsigned int lumiId)
Definition: Time.cc:54
cond::persistency::Session::transaction
Transaction & transaction()
Definition: Session.cc:52
cond::service::PoolDBOutputService::logger
cond::persistency::Logger & logger()
Definition: PoolDBOutputService.h:189
getInfoFromDAQ
bool getInfoFromDAQ(const std::string &urlString, std::string &info)
Definition: OnlineDBOutputService.cc:12
cond::service::PoolDBOutputService::newReadOnlySession
cond::persistency::Session newReadOnlySession(const std::string &connectionString, const std::string &transactionId)
Definition: PoolDBOutputService.cc:87
cond::time::unpack
cond::UnpackedTime unpack(cond::Time_t iValue)
Definition: TimeConversions.h:22
cond::Iov_t
Definition: Types.h:47
cond::service::OnlineDBOutputService::preLoadIov
cond::Iov_t preLoadIov(const std::string &recordName, cond::Time_t targetTime)
Definition: OnlineDBOutputService.cc:135
cond::service::PoolDBOutputService::startTransaction
void startTransaction()
Definition: PoolDBOutputService.cc:119
cond::service::PoolDBOutputService::PoolDBOutputService
PoolDBOutputService(const edm::ParameterSet &iConfig, edm::ActivityRegistry &iAR)
Definition: PoolDBOutputService.cc:37
cond::service::OnlineDBOutputService::m_lastLumiFile
std::string m_lastLumiFile
Definition: OnlineDBOutputService.h:86
cond::service::OnlineDBOutputService::m_runNumber
cond::Time_t m_runNumber
Definition: OnlineDBOutputService.h:82