CMS 3D CMS Logo

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

#include <PopCon.h>

Public Types

typedef cond::Time_t Time_t
 

Public Member Functions

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

Private Member Functions

void finalize (Time_t lastTill)
 
cond::persistency::Session initialize ()
 

Private Attributes

std::string m_authPath
 
int m_authSys
 
bool m_close
 
edm::Service< cond::service::PoolDBOutputServicem_dbService
 
Time_t m_lastTill
 
cond::LogDBEntry_t m_logDBEntry
 
bool m_LoggingOn
 
std::string m_payload_name
 
std::string m_record
 
std::string m_tag
 
cond::TagInfo_t m_tagInfo
 
std::string m_targetConnectionString
 
cond::persistency::Session m_targetSession
 

Static Private Attributes

static constexpr const char *const s_version = "5.0"
 

Detailed Description

Definition at line 29 of file PopCon.h.

Member Typedef Documentation

◆ Time_t

Definition at line 31 of file PopCon.h.

Constructor & Destructor Documentation

◆ PopCon()

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

Definition at line 12 of file PopCon.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_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  }
Time_t m_lastTill
Definition: PopCon.h:69
bool m_close
Definition: PopCon.h:67
std::string m_record
Definition: PopCon.h:55
cond::persistency::Session m_targetSession
Definition: PopCon.h:47
std::string m_targetConnectionString
Definition: PopCon.h:49
Log< level::Info, false > LogInfo
static constexpr const char *const s_version
Definition: PopCon.h:71
int m_authSys
Definition: PopCon.h:53
std::string m_authPath
Definition: PopCon.h:51
std::string m_payload_name
Definition: PopCon.h:57
bool m_LoggingOn
Definition: PopCon.h:59

◆ ~PopCon()

popcon::PopCon::~PopCon ( )
virtual

Definition at line 29 of file PopCon.cc.

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

29  {
30  if (!m_targetConnectionString.empty()) {
32  }
33  }
Transaction & transaction()
Definition: Session.cc:52
cond::persistency::Session m_targetSession
Definition: PopCon.h:47
std::string m_targetConnectionString
Definition: PopCon.h:49

Member Function Documentation

◆ finalize()

void popcon::PopCon::finalize ( Time_t  lastTill)
private

Definition at line 73 of file PopCon.cc.

References cond::service::PoolDBOutputService::closeIOV(), cond::persistency::Transaction::commit(), cond::service::PoolDBOutputService::commitTransaction(), m_close, m_dbService, m_lastTill, m_record, m_targetConnectionString, m_targetSession, and cond::persistency::Session::transaction().

Referenced by write().

73  {
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  } else {
84  }
85  }
Time_t m_lastTill
Definition: PopCon.h:69
bool m_close
Definition: PopCon.h:67
std::string m_record
Definition: PopCon.h:55
Transaction & transaction()
Definition: Session.cc:52
cond::persistency::Session m_targetSession
Definition: PopCon.h:47
void closeIOV(Time_t lastTill, const std::string &recordName)
std::string m_targetConnectionString
Definition: PopCon.h:49
edm::Service< cond::service::PoolDBOutputService > m_dbService
Definition: PopCon.h:45

◆ initialize()

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

Definition at line 35 of file PopCon.cc.

References cond::persistency::ConnectionPool::configure(), cond::persistency::Session::connectionString(), cond::persistency::ConnectionPool::createSession(), Exception, cond::persistency::Session::existsDatabase(), cond::persistency::Session::existsIov(), cond::service::PoolDBOutputService::forceInit(), cond::persistency::IOVProxy::getLast(), edm::Service< T >::isAvailable(), cond::TagInfo_t::lastInterval, m_authPath, m_authSys, m_dbService, m_payload_name, m_record, m_tag, 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(), cond::Iov_t::till, and cond::persistency::Session::transaction().

Referenced by write().

