CMS 3D CMS Logo

OnlinePopCon.cc
Go to the documentation of this file.
5 
6 //#include <iostream>
7 
8 namespace popcon {
9 
10  constexpr const char* const OnlinePopCon::s_version;
11 
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  }
23 
25  if (!m_targetConnectionString.empty()) {
27  }
28  }
29 
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  }
67 
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  }
89 
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  }
113 
114 } // namespace popcon
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()
cond::persistency::Session initialize()
Definition: OnlinePopCon.cc:68
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
Log< level::Info, false > LogInfo
bool existsIov(const std::string &tag)
Definition: Session.cc:77
cond::persistency::Session m_targetSession
Definition: OnlinePopCon.h:47
cond::persistency::Session preparePopCon()
Definition: OnlinePopCon.cc:30
cond::TagInfo_t m_tagInfo
Definition: OnlinePopCon.h:52
bool isAvailable() const
Definition: Service.h:40
static constexpr const char *const s_version
Definition: OnlinePopCon.h:60
OnlinePopCon(const edm::ParameterSet &pset)
Definition: OnlinePopCon.cc:12
EchoedLogStream< edm::LogInfo > logInfo()
Definition: Logger.cc:157
void end(int retCode)
Definition: Logger.cc:80
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