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)
 
template<typename PayloadType >
cond::Time_t writeIOVForNextLumisection (const PayloadType &payload, const std::string &recordName)
 
 ~OnlineDBOutputService () override
 
- Public Member Functions inherited from cond::service::PoolDBOutputService
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

cond::Time_t getLastLumiProcessed ()
 
cond::Iov_t preLoadIov (const PoolDBOutputService::Record &record, cond::Time_t targetTime)
 

Private Attributes

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

Additional Inherited Members

- Static Public Attributes inherited from cond::service::PoolDBOutputService
static const std::string kSharedResource = "PoolDBOutputService"
 

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.

References edm::ParameterSet::getUntrackedParameter(), m_lastLumiFile, m_omsServiceUrl, and AlCaHLTBitMon_QueryRunRegistry::string.

82  : PoolDBOutputService(iConfig, iAR),
83  m_runNumber(iConfig.getUntrackedParameter<unsigned long long>("runNumber", 1)),
84  m_latencyInLumisections(iConfig.getUntrackedParameter<unsigned int>("latency", 1)),
85  m_omsServiceUrl(iConfig.getUntrackedParameter<std::string>("omsServiceUrl", "")),
86  m_preLoadConnectionString(iConfig.getUntrackedParameter<std::string>("preLoadConnectionString", "")),
87  m_frontierKey(iConfig.getUntrackedParameter<std::string>("frontierKey", "")),
88  m_debug(iConfig.getUntrackedParameter<bool>("debugLogging", false)) {
89  if (m_omsServiceUrl.empty()) {
90  m_lastLumiFile = iConfig.getUntrackedParameter<std::string>("lastLumiFile", "");
91  }
92 }
T getUntrackedParameter(std::string const &, T const &) const
PoolDBOutputService(const edm::ParameterSet &iConfig, edm::ActivityRegistry &iAR)

◆ ~OnlineDBOutputService()

OnlineDBOutputService::~OnlineDBOutputService ( )
override

Definition at line 94 of file OnlineDBOutputService.cc.

94 {}

Member Function Documentation

◆ getLastLumiProcessed()

cond::Time_t OnlineDBOutputService::getLastLumiProcessed ( )
private

Definition at line 96 of file OnlineDBOutputService.cc.

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

Referenced by writeIOVForNextLumisection().

96  {
97  cond::Time_t lastLumiProcessed = cond::time::MIN_VAL;
98  std::string info("");
99  if (!m_omsServiceUrl.empty()) {
100  lastLumiProcessed = cond::getLastLumiFromOMS(m_omsServiceUrl);
101  logger().logInfo() << "Last lumi: " << lastLumiProcessed
102  << " Current run: " << cond::time::unpack(lastLumiProcessed).first
103  << " lumi id:" << cond::time::unpack(lastLumiProcessed).second;
104  } else {
105  if (!m_lastLumiFile.empty()) {
106  lastLumiProcessed = cond::getLatestLumiFromFile(m_lastLumiFile);
107  auto upkTime = cond::time::unpack(lastLumiProcessed);
108  logger().logInfo() << "Last lumi: " << lastLumiProcessed << " Current run: " << upkTime.first
109  << " lumi id:" << upkTime.second;
110  } else {
111  lastLumiProcessed = cond::time::lumiTime(m_runNumber, 1);
112  }
113  }
114  return lastLumiProcessed;
115 }
static const TGPicture * info(bool iBackgroundIsBlack)
cond::Time_t getLastLumiFromOMS(const std::string &omsServiceUrl)
const Time_t MIN_VAL(0)
unsigned long long Time_t
Definition: Time.h:14
Time_t lumiTime(unsigned int run, unsigned int lumiId)
Definition: Time.cc:66
cond::persistency::Logger & logger()
cond::Time_t getLatestLumiFromFile(const std::string &fileName)
EchoedLogStream< edm::LogInfo > logInfo()
Definition: Logger.cc:157
cond::UnpackedTime unpack(cond::Time_t iValue)

◆ preLoadIov()

cond::Iov_t OnlineDBOutputService::preLoadIov ( const PoolDBOutputService::Record record,
cond::Time_t  targetTime 
)
private

Definition at line 117 of file OnlineDBOutputService.cc.

References cond::persistency::IOVProxy::getInterval(), cond::service::PoolDBOutputService::newReadOnlySession(), cond::persistency::Session::readIov(), AlCaHarvesting_cff::record, cond::persistency::TransactionScope::start(), cond::persistency::Session::transaction(), and cond::time::transactionIdForLumiTime().

Referenced by writeIOVForNextLumisection().

