CMS 3D CMS Logo

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
popcon::PopCon::PopCon
PopCon(const edm::ParameterSet &pset)
Definition: PopCon.cc:12
popcon::PopCon::m_tag
std::string m_tag
Definition: PopCon.h:65
cond::service::PoolDBOutputService::tag
std::string tag(const std::string &recordName)
Definition: PoolDBOutputService.cc:124
electrons_cff.bool
bool
Definition: electrons_cff.py:366
ConnectionPool.h
MessageLogger.h
popcon::PopCon::s_version
static constexpr const char *const s_version
Definition: PopCon.h:75
funct::false
false
Definition: Factorize.h:29
cond::persistency::IOVProxy::getLast
cond::Iov_t getLast()
Definition: IOVProxy.cc:396
Exception.h
cond::persistency::Session::existsIov
bool existsIov(const std::string &tag)
Definition: Session.cc:77
popcon::PopCon::m_authPath
std::string m_authPath
Definition: PopCon.h:55
cond::service::PoolDBOutputService::closeIOV
void closeIOV(Time_t lastTill, const std::string &recordName)
Definition: PoolDBOutputService.cc:346
popcon::PopCon::m_targetConnectionString
std::string m_targetConnectionString
Definition: PopCon.h:53
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
cond::persistency::ConnectionPool::createSession
Session createSession(const std::string &connectionString, bool writeCapable=false)
Definition: ConnectionPool.cc:174
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
cond::TagInfo_t::name
std::string name
Definition: Types.h:72
PopCon.h
popcon::PopCon::m_close
bool m_close
Definition: PopCon.h:71
cond::Iov_t::till
Time_t till
Definition: Types.h:54
cond::service::PoolDBOutputService::session
cond::persistency::Session session() const
Definition: PoolDBOutputService.cc:92
popcon::PopCon::m_targetSession
cond::persistency::Session m_targetSession
Definition: PopCon.h:51
popcon::PopCon::m_authSys
int m_authSys
Definition: PopCon.h:57
cond::persistency::ConnectionPool
Definition: ConnectionPool.h:35
popcon::PopCon::~PopCon
virtual ~PopCon()
Definition: PopCon.cc:29
popcon::PopCon::m_payload_name
std::string m_payload_name
Definition: PopCon.h:61
cond::persistency::Session::readIov
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
cond::persistency::ConnectionPool::setAuthenticationSystem
void setAuthenticationSystem(int authSysCode)
Definition: ConnectionPool.cc:37
cond::persistency::IOVProxy
Definition: IOVProxy.h:92
funct::true
true
Definition: Factorize.h:173
edm::ParameterSet
Definition: ParameterSet.h:47
cond::persistency::Session
Definition: Session.h:63
cond::Iov_t::since
Time_t since
Definition: Types.h:53
popcon::PopCon::m_lastTill
Time_t m_lastTill
Definition: PopCon.h:73
cond::persistency::Session::connectionString
std::string connectionString()
Definition: Session.cc:216
createfilelist.int
int
Definition: createfilelist.py:10
cond::persistency::Transaction::commit
void commit()
Definition: Session.cc:23
cond::persistency::ConnectionPool::setAuthenticationPath
void setAuthenticationPath(const std::string &p)
Definition: ConnectionPool.cc:35
popcon::PopCon::finalize
void finalize(Time_t lastTill)
Definition: PopCon.cc:73
cond::persistency::ConnectionPool::configure
void configure()
Definition: ConnectionPool.cc:129
popcon::PopCon::m_record
std::string m_record
Definition: PopCon.h:59
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond::persistency::IOVProxy::sequenceSize
int sequenceSize() const
Definition: IOVProxy.cc:409
cond::TagInfo_t::lastInterval
Iov_t lastInterval
Definition: Types.h:73
cond::persistency::Session::transaction
Transaction & transaction()
Definition: Session.cc:52
cond::persistency::Transaction::start
void start(bool readOnly=true)
Definition: Session.cc:18
std
Definition: JetResolutionObject.h:76
popcon
Definition: Exception.h:6
popcon::PopCon::m_dbService
edm::Service< cond::service::PoolDBOutputService > m_dbService
Definition: PopCon.h:49
cond::persistency::Session::existsDatabase
bool existsDatabase()
Definition: Session.cc:55
Exception
Definition: hltDiff.cc:245
popcon::PopCon::Time_t
cond::Time_t Time_t
Definition: PopCon.h:31
popcon::PopCon::initialize
cond::persistency::Session initialize()
Definition: PopCon.cc:35
popcon::PopCon::m_tagInfo
cond::TagInfo_t m_tagInfo
Definition: PopCon.h:67
ParameterSet.h
cond::service::PoolDBOutputService::forceInit
void forceInit()
Definition: PoolDBOutputService.cc:201
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
cond::TagInfo_t::size
size_t size
Definition: Types.h:74