CMS 3D CMS Logo

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