Skip to content

Commit

Permalink
Cleanup and style fixes in PopCon.
Browse files Browse the repository at this point in the history
  • Loading branch information
Salvatore Di Guida committed May 9, 2016
1 parent c655438 commit f4a1c40
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 39 deletions.
29 changes: 14 additions & 15 deletions CondCore/PopCon/interface/PopCon.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,17 @@ namespace popcon {

bool m_LoggingOn;

bool m_IsDestDbCheckedInQueryLog;

std::string m_tag;

cond::TagInfo_t m_tagInfo;

cond::LogDBEntry_t m_logDBEntry;

bool m_close;

Time_t m_lastTill;


static constexpr const char* const s_version = "5.0";
};


Expand All @@ -103,15 +102,15 @@ namespace popcon {

template<typename Container>
const std::string displayIovHelper(Container const & payloads) {
if (payloads.empty()) return "Nothing to transfer;";
std::ostringstream s;
if (payloads.empty()) return std::string("Nothing to transfer;");
std::ostringstream s;
// when only 1 payload is transferred;
if ( payloads.size()==1)
s <<"Since " << (*payloads.begin()).time << "; " ;
if ( payloads.size()==1)
s << "Since " << (*payloads.begin()).time << "; " ;
else{
// when more than one payload are transferred;
s << "first payload Since " << (*payloads.begin()).time << ","
<< "last payload Since " << (*payloads.rbegin()).time << ";" ;
s << "first payload Since " << (*payloads.begin()).time << ", "
<< "last payload Since " << (*payloads.rbegin()).time << "; " ;
}
return s.str();
}
Expand All @@ -129,12 +128,12 @@ namespace popcon {
m_tagInfo,m_logDBEntry);
Container const & payloads = *ret.first;

if(m_LoggingOn)
m_dbService->setLogHeaderForRecord(m_record,source.id(),"PopCon v4.0; " +
displayIovHelper(payloads) + ret.second);
//m_dbService->setLogHeaderForRecord(m_record,source.id(),"PopCon v4.0; " +
// cond::userInfo() + displayIovHelper(payloads) + ret.second);

if(m_LoggingOn) {
std::ostringstream s;
s << "PopCon v" << s_version << "; " << displayIovHelper(payloads) << ret.second;
//s << "PopCon v" << s_version << "; " << cond::userInfo() << displayIovHelper(payloads) << ret.second;
m_dbService->setLogHeaderForRecord(m_record,source.id(),s.str());
}
displayHelper(payloads);

std::for_each(payloads.begin(),payloads.end(),
Expand Down
39 changes: 15 additions & 24 deletions CondCore/PopCon/src/PopCon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ namespace popcon {
m_record(pset.getParameter<std::string> ("record")),
m_payload_name(pset.getUntrackedParameter<std::string> ("name","")),
m_LoggingOn(pset.getUntrackedParameter< bool > ("loggingOn",true)),
m_IsDestDbCheckedInQueryLog( pset.getUntrackedParameter< bool >("IsDestDbCheckedInQueryLog",true)),
m_close(pset.getUntrackedParameter< bool > ("closeIOV",false)),
m_lastTill(pset.getUntrackedParameter< bool > ("lastTill",0))
{
//TODO set the policy (cfg or global configuration?)
//Policy if corrupted data found

edm::LogInfo ("PopCon") << "This is PopCon (Populator of Condition) V4.0\n"
<< "Please report any problem and feature request through the savannah portal under the category conditions\n" ;
edm::LogInfo ("PopCon") << "This is PopCon (Populator of Condition) v" << s_version << ".\n"
<< "Please report any problem and feature request through the JIRA project CMSCONDDB.\n" ;
}

PopCon::~PopCon(){
Expand Down Expand Up @@ -53,30 +52,22 @@ namespace popcon {
m_tagInfo.name = m_tag;
m_tagInfo.size = iov.sequenceSize();
if( m_tagInfo.size>0 ){
cond::Iov_t last = iov.getLast();
m_tagInfo.lastInterval = cond::ValidityInterval( last.since, last.till );
m_tagInfo.lastPayloadToken = last.payloadId;
cond::Iov_t last = iov.getLast();
m_tagInfo.lastInterval = cond::ValidityInterval( last.since, last.till );
m_tagInfo.lastPayloadToken = last.payloadId;
}

//if( m_IsDestDbCheckedInQueryLog ) {
//m_dbService->queryLog().LookupLastEntryByTag( m_tag, connectionStr, m_logDBEntry );
//std::cout <<" ------ log info searched in the same db: "<< connectionStr << "------" <<std::endl;
//} else {
//m_dbService->queryLog().LookupLastEntryByTag( m_tag, m_logDBEntry );
//std::cout <<" ------ log info found in another db "<< "------" <<std::endl;
//}

edm::LogInfo ("PopCon") << "DB: " << connectionStr << "\n"
<< "TAG: " << m_tag
<< ", last since/till: " << m_tagInfo.lastInterval.first
<< "/" << m_tagInfo.lastInterval.second
<< ", , size: " << m_tagInfo.size << "\n"
<< "Last writer: " << m_logDBEntry.provenance
<< ", size: " << m_logDBEntry.payloadIdx+1 << std::endl;
edm::LogInfo ("PopCon") << "destination DB: " << connectionStr
<< ", target DB: " << ( m_targetConnectionString.empty() ? connectionStr : m_targetConnectionString ) << "\n"
<< "TAG: " << m_tag
<< ", last since/till: " << m_tagInfo.lastInterval.first
<< "/" << m_tagInfo.lastInterval.second
<< ", size: " << m_tagInfo.size << "\n" << std::endl;
} else {
edm::LogInfo ("PopCon") << "DB: " << connectionStr << "\n"
<< "TAG: " << m_tag
<< "; First writer to this new tag." << std::endl;
edm::LogInfo ("PopCon") << "destination DB: " << connectionStr
<< ", target DB: " << ( m_targetConnectionString.empty() ? connectionStr : m_targetConnectionString ) << "\n"
<< "TAG: " << m_tag
<< "; First writer to this new tag." << std::endl;
}
return m_targetSession;
}
Expand Down

0 comments on commit f4a1c40

Please sign in to comment.