35  {
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()) {
46  } else {
50  connPool.configure();
53  }
56  m_tagInfo.size = iov.sequenceSize();
57  if (m_tagInfo.size > 0) {
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  }
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
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 setAuthenticationSystem(int authSysCode)
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
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
Log< level::Info, false > LogInfo
int m_authSys
Definition: PopCon.h:53
bool existsIov(const std::string &tag)
Definition: Session.cc:77
std::string m_authPath
Definition: PopCon.h:51
bool isAvailable() const
Definition: Service.h:40
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
cond::persistency::Session session() const
Time_t till
Definition: Types.h:54

◆ write()

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

Definition at line 75 of file PopCon.h.

References finalize(), dqmdumpme::first, initialize(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, m_dbService, m_logDBEntry, m_LoggingOn, m_record, m_tagInfo, mps_check::msg, runTheMatrix::ret, alignCSCRings::s, s_version, cond::service::PoolDBOutputService::setLogHeaderForRecord(), source, AlCaHLTBitMon_QueryRunRegistry::string, and cond::service::PoolDBOutputService::writeMany().

Referenced by SiStripPopConDQMEDHarvester< SourceHandler >::dqmEndJob(), pkg.AbstractPkg::generate(), ExTestEcalChannelStatusAnalyzer::write(), HcalSiPMCharacteristicsPopConAnalyzer::write(), HcalSiPMParametersPopConAnalyzer::write(), HcalTPChannelParametersPopConAnalyzer::write(), HcalTPParametersPopConAnalyzer::write(), HcalFrontEndMapPopConAnalyzer::write(), HcalPFCutsPopConAnalyzer::write(), HcalGainsPopConAnalyzer::write(), HcalElectronicsMapPopConAnalyzer::write(), HcalFlagHFDigiTimeParamsPopConAnalyzer::write(), HcalValidationCorrsPopConAnalyzer::write(), HcalL1TriggerObjectsPopConAnalyzer::write(), HcalQIETypesPopConAnalyzer::write(), HcalQIEDataPopConAnalyzer::write(), HcalDcsMapPopConAnalyzer::write(), HcalPFCorrsPopConAnalyzer::write(), HcalPedestalWidthsPopConAnalyzer::write(), HcalPedestalsPopConAnalyzer::write(), HcalMCParamsPopConAnalyzer::write(), HcalRecoParamsPopConAnalyzer::write(), HcalLUTCorrsPopConAnalyzer::write(), CastorRecoParamsPopConAnalyzer::write(), CastorQIEDataPopConAnalyzer::write(), HcalGainWidthsPopConAnalyzer::write(), HcalZSThresholdsPopConAnalyzer::write(), HcalTimeCorrsPopConAnalyzer::write(), HcalRespCorrsPopConAnalyzer::write(), CastorChannelQualityPopConAnalyzer::write(), HcalDcsValuesPopConAnalyzer::write(), CastorGainWidthsPopConAnalyzer::write(), HcalChannelQualityPopConAnalyzer::write(), HcalLutMetadataPopConAnalyzer::write(), HcalLongRecoParamsPopConAnalyzer::write(), CastorElectronicsMapPopConAnalyzer::write(), CastorPedestalWidthsPopConAnalyzer::write(), CastorPedestalsPopConAnalyzer::write(), CastorGainsPopConAnalyzer::write(), CastorSaturationCorrsPopConAnalyzer::write(), HcalTimingParamsPopConAnalyzer::write(), HcalZDCLowGainFractionsPopConAnalyzer::write(), popcon::PopConAnalyzer< HcalTPParametersHandler >::write(), and querying.connection::write_and_commit().

75  {
76  typedef typename Source::value_type value_type;
77  typedef typename Source::Container Container;
78 
79  std::pair<Container const*, std::string const> ret = source(initialize(), m_tagInfo, m_logDBEntry);
80  Container const& iovs = *ret.first;
81 
82  if (m_LoggingOn) {
83  std::string msg("Nothing to transfer;");
84  size_t niovs = iovs.size();
85  if (niovs) {
86  std::ostringstream s;
87  if (niovs == 1) {
88  s << "Since " << (*iovs.begin()).first << "; ";
89  } else {
90  s << "first payload Since " << (*iovs.begin()).first << ", "
91  << "last payload Since " << (*iovs.rbegin()).first << "; ";
92  }
93  msg = s.str();
94  }
95  std::ostringstream s;
96  s << "PopCon v" << s_version << "; " << msg << ret.second;
98  }
99  for (const auto& it : iovs)
100  edm::LogInfo("PopCon") << "Since " << it.first << std::endl;
101 
103 
104  finalize(iovs.empty() ? Time_t(0) : iovs.rbegin()->first);
105  }
cond::LogDBEntry_t m_logDBEntry
Definition: PopCon.h:65
void finalize(Time_t lastTill)
Definition: PopCon.cc:73
ret
prodAgent to be discontinued
cond::Time_t Time_t
Definition: PopCon.h:31
std::string m_record
Definition: PopCon.h:55
cond::TagInfo_t m_tagInfo
Definition: PopCon.h:63
void setLogHeaderForRecord(const std::string &recordName, const std::string &provenance, const std::string &usertext)
Log< level::Info, false > LogInfo
static constexpr const char *const s_version
Definition: PopCon.h:71
cond::persistency::Session initialize()
Definition: PopCon.cc:35
tuple msg
Definition: mps_check.py:286
void writeMany(const std::map< Time_t, std::shared_ptr< T > > &iovAndPayloads, const std::string &recordName)
edm::AssociationVector< reco::JetRefBaseProd, Values > Container
static std::string const source
Definition: EdmProvDump.cc:49
edm::Service< cond::service::PoolDBOutputService > m_dbService
Definition: PopCon.h:45
bool m_LoggingOn
Definition: PopCon.h:59

Member Data Documentation

◆ m_authPath

std::string popcon::PopCon::m_authPath
private

Definition at line 51 of file PopCon.h.

Referenced by initialize().

◆ m_authSys

int popcon::PopCon::m_authSys
private

Definition at line 53 of file PopCon.h.

Referenced by initialize().

◆ m_close

bool popcon::PopCon::m_close
private

Definition at line 67 of file PopCon.h.

Referenced by finalize().

◆ m_dbService

edm::Service<cond::service::PoolDBOutputService> popcon::PopCon::m_dbService
private

Definition at line 45 of file PopCon.h.

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

◆ m_lastTill

Time_t popcon::PopCon::m_lastTill
private

Definition at line 69 of file PopCon.h.

Referenced by finalize().

◆ m_logDBEntry

cond::LogDBEntry_t popcon::PopCon::m_logDBEntry
private

Definition at line 65 of file PopCon.h.

Referenced by write().

◆ m_LoggingOn

bool popcon::PopCon::m_LoggingOn
private

Definition at line 59 of file PopCon.h.

Referenced by write().

◆ m_payload_name

std::string popcon::PopCon::m_payload_name
private

Definition at line 57 of file PopCon.h.

Referenced by initialize().

◆ m_record

std::string popcon::PopCon::m_record
private

Definition at line 55 of file PopCon.h.

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

◆ m_tag

std::string popcon::PopCon::m_tag
private

Definition at line 61 of file PopCon.h.

Referenced by initialize().

◆ m_tagInfo

cond::TagInfo_t popcon::PopCon::m_tagInfo
private

Definition at line 63 of file PopCon.h.

Referenced by initialize(), and write().

◆ m_targetConnectionString

std::string popcon::PopCon::m_targetConnectionString
private

Definition at line 49 of file PopCon.h.

Referenced by finalize(), initialize(), and ~PopCon().

◆ m_targetSession

cond::persistency::Session popcon::PopCon::m_targetSession
private

Definition at line 47 of file PopCon.h.

Referenced by finalize(), initialize(), and ~PopCon().

◆ s_version

constexpr const char *const popcon::PopCon::s_version = "5.0"
staticprivate

Definition at line 71 of file PopCon.h.

Referenced by PopCon(), and write().