118  {
119  auto transId = cond::time::transactionIdForLumiTime(targetTime, record.m_refreshTime, m_frontierKey);
122  transaction.start(true);
124  auto iov = proxy.getInterval(targetTime);
125  transaction.commit();
126  return iov;
127 }
Transaction & transaction()
Definition: Session.cc:52
std::string transactionIdForLumiTime(Time_t time, unsigned int iovSize, const std::string &secretKey)
Definition: Time.cc:150
void start(bool readOnly=true)
Definition: Session.cc:236
cond::Iov_t getInterval(cond::Time_t time)
Definition: IOVProxy.cc:320
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
cond::persistency::Session newReadOnlySession(const std::string &connectionString, const std::string &transactionId)
cond::persistency::Session session() const

◆ writeIOVForNextLumisection()

template<typename PayloadType >
cond::Time_t cond::service::OnlineDBOutputService::writeIOVForNextLumisection ( const PayloadType &  payload,
const std::string &  recordName 
)
inline

Definition at line 37 of file OnlineDBOutputService.h.

References cond::service::PoolDBOutputService::commitTransaction(), submitPVResolutionJobs::count, cond::service::PoolDBOutputService::eraseSinceTime(), getLastLumiProcessed(), cond::service::PoolDBOutputService::logger(), cond::persistency::Logger::logInfo(), cond::persistency::Logger::logWarning(), cond::service::PoolDBOutputService::lookUpRecord(), cond::time::lumiTime(), m_latencyInLumisections, submitPVValidationJobs::now, jetsAK4_Puppi_cff::payload, preLoadIov(), align_cfg::recordName, cond::Iov_t::since, FrontierCondition_GT_autoExpress_cfi::t0, RandomServiceHelper::t1, RandomServiceHelper::t2, RandomServiceHelper::t3, and cond::time::unpack().

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

37  {
40  auto unpkLastTime = cond::time::unpack(lastTime);
41  cond::Time_t targetTime =
42  cond::time::lumiTime(unpkLastTime.first, unpkLastTime.second + m_latencyInLumisections);
44  logger().logInfo() << "Updating lumisection " << targetTime;
45  cond::Hash payloadId = PoolDBOutputService::writeOneIOV<PayloadType>(payload, targetTime, recordName);
47  if (payloadId.empty()) {
48  return 0;
49  }
51  auto w_lat = std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count();
52  logger().logInfo() << "Update has taken " << w_lat << " microsecs.";
53  // check for late updates...
54  cond::Time_t lastProcessed = getLastLumiProcessed();
55  logger().logInfo() << "Last lumisection processed after update: " << lastProcessed;
56  // check the pre-loaded iov
57  logger().logInfo() << "Preloading lumisection " << targetTime;
59  cond::Iov_t usedIov = preLoadIov(rec, targetTime);
61  logger().logInfo() << "Iov for preloaded lumisection " << targetTime << " is " << usedIov.since;
62  auto p_lat = std::chrono::duration_cast<std::chrono::microseconds>(t3 - t2).count();
63  logger().logInfo() << "Preload has taken " << p_lat << " microsecs.";
64  if (usedIov.since < targetTime) {
65  logger().logWarning() << "Found a late update for lumisection " << targetTime << "(found since "
66  << usedIov.since << "). A revert is required.";
67  PoolDBOutputService::eraseSinceTime(payloadId, targetTime, recordName);
69  targetTime = 0;
70  }
72  auto t_lat = std::chrono::duration_cast<std::chrono::microseconds>(t4 - t0).count();
73  logger().logInfo() << "Total update time: " << t_lat << " microsecs.";
74  return targetTime;
75  }
const Record & lookUpRecord(const std::string &recordName)
EchoedLogStream< edm::LogWarning > logWarning()
Definition: Logger.cc:169
Time_t since
Definition: Types.h:53
unsigned long long Time_t
Definition: Time.h:14
Time_t lumiTime(unsigned int run, unsigned int lumiId)
Definition: Time.cc:66
cond::persistency::Logger & logger()
std::string Hash
Definition: Types.h:43
cond::Iov_t preLoadIov(const PoolDBOutputService::Record &record, cond::Time_t targetTime)
EchoedLogStream< edm::LogInfo > logInfo()
Definition: Logger.cc:157
void eraseSinceTime(const std::string &payloadId, cond::Time_t sinceTime, const std::string &recordName)
cond::UnpackedTime unpack(cond::Time_t iValue)

Member Data Documentation

◆ m_debug

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

Definition at line 89 of file OnlineDBOutputService.h.

◆ m_frontierKey

std::string cond::service::OnlineDBOutputService::m_frontierKey
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_latencyInLumisections

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

Definition at line 84 of file OnlineDBOutputService.h.

Referenced by writeIOVForNextLumisection().

◆ m_omsServiceUrl

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

Definition at line 85 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 83 of file OnlineDBOutputService.h.