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_IsDestDbCheckedInQueryLog( pset.getUntrackedParameter< bool >("IsDestDbCheckedInQueryLog",true)),
19  m_close(pset.getUntrackedParameter< bool > ("closeIOV",false)),
20  m_lastTill(pset.getUntrackedParameter< bool > ("lastTill",0))
21  {
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) V4.0\n"
26  << "Please report any problem and feature request through the savannah portal under the category conditions\n" ;
27  }
28 
30  if( !m_targetConnectionString.empty() ) {
32  }
33  }
34 
35 
37  edm::LogInfo ("PopCon")<<"payload name "<<m_payload_name<<std::endl;
38  if(!m_dbService.isAvailable() ) throw Exception("DBService not available");
39  const std::string & connectionStr = m_dbService->session().connectionString();
43  else {
47  connPool.configure();
50  }
54  m_tagInfo.size = iov.sequenceSize();
55  if( m_tagInfo.size>0 ){
56  cond::Iov_t last = iov.getLast();
59  }
60 
63  std::cout <<" ------ log info searched in the same db: "<< connectionStr << "------" <<std::endl;
64  } else {
66  std::cout <<" ------ log info found in another db "<< "------" <<std::endl;
67  }
68 
69  edm::LogInfo ("PopCon") << "DB: " << connectionStr << "\n"
70  << "TAG: " << m_tag
71  << ", last since/till: " << m_tagInfo.lastInterval.first
72  << "/" << m_tagInfo.lastInterval.second
73  << ", , size: " << m_tagInfo.size << "\n"
74  << "Last writer: " << m_logDBEntry.provenance
75  << ", size: " << m_logDBEntry.payloadIdx+1 << std::endl;
76  } else {
77  edm::LogInfo ("PopCon") << "DB: " << connectionStr << "\n"
78  << "TAG: " << m_tag
79  << "; First writer to this new tag." << std::endl;
80  }
81  return m_targetSession;
82  }
83 
84 
85  void PopCon::finalize(Time_t lastTill) {
86 
87  if (m_close) {
88  // avoid to close it before lastSince
89  if (m_lastTill>lastTill) lastTill=m_lastTill;
90  m_dbService->closeIOV(lastTill,m_record);
91  }
92  if( !m_targetConnectionString.empty() ) {
94  }
95  }
96 
97 }
cond::LogDBEntry m_logDBEntry
Definition: PopCon.h:82
void closeIOV(Time_t lastTill, const std::string &recordName, bool withlogging=false)
void finalize(Time_t lastTill)
Definition: PopCon.cc:85
unsigned int payloadIdx
Definition: LogDBEntry.h:23
Time_t m_lastTill
Definition: PopCon.h:85
void start(bool readOnly=true)
Definition: Session.cc:22
cond::persistency::Session session() const
bool m_close
Definition: PopCon.h:84
Time_t since
Definition: Types.h:56
cond::Time_t Time_t
Definition: PopCon.h:37
size_t size
Definition: Types.h:77
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
std::string m_tag
Definition: PopCon.h:78
std::string m_record
Definition: PopCon.h:70
Transaction & transaction()
Definition: Session.cc:66
std::string tag(const std::string &recordName)
cond::persistency::Session m_targetSession
Definition: PopCon.h:62
std::string name
Definition: Types.h:73
cond::ValidityInterval lastInterval
Definition: Types.h:75
IOVProxy readIov(const std::string &tag, bool full=false)
Definition: Session.cc:81
tuple iov
Definition: o2o.py:307
void setAuthenticationSystem(int authSysCode)
Session createSession(const std::string &connectionString, bool writeCapable=false, BackendType backType=DEFAULT_DB)
bool isAvailable() const
Definition: Service.h:46
Hash payloadId
Definition: Types.h:58
std::string m_targetConnectionString
Definition: PopCon.h:64
cond::TagInfo_t m_tagInfo
Definition: PopCon.h:80
std::string connectionString()
Definition: Session.cc:268
PopCon(const edm::ParameterSet &pset)
Definition: PopCon.cc:10
bool m_IsDestDbCheckedInQueryLog
Definition: PopCon.h:76
int m_authSys
Definition: PopCon.h:68
cond::persistency::Session initialize()
Definition: PopCon.cc:36
std::string lastPayloadToken
Definition: Types.h:76
bool existsIov(const std::string &tag)
Definition: Session.cc:97
std::string provenance
Definition: LogDBEntry.h:19
std::string m_authPath
Definition: PopCon.h:66
virtual ~PopCon()
Definition: PopCon.cc:29
void LookupLastEntryByTag(const std::string &iovtag, LogDBEntry &logentry, bool filterFailedOp=true) const
Definition: Logger.cc:289
tuple cout
Definition: gather_cfg.py:121
volatile std::atomic< bool > shutdown_flag false
void setAuthenticationPath(const std::string &p)
std::string m_payload_name
Definition: PopCon.h:72
const cond::Logger & queryLog() const
edm::Service< cond::service::PoolDBOutputService > m_dbService
Definition: PopCon.h:60
Time_t till
Definition: Types.h:57