CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PopCon.cc
Go to the documentation of this file.
6 #include <iostream>
7 
8 namespace popcon {
9 
10  constexpr const char* const PopCon::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_record(pset.getParameter<std::string>("record")),
18  m_payload_name(pset.getUntrackedParameter<std::string>("name", "")),
19  m_LoggingOn(pset.getUntrackedParameter<bool>("loggingOn", true)),
20  m_close(pset.getUntrackedParameter<bool>("closeIOV", false)),
21  m_lastTill(pset.getUntrackedParameter<bool>("lastTill", false)) {
22  //TODO set the policy (cfg or global configuration?)
23  //Policy if corrupted data found
24 
25  edm::LogInfo("PopCon") << "This is PopCon (Populator of Condition) v" << s_version << ".\n"
26  << "Please report any problem and feature request through the JIRA project CMSCONDDB.\n";
27  }
28 
30  if (!m_targetConnectionString.empty()) {
32  }
33  }
34 
36  edm::LogInfo("PopCon") << "payload name " << m_payload_name << std::endl;
37  if (!m_dbService.isAvailable())
38  throw Exception("DBService not available");
39  const std::string& connectionStr = m_dbService->session().connectionString();
43  if (m_targetConnectionString.empty())
45  else {
49  connPool.configure();
52  }
55  m_tagInfo.size = iov.sequenceSize();
56  if (m_tagInfo.size > 0) {
58  }
59 
60  edm::LogInfo("PopCon") << "destination DB: " << connectionStr << ", target DB: "
61  << (m_targetConnectionString.empty() ? connectionStr : m_targetConnectionString) << "\n"
62  << "TAG: " << m_tag << ", last since/till: " << m_tagInfo.lastInterval.since << "/"
63  << m_tagInfo.lastInterval.till << ", size: " << m_tagInfo.size << "\n"
64  << std::endl;
65  } else {
66  edm::LogInfo("PopCon") << "destination DB: " << connectionStr << ", target DB: "
67  << (m_targetConnectionString.empty() ? connectionStr : m_targetConnectionString) << "\n"
68  << "TAG: " << m_tag << "; First writer to this new tag." << std::endl;
69  }
70  return m_targetSession;
71  }
72 
73  void PopCon::finalize(Time_t lastTill) {
74  if (m_close) {
75  // avoid to close it before lastSince
76  if (m_lastTill > lastTill)
77  lastTill = m_lastTill;
78  m_dbService->closeIOV(lastTill, m_record);
79  }
80  if (!m_targetConnectionString.empty()) {
82  }
83  }
84 
85 } // namespace popcon
void finalize(Time_t lastTill)
Definition: PopCon.cc:73
Iov_t lastInterval
Definition: Types.h:73
Time_t m_lastTill
Definition: PopCon.h:69
void start(bool readOnly=true)
Definition: Session.cc:18
cond::persistency::Session session() const
bool m_close
Definition: PopCon.h:67
Time_t since
Definition: Types.h:53
cond::Time_t Time_t
Definition: PopCon.h:31
size_t size
Definition: Types.h:74
std::string m_tag
Definition: PopCon.h:61
std::string m_record
Definition: PopCon.h:55
Transaction & transaction()
Definition: Session.cc:52
std::string tag(const std::string &recordName)
cond::persistency::Session m_targetSession
Definition: PopCon.h:47
std::string name
Definition: Types.h:72
void closeIOV(Time_t lastTill, const std::string &recordName)
void setAuthenticationSystem(int authSysCode)
bool isAvailable() const
Definition: Service.h:40
Session createSession(const std::string &connectionString, bool writeCapable=false)
std::string m_targetConnectionString
Definition: PopCon.h:49
cond::TagInfo_t m_tagInfo
Definition: PopCon.h:63
std::string connectionString()
Definition: Session.cc:216
PopCon(const edm::ParameterSet &pset)
Definition: PopCon.cc:12
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
Log< level::Info, false > LogInfo
static constexpr const char *const s_version
Definition: PopCon.h:71
int m_authSys
Definition: PopCon.h:53
cond::persistency::Session initialize()
Definition: PopCon.cc:35
bool existsIov(const std::string &tag)
Definition: Session.cc:77
std::string m_authPath
Definition: PopCon.h:51
virtual ~PopCon()
Definition: PopCon.cc:29
void setAuthenticationPath(const std::string &p)
std::string m_payload_name
Definition: PopCon.h:57
edm::Service< cond::service::PoolDBOutputService > m_dbService
Definition: PopCon.h:45
Time_t till
Definition: Types.h:54