CMS 3D CMS Logo

OnlineDBOutputService.h
Go to the documentation of this file.
1 #ifndef CondCore_OnlineDBOutputService_h
2 #define CondCore_OnlineDBOutputService_h
5 #include <string>
6 #include <map>
7 #include <fstream>
8 #include <mutex>
9 #include <chrono>
10 
11 //
12 // Package: DBOutputService
13 // Class : OnlineDBOutputService
14 //
18 //
19 // Author: Giacomo Govi
20 //
21 
22 namespace cond {
23 
25 
27 
28  namespace service {
29 
31  public:
33 
34  ~OnlineDBOutputService() override;
35 
37 
38  //
39  template <typename PayloadType>
40  bool writeForNextLumisection(const PayloadType* payload, const std::string& recordName) {
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  }
75 
76  private:
78 
80 
81  private:
88  bool m_debug;
89 
90  }; //OnlineDBOutputService
91  } // namespace service
92 } // namespace cond
93 #endif
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
cond::service::OnlineDBOutputService::m_preLoadConnectionString
std::string m_preLoadConnectionString
Definition: OnlineDBOutputService.h:86
service
Definition: service.py:1
cond::service::OnlineDBOutputService::m_latencyInLumisections
size_t m_latencyInLumisections
Definition: OnlineDBOutputService.h:83
MessageLogger.h
cond::service::OnlineDBOutputService::writeForNextLumisection
bool writeForNextLumisection(const PayloadType *payload, const std::string &recordName)
Definition: OnlineDBOutputService.h:40
cond::Hash
std::string Hash
Definition: Types.h:43
cond::service::OnlineDBOutputService::m_frontierKey
std::string m_frontierKey
Definition: OnlineDBOutputService.h:87
submitPVValidationJobs.now
now
Definition: submitPVValidationJobs.py:639
cond::service::PoolDBOutputService::eraseSinceTime
void eraseSinceTime(const std::string &payloadId, cond::Time_t sinceTime, const std::string &recordName)
Definition: PoolDBOutputService.cc:303
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
cond::service::PoolDBOutputService
Definition: PoolDBOutputService.h:33
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
cond::persistency::Logger::logInfo
EchoedLogStream< edm::LogInfo > logInfo()
Definition: Logger.cc:157
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
cond::service::OnlineDBOutputService
Definition: OnlineDBOutputService.h:30
PoolDBOutputService.h
FrontierCondition_GT_autoExpress_cfi.t0
t0
Definition: FrontierCondition_GT_autoExpress_cfi.py:149
cond::service::OnlineDBOutputService::getReadOnlyCache
cond::persistency::Session getReadOnlyCache(cond::Time_t targetTime)
Definition: OnlineDBOutputService.cc:127
edm::ActivityRegistry
Definition: ActivityRegistry.h:134
cond::service::PoolDBOutputService::commitTransaction
void commitTransaction()
Definition: PoolDBOutputService.cc:152
jets_cff.payload
payload
Definition: jets_cff.py:32
RandomServiceHelper.t3
t3
Definition: RandomServiceHelper.py:258
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
cond::persistency::Logger::logWarning
EchoedLogStream< edm::LogWarning > logWarning()
Definition: Logger.cc:169
edm::ParameterSet
Definition: ParameterSet.h:47
cond::service::OnlineDBOutputService::getLastLumiProcessed
cond::Time_t getLastLumiProcessed()
Definition: OnlineDBOutputService.cc:96
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::service::OnlineDBOutputService::~OnlineDBOutputService
~OnlineDBOutputService() override
Definition: OnlineDBOutputService.cc:94
cond::service::PoolDBOutputService::logger
cond::persistency::Logger & logger()
Definition: PoolDBOutputService.h:195
beam_dqm_sourceclient-live_cfg.omsServiceUrl
omsServiceUrl
Definition: beam_dqm_sourceclient-live_cfg.py:378
cond::service::OnlineDBOutputService::OnlineDBOutputService
OnlineDBOutputService(const edm::ParameterSet &iConfig, edm::ActivityRegistry &iAR)
Definition: OnlineDBOutputService.cc:80
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:117
cond::service::OnlineDBOutputService::m_lastLumiFile
std::string m_lastLumiFile
Definition: OnlineDBOutputService.h:85
cond::service::OnlineDBOutputService::m_runNumber
cond::Time_t m_runNumber
Definition: OnlineDBOutputService.h:82