CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
popcon::OnlinePopCon Class Reference

#include <OnlinePopCon.h>

Public Types

typedef cond::Time_t Time_t
 

Public Member Functions

 OnlinePopCon (const edm::ParameterSet &pset)
 
template<typename Source >
void write (Source const &source)
 
virtual ~OnlinePopCon ()
 

Private Member Functions

void finalize ()
 
cond::persistency::Session initialize ()
 
cond::persistency::Session preparePopCon ()
 

Private Attributes

std::string m_authPath
 
int m_authSys
 
int m_dbLoggerReturn_
 
edm::Service< cond::service::OnlineDBOutputServicem_dbService
 
cond::LogDBEntry_t m_logDBEntry
 
std::string m_recordName
 
cond::TagInfo_t m_tagInfo
 
std::string m_targetConnectionString
 
cond::persistency::Session m_targetSession
 
bool m_useLockRecors
 

Static Private Attributes

static constexpr const char *const s_version = "1.0"
 

Detailed Description

Definition at line 26 of file OnlinePopCon.h.

Member Typedef Documentation

◆ Time_t

Definition at line 28 of file OnlinePopCon.h.

Constructor & Destructor Documentation

◆ OnlinePopCon()

popcon::OnlinePopCon::OnlinePopCon ( const edm::ParameterSet pset)

Definition at line 12 of file OnlinePopCon.cc.

References s_version.

13  : m_targetSession(),
14  m_targetConnectionString(pset.getUntrackedParameter<std::string>("targetDBConnectionString", "")),
15  m_authPath(pset.getUntrackedParameter<std::string>("authenticationPath", "")),
16  m_authSys(pset.getUntrackedParameter<int>("authenticationSystem", 1)),
17  m_recordName(pset.getParameter<std::string>("record")),
18  m_useLockRecors(pset.getUntrackedParameter<bool>("useLockRecords", false)) {
19  edm::LogInfo("OnlinePopCon")
20  << "This is OnlinePopCon (Populator of Condition) v" << s_version << ".\n"
21  << "Please report any problem and feature request through the JIRA project CMSCONDDB.\n";
22  }
std::string m_authPath
Definition: OnlinePopCon.h:49
Log< level::Info, false > LogInfo
cond::persistency::Session m_targetSession
Definition: OnlinePopCon.h:47
static constexpr const char *const s_version
Definition: OnlinePopCon.h:60
std::string m_recordName
Definition: OnlinePopCon.h:51
std::string m_targetConnectionString
Definition: OnlinePopCon.h:48

◆ ~OnlinePopCon()

popcon::OnlinePopCon::~OnlinePopCon ( )
virtual

Definition at line 24 of file OnlinePopCon.cc.

References cond::persistency::Transaction::commit(), m_targetConnectionString, m_targetSession, and cond::persistency::Session::transaction().

24  {
25  if (!m_targetConnectionString.empty()) {
27  }
28  }
Transaction & transaction()
Definition: Session.cc:52
cond::persistency::Session m_targetSession
Definition: OnlinePopCon.h:47
std::string m_targetConnectionString
Definition: OnlinePopCon.h:48

Member Function Documentation

◆ finalize()

void popcon::OnlinePopCon::finalize ( )
private

Definition at line 90 of file OnlinePopCon.cc.

References cond::persistency::Transaction::commit(), cond::service::PoolDBOutputService::commitTransaction(), cond::persistency::Logger::end(), Exception, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::logger(), cond::persistency::Logger::logInfo(), m_dbLoggerReturn_, m_dbService, m_recordName, m_targetConnectionString, m_targetSession, m_useLockRecors, cond::service::PoolDBOutputService::releaseLocks(), and cond::persistency::Session::transaction().

Referenced by write().

90  {
91  // Check if DB service is available
92  if (!m_dbService.isAvailable()) {
93  throw Exception("OnlinePopCon", "[finalize] DBService not available");
94  }
95 
96  // Release locks if previously locked
97  if (m_useLockRecors) {
98  m_dbService->logger().logInfo() << "OnlinePopCon::finalize - releasing locks";
100  }
101 
102  // Finalize PopCon infrastructure
103  if (m_targetConnectionString.empty()) {
105  } else {
107  }
108 
109  // Stop DB logging service
110  m_dbService->logger().logInfo() << "OnlinePopCon::finalize - end logging for record: " << m_recordName;
112  }
edm::Service< cond::service::OnlineDBOutputService > m_dbService
Definition: OnlinePopCon.h:44
Transaction & transaction()
Definition: Session.cc:52
cond::persistency::Logger & logger()
cond::persistency::Session m_targetSession
Definition: OnlinePopCon.h:47
bool isAvailable() const
Definition: Service.h:40
EchoedLogStream< edm::LogInfo > logInfo()
Definition: Logger.cc:157
void end(int retCode)
Definition: Logger.cc:80
std::string m_recordName
Definition: OnlinePopCon.h:51
std::string m_targetConnectionString
Definition: OnlinePopCon.h:48

◆ initialize()

cond::persistency::Session popcon::OnlinePopCon::initialize ( )
private

Definition at line 68 of file OnlinePopCon.cc.

References Exception, edm::Service< T >::isAvailable(), cond::service::PoolDBOutputService::lockRecords(), cond::service::PoolDBOutputService::logger(), cond::persistency::Logger::logInfo(), m_dbLoggerReturn_, m_dbService, m_recordName, m_useLockRecors, preparePopCon(), run_AlCaRecoTriggerBitsUpdateWorkflow::session, and cond::persistency::Logger::start().

Referenced by write().

68  {
69  // Check if DB service is available
70  if (!m_dbService.isAvailable()) {
71  throw Exception("OnlinePopCon", "[initialize] DBService not available");
72  }
73 
74  // Start DB logging service
77  m_dbService->logger().logInfo() << "OnlinePopCon::initialize - begin logging for record: " << m_recordName;
78 
79  // If requested, lock records
80  if (m_useLockRecors) {
81  m_dbService->logger().logInfo() << "OnlinePopCon::initialize - locking records";
83  }
84 
85  // Prepare the rest of PopCon infrastructure
86  auto session = preparePopCon();
87  return session;
88  }
edm::Service< cond::service::OnlineDBOutputService > m_dbService
Definition: OnlinePopCon.h:44
cond::persistency::Logger & logger()
cond::persistency::Session preparePopCon()
Definition: OnlinePopCon.cc:30
bool isAvailable() const
Definition: Service.h:40
EchoedLogStream< edm::LogInfo > logInfo()
Definition: Logger.cc:157
std::string m_recordName
Definition: OnlinePopCon.h:51

◆ preparePopCon()

cond::persistency::Session popcon::OnlinePopCon::preparePopCon ( )
private

Definition at line 30 of file OnlinePopCon.cc.

References cond::persistency::ConnectionPool::configure(), cond::persistency::Session::connectionString(), cond::persistency::ConnectionPool::createSession(), cond::persistency::Session::existsDatabase(), cond::persistency::Session::existsIov(), cond::service::PoolDBOutputService::forceInit(), cond::persistency::IOVProxy::getLast(), cond::TagInfo_t::lastInterval, cond::service::PoolDBOutputService::logger(), cond::persistency::Logger::logInfo(), m_authPath, m_authSys, m_dbService, m_recordName, m_tagInfo, m_targetConnectionString, m_targetSession, cond::TagInfo_t::name, cond::persistency::Session::readIov(), cond::persistency::IOVProxy::sequenceSize(), cond::service::PoolDBOutputService::session(), cond::persistency::ConnectionPool::setAuthenticationPath(), cond::persistency::ConnectionPool::setAuthenticationSystem(), cond::Iov_t::since, cond::TagInfo_t::size, cond::persistency::Transaction::start(), cond::service::PoolDBOutputService::startTransaction(), AlCaHLTBitMon_QueryRunRegistry::string, cond::service::PoolDBOutputService::tag(), dcs_print_summary_cfg::tagName, cond::Iov_t::till, and cond::persistency::Session::transaction().

Referenced by initialize().

30  {
31  // Initialization almost identical to PopCon
32  const std::string& connectionStr = m_dbService->session().connectionString();
36  if (m_targetConnectionString.empty()) {
39  } else {
43  connPool.configure();
46  }
47 
48  m_dbService->logger().logInfo() << "OnlinePopCon::preparePopCon";
49  m_dbService->logger().logInfo() << " destination DB: " << connectionStr;
50  m_dbService->logger().logInfo() << " target DB: "
51  << (m_targetConnectionString.empty() ? connectionStr : m_targetConnectionString);
52 
55  m_tagInfo.size = iov.sequenceSize();
56  if (m_tagInfo.size > 0) {
58  }
59  m_dbService->logger().logInfo() << " TAG: " << tagName << ", last since/till: " << m_tagInfo.lastInterval.since
60  << "/" << m_tagInfo.lastInterval.till;
61  m_dbService->logger().logInfo() << " size: " << m_tagInfo.size;
62  } else {
63  m_dbService->logger().logInfo() << " TAG: " << tagName << "; First writer to this new tag.";
64  }
65  return m_targetSession;
66  }
std::string m_authPath
Definition: OnlinePopCon.h:49
edm::Service< cond::service::OnlineDBOutputService > m_dbService
Definition: OnlinePopCon.h:44
Iov_t lastInterval
Definition: Types.h:73
void start(bool readOnly=true)
Definition: Session.cc:18
Time_t since
Definition: Types.h:53
size_t size
Definition: Types.h:74
Transaction & transaction()
Definition: Session.cc:52
std::string tag(const std::string &recordName)
std::string name
Definition: Types.h:72
void setAuthenticationSystem(int authSysCode)
cond::persistency::Logger & logger()
Session createSession(const std::string &connectionString, bool writeCapable=false)
std::string connectionString()
Definition: Session.cc:216
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
bool existsIov(const std::string &tag)
Definition: Session.cc:77
cond::persistency::Session m_targetSession
Definition: OnlinePopCon.h:47
cond::TagInfo_t m_tagInfo
Definition: OnlinePopCon.h:52
EchoedLogStream< edm::LogInfo > logInfo()
Definition: Logger.cc:157
std::string m_recordName
Definition: OnlinePopCon.h:51
void setAuthenticationPath(const std::string &p)
std::string m_targetConnectionString
Definition: OnlinePopCon.h:48
cond::persistency::Session session() const
Time_t till
Definition: Types.h:54

◆ write()

template<typename Source >
void popcon::OnlinePopCon::write ( Source const &  source)

Definition at line 64 of file OnlinePopCon.h.

References MillePedeFileConverter_cfg::e, cppFunctionSkipper::exception, Exception, finalize(), initialize(), run_AlCaRecoTriggerBitsUpdateWorkflow::iovs, edm::Service< T >::isAvailable(), cond::persistency::Logger::logError(), cond::service::PoolDBOutputService::logger(), cond::persistency::Logger::logInfo(), m_dbLoggerReturn_, m_dbService, m_logDBEntry, m_recordName, m_tagInfo, jetsAK4_Puppi_cff::payload, runTheMatrix::ret, source, and cond::service::OnlineDBOutputService::writeIOVForNextLumisection().

Referenced by pkg.AbstractPkg::generate(), popcon::OnlinePopConAnalyzer< S >::write(), and querying.connection::write_and_commit().

64  {
65  // Get data to be uploaded
66  typedef typename Source::Container Container;
67  std::pair<Container const*, std::string const> ret = source(initialize(), m_tagInfo, m_logDBEntry);
68  Container const& iovs = *ret.first;
69 
70  // Check that only 1 iov/payload is provided
71  if (iovs.size() > 1) {
72  throw Exception("OnlinePopCon", "[write] More than one iov/payload provided!");
73  }
74 
75  // If zero payloads to transfer, finalize and return
76  if (iovs.empty()) {
77  m_dbService->logger().logInfo() << "OnlinePopCon::write - Nothing to transfer";
78  finalize();
79  return;
80  }
81 
82  // Upload
83  // Check if DB service is available
84  if (!m_dbService.isAvailable()) {
85  throw Exception("OnlinePopCon", "[write] DBService not available");
86  }
87 
88  // Get the only payload to transfer
89  auto [originalSince, payload] = *iovs.begin();
90 
91  // Log the original since
92  m_dbService->logger().logInfo() << "OnlinePopCon::write - original since: " << originalSince;
93 
94  // Upload the payload
95  try {
97  m_dbService->logger().logInfo() << "OnlinePopCon::write - writeForNextLumisection successful!";
98  m_dbService->logger().logInfo() << "OnlinePopCon::write - uploaded with since: " << targetSince;
99  } catch (const std::exception& e) {
100  m_dbService->logger().logError() << "OnlinePopCon::write - Error writing record: " << m_recordName;
101  m_dbService->logger().logError() << "Error is: " << e.what();
102  m_dbLoggerReturn_ = 2;
103  }
104 
105  // Finalize
106  finalize();
107  }
edm::Service< cond::service::OnlineDBOutputService > m_dbService
Definition: OnlinePopCon.h:44
ret
prodAgent to be discontinued
EchoedLogStream< edm::LogError > logError()
Definition: Logger.cc:165
cond::persistency::Logger & logger()
cond::persistency::Session initialize()
Definition: OnlinePopCon.cc:68
cond::Time_t writeIOVForNextLumisection(const PayloadType &payload, const std::string &recordName)
cond::TagInfo_t m_tagInfo
Definition: OnlinePopCon.h:52
bool isAvailable() const
Definition: Service.h:40
EchoedLogStream< edm::LogInfo > logInfo()
Definition: Logger.cc:157
std::string m_recordName
Definition: OnlinePopCon.h:51
edm::AssociationVector< reco::JetRefBaseProd, Values > Container
static std::string const source
Definition: EdmProvDump.cc:49
cond::LogDBEntry_t m_logDBEntry
Definition: OnlinePopCon.h:53

Member Data Documentation

◆ m_authPath

std::string popcon::OnlinePopCon::m_authPath
private

Definition at line 49 of file OnlinePopCon.h.

Referenced by preparePopCon().

◆ m_authSys

int popcon::OnlinePopCon::m_authSys
private

Definition at line 50 of file OnlinePopCon.h.

Referenced by preparePopCon().

◆ m_dbLoggerReturn_

int popcon::OnlinePopCon::m_dbLoggerReturn_
private

Definition at line 56 of file OnlinePopCon.h.

Referenced by finalize(), initialize(), and write().

◆ m_dbService

edm::Service<cond::service::OnlineDBOutputService> popcon::OnlinePopCon::m_dbService
private

Definition at line 44 of file OnlinePopCon.h.

Referenced by finalize(), initialize(), preparePopCon(), and write().

◆ m_logDBEntry

cond::LogDBEntry_t popcon::OnlinePopCon::m_logDBEntry
private

Definition at line 53 of file OnlinePopCon.h.

Referenced by write().

◆ m_recordName

std::string popcon::OnlinePopCon::m_recordName
private

Definition at line 51 of file OnlinePopCon.h.

Referenced by finalize(), initialize(), preparePopCon(), and write().

◆ m_tagInfo

cond::TagInfo_t popcon::OnlinePopCon::m_tagInfo
private

Definition at line 52 of file OnlinePopCon.h.

Referenced by preparePopCon(), and write().

◆ m_targetConnectionString

std::string popcon::OnlinePopCon::m_targetConnectionString
private

Definition at line 48 of file OnlinePopCon.h.

Referenced by finalize(), preparePopCon(), and ~OnlinePopCon().

◆ m_targetSession

cond::persistency::Session popcon::OnlinePopCon::m_targetSession
private

Definition at line 47 of file OnlinePopCon.h.

Referenced by finalize(), preparePopCon(), and ~OnlinePopCon().

◆ m_useLockRecors

bool popcon::OnlinePopCon::m_useLockRecors
private

Definition at line 57 of file OnlinePopCon.h.

Referenced by finalize(), and initialize().

◆ s_version

constexpr const char *const popcon::OnlinePopCon::s_version = "1.0"
staticprivate

Definition at line 60 of file OnlinePopCon.h.

Referenced by OnlinePopCon().