#include <CondDBESSource.h>
Classes | |
struct | Stats |
Public Types | |
typedef std::multimap < std::string, ProxyP > | ProxyMap |
typedef boost::shared_ptr < cond::DataProxyWrapperBase > | ProxyP |
enum | RefreshPolicy { NOREFRESH, REFRESH_ALWAYS, REFRESH_OPEN_IOVS, REFRESH_EACH_RUN, RECONNECT_EACH_RUN } |
Public Member Functions | |
CondDBESSource (const edm::ParameterSet &) | |
~CondDBESSource () | |
Protected Member Functions | |
virtual void | newInterval (const edm::eventsetup::EventSetupRecordKey &iRecordType, const edm::ValidityInterval &iInterval) |
called when a new interval of validity occurs for iRecordType | |
virtual void | registerProxies (const edm::eventsetup::EventSetupRecordKey &iRecordKey, KeyedProxies &aProxyList) |
virtual void | setIntervalFor (const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) |
Private Types | |
typedef std::map< std::string, cond::TagMetadata > | TagCollection |
Private Member Functions | |
void | fillList (const std::string &pfn, std::vector< std::string > &pfnList, const unsigned int listSize, const std::string &type) |
void | fillTagCollectionFromDB (const std::vector< std::string > &coraldbList, const std::vector< std::string > &prefix, const std::vector< std::string > &postfix, const std::vector< std::string > &roottagList, std::map< std::string, cond::TagMetadata > &replacement) |
void | fillTagCollectionFromGT (const std::string &coraldb, const std::string &prefix, const std::string &postfix, const std::string &roottag, std::set< cond::TagMetadata > &tagcoll) |
Private Attributes | |
cond::DbConnection | m_connection |
bool | m_doDump |
unsigned int | m_lastLumi |
std::map< std::string, unsigned int > | m_lastRecordRuns |
unsigned int | m_lastRun |
RefreshPolicy | m_policy |
ProxyMap | m_proxies |
std::map< std::string, std::pair< cond::DbSession, std::string > > | m_sessionPool |
Stats | m_stats |
TagCollection | m_tagCollection |
Definition at line 35 of file CondDBESSource.h.
typedef std::multimap< std::string, ProxyP> CondDBESSource::ProxyMap |
Definition at line 39 of file CondDBESSource.h.
typedef boost::shared_ptr<cond::DataProxyWrapperBase > CondDBESSource::ProxyP |
Definition at line 38 of file CondDBESSource.h.
typedef std::map< std::string, cond::TagMetadata > CondDBESSource::TagCollection [private] |
Definition at line 66 of file CondDBESSource.h.
Definition at line 41 of file CondDBESSource.h.
CondDBESSource::CondDBESSource | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
required by eventsetup
Definition at line 110 of file CondDBESSource.cc.
References b, cond::DbConnection::configuration(), cond::DbConnection::configure(), cond::DbConnection::createSession(), alignCSCRings::e, edm::ParameterSet::exists(), fillList(), fillTagCollectionFromDB(), edm::EventSetupRecordIntervalFinder::findingRecordWithKey(), edm::eventsetup::heterocontainer::HCTypeTag::findType(), reco::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), align_cfg::globaltag, cond::TagMetadata::labelname, m_connection, m_policy, m_proxies, m_stats, m_tagCollection, CondDBESSource::Stats::nData, cond::DbSession::openReadOnly(), cond::TagMetadata::pfn, RECONNECT_EACH_RUN, cond::TagMetadata::recordname, REFRESH_ALWAYS, REFRESH_EACH_RUN, REFRESH_OPEN_IOVS, alignCSCRings::s, split, AlCaHLTBitMon_QueryRunRegistry::string, cond::TagMetadata::tag, convertSQLitetoXML_cfg::toGet, edm::eventsetup::EventSetupRecordKey::type(), and edm::eventsetup::DataProxyProvider::usingRecordWithKey().
: m_connection(), m_lastRun(0), // for the stat m_lastLumi(0), // for the stat m_policy( NOREFRESH ), m_doDump( iConfig.getUntrackedParameter<bool>( "DumpStat", false ) ) { if( iConfig.getUntrackedParameter<bool>( "RefreshAlways", false ) ) { m_policy = REFRESH_ALWAYS; } if( iConfig.getUntrackedParameter<bool>( "RefreshOpenIOVs", false ) ) { m_policy = REFRESH_OPEN_IOVS; } if( iConfig.getUntrackedParameter<bool>( "RefreshEachRun", false ) ) { m_policy = REFRESH_EACH_RUN; } if( iConfig.getUntrackedParameter<bool>( "ReconnectEachRun", false ) ) { m_policy = RECONNECT_EACH_RUN; } Stats s = {0,0,0,0,0,0,0,0}; m_stats = s; //std::cout<<"CondDBESSource::CondDBESSource"<<std::endl; /*parameter set parsing and pool environment setting */ // default connection string // inproduction used for the global tag std::string userconnect= iConfig.getParameter<std::string>("connect"); // connection configuration edm::ParameterSet connectionPset = iConfig.getParameter<edm::ParameterSet>( "DBParameters" ); m_connection.configuration().setParameters( connectionPset ); m_connection.configure(); // load additional record/tag info it will overwrite the global tag std::map<std::string,cond::TagMetadata> replacement; if( iConfig.exists( "toGet" ) ) { typedef std::vector< edm::ParameterSet > Parameters; Parameters toGet = iConfig.getParameter<Parameters>( "toGet" ); for( Parameters::iterator itToGet = toGet.begin(); itToGet != toGet.end(); ++itToGet ) { cond::TagMetadata nm; nm.recordname = itToGet->getParameter<std::string>( "record" ); nm.labelname = itToGet->getUntrackedParameter<std::string>( "label", "" ); nm.tag = itToGet->getParameter<std::string>( "tag" ); nm.pfn = itToGet->getUntrackedParameter<std::string>( "connect", userconnect ); // nm.objectname=itFound->second; std::string recordLabelKey = joinRecordAndLabel( nm.recordname, nm.labelname ); replacement.insert( std::pair<std::string,cond::TagMetadata>( recordLabelKey, nm ) ); } } // get the global tag, merge with "replacement" store in "tagCollection" std::vector<std::string> globaltagList; std::vector<std::string> connectList; std::vector<std::string> pfnPrefixList; std::vector<std::string> pfnPostfixList; if( iConfig.exists( "globaltag" ) ) { std::string pfnPrefix(iConfig.getUntrackedParameter<std::string>( "pfnPrefix", "" )); std::string pfnPostfix(iConfig.getUntrackedParameter<std::string>( "pfnPostfix", "" )); std::string globaltag(iConfig.getParameter<std::string>( "globaltag" )); boost::split( globaltagList, globaltag, boost::is_any_of("|"), boost::token_compress_off ); fillList(userconnect, connectList, globaltagList.size(), "connection"); fillList(pfnPrefix, pfnPrefixList, globaltagList.size(), "pfnPrefix"); fillList(pfnPostfix, pfnPostfixList, globaltagList.size(), "pfnPostfix"); } fillTagCollectionFromDB(connectList, pfnPrefixList, pfnPostfixList, globaltagList, replacement); TagCollection::iterator it; TagCollection::iterator itBeg = m_tagCollection.begin(); TagCollection::iterator itEnd = m_tagCollection.end(); std::map<std::string, cond::DbSession> sessions; /* load DataProxy Plugin (it is strongly typed due to EventSetup ideosyncrasis) * construct proxy * contrary to EventSetup the "object-name" is not used as identifier: multiple entries in a record are * dinstinguished only by their label... * done in two step: first create ProxyWrapper loading ALL required dictionaries * this will allow to initialize POOL in one go for each "database" * The real initialization of the Data-Proxies is done in the second loop */ std::vector<cond::DataProxyWrapperBase *> proxyWrappers(m_tagCollection.size()); size_t ipb=0; for(it=itBeg;it!=itEnd;++it){ proxyWrappers[ipb++] = cond::ProxyFactory::get()->create(buildName(it->second.recordname)); } // now all required libraries have been loaded // init sessions and DataProxies ipb=0; for(it=itBeg;it!=itEnd;++it){ std::map<std::string, cond::DbSession>::iterator p = sessions.find( it->second.pfn ); cond::DbSession nsess; if (p==sessions.end()) { //open db get tag info (i.e. the IOV token...) nsess = m_connection.createSession(); nsess.openReadOnly( it->second.pfn, "" ); sessions.insert(std::make_pair(it->second.pfn,nsess)); } else nsess = (*p).second; //cond::MetaData metadata(nsess); //nsess.transaction().start(true); //std::string iovtoken = metadata.getToken(it->tag); // owenship... ProxyP proxy(proxyWrappers[ipb++]); // instert in the map m_proxies.insert(std::make_pair(it->second.recordname, proxy)); // initialize //proxy->lateInit(nsess,iovtoken, // it->labelname, it->pfn, it->tag // ); proxy->lateInit(nsess,it->second.tag, it->second.labelname, it->second.pfn); //nsess.transaction().commit(); } // one loaded expose all other tags to the Proxy! CondGetterFromESSource visitor( m_proxies ); ProxyMap::iterator b = m_proxies.begin(); ProxyMap::iterator e = m_proxies.end(); for ( ;b != e; b++ ) { (*b).second->proxy()->loadMore( visitor ); edm::eventsetup::EventSetupRecordKey recordKey(edm::eventsetup::EventSetupRecordKey::TypeTag::findType( (*b).first ) ); if( recordKey.type() != edm::eventsetup::EventSetupRecordKey::TypeTag() ) { findingRecordWithKey( recordKey ); usingRecordWithKey( recordKey ); } } m_stats.nData=m_proxies.size(); }
CondDBESSource::~CondDBESSource | ( | ) |
Definition at line 268 of file CondDBESSource.cc.
References b, gather_cfg::cout, alignCSCRings::e, cond::BasePayloadProxy::gstats, m_doDump, m_proxies, m_stats, CondDBESSource::Stats::nActualReconnect, CondDBESSource::Stats::nActualRefresh, CondDBESSource::Stats::nData, CondDBESSource::Stats::nLumi, CondDBESSource::Stats::nReconnect, CondDBESSource::Stats::nRefresh, CondDBESSource::Stats::nRun, and CondDBESSource::Stats::nSet.
{ //dump info FIXME: find a more suitable place... if (m_doDump) { std::cout << "CondDBESSource Statistics" << std::endl << "DataProxy " << m_stats.nData << " setInterval " << m_stats.nSet << " Runs " << m_stats.nRun << " Lumis " << m_stats.nLumi << " Refresh " << m_stats.nRefresh << " Actual Refresh " << m_stats.nActualRefresh << " Reconnect " << m_stats.nReconnect << " Actual Reconnect " << m_stats.nActualReconnect; std::cout << std::endl; std::cout << "Global Proxy Statistics" << std::endl << "proxy " << cond::BasePayloadProxy::gstats.nProxy << " make " << cond::BasePayloadProxy::gstats.nMake << " load " << cond::BasePayloadProxy::gstats.nLoad; std::cout << std::endl; ProxyMap::iterator b= m_proxies.begin(); ProxyMap::iterator e= m_proxies.end(); for ( ;b != e; b++ ) { dumpInfo( std::cout, (*b).first, *(*b).second ); std::cout << "\n" << std::endl; } // FIXME // We shall eventually close transaction and session... } }
void CondDBESSource::fillList | ( | const std::string & | pfn, |
std::vector< std::string > & | pfnList, | ||
const unsigned int | listSize, | ||
const std::string & | type | ||
) | [private] |
Definition at line 253 of file CondDBESSource.cc.
References Exception, i, split, and AlCaHLTBitMon_QueryRunRegistry::string.
Referenced by CondDBESSource().
{ boost::split( listToFill, stringList, boost::is_any_of("|"), boost::token_compress_off ); // If it is one clone it for each GT if( listToFill.size() == 1 ) { for( unsigned int i=1; i<listSize; ++i ) { listToFill.push_back(stringList); } } // else if they don't match the number of GTs throw an exception else if( listSize != listToFill.size() ) { throw cond::Exception( std::string( "ESSource: number of global tag components does not match number of "+type+" strings" ) ); } }
void CondDBESSource::fillTagCollectionFromDB | ( | const std::vector< std::string > & | coraldbList, |
const std::vector< std::string > & | prefix, | ||
const std::vector< std::string > & | postfix, | ||
const std::vector< std::string > & | roottagList, | ||
std::map< std::string, cond::TagMetadata > & | replacement | ||
) | [private] |
Definition at line 569 of file CondDBESSource.cc.
References NewTree::fid, fillTagCollectionFromGT(), cond::TagMetadata::labelname, m_tagCollection, cond::TagMetadata::objectname, cond::TagMetadata::pfn, prof2calltree::prefix, cond::TagMetadata::recordname, AlCaHLTBitMon_QueryRunRegistry::string, and cond::TagMetadata::tag.
Referenced by CondDBESSource().
{ std::set< cond::TagMetadata > tagcoll; auto coraldb = coraldbList.begin(); auto prefix = prefixList.begin(); auto postfix = postfixList.begin(); for( auto roottag = roottagList.begin(); roottag != roottagList.end(); ++roottag, ++coraldb, ++prefix, ++postfix) { fillTagCollectionFromGT(*coraldb, *prefix, *postfix, *roottag, tagcoll); } std::set<cond::TagMetadata>::iterator tagCollIter; std::set<cond::TagMetadata>::iterator tagCollBegin = tagcoll.begin(); std::set<cond::TagMetadata>::iterator tagCollEnd = tagcoll.end(); // FIXME the logic is a bit perverse: can be surely linearized (at least simplified!) .... for( tagCollIter = tagCollBegin; tagCollIter != tagCollEnd; ++tagCollIter ) { std::string recordLabelKey = joinRecordAndLabel( tagCollIter->recordname, tagCollIter->labelname ); std::map<std::string,cond::TagMetadata>::iterator fid = replacement.find( recordLabelKey ); if( fid != replacement.end() ) { cond::TagMetadata tagMetadata; tagMetadata.recordname = tagCollIter->recordname; tagMetadata.labelname = tagCollIter->labelname; tagMetadata.pfn = fid->second.pfn; tagMetadata.tag = fid->second.tag; tagMetadata.objectname = tagCollIter->objectname; m_tagCollection.insert( std::make_pair( recordLabelKey, tagMetadata ) ); replacement.erase( fid ); edm::LogInfo( "CondDBESSource" ) << "Replacing connection string \"" << tagCollIter->pfn << "\" and tag \"" << tagCollIter->tag << "\" for record \"" << tagMetadata.recordname << "\" and label \"" << tagMetadata.labelname << "\" with connection string \"" << tagMetadata.pfn << "\" and tag " << tagMetadata.tag << "\"; from CondDBESSource::fillTagCollectionFromDB"; } else { m_tagCollection.insert( std::make_pair( recordLabelKey, *tagCollIter) ); } } std::map<std::string,cond::TagMetadata>::iterator replacementIter; std::map<std::string,cond::TagMetadata>::iterator replacementBegin = replacement.begin(); std::map<std::string,cond::TagMetadata>::iterator replacementEnd = replacement.end(); for( replacementIter = replacementBegin; replacementIter != replacementEnd; ++replacementIter ){ // std::cout<<"appending"<<std::endl; // std::cout<<"pfn "<<replacementIter->second.pfn<<std::endl; // std::cout<<"objectname "<<replacementIter->second.objectname<<std::endl; // std::cout<<"tag "<<replacementIter->second.tag<<std::endl; // std::cout<<"recordname "<<replacementIter->second.recordname<<std::endl; m_tagCollection.insert( *replacementIter ); } }
void CondDBESSource::fillTagCollectionFromGT | ( | const std::string & | coraldb, |
const std::string & | prefix, | ||
const std::string & | postfix, | ||
const std::string & | roottag, | ||
std::set< cond::TagMetadata > & | tagcoll | ||
) | [private] |
Definition at line 545 of file CondDBESSource.cc.
References cond::Auth::COND_READER_ROLE, cond::DbConnection::createSession(), cond::TagCollectionRetriever::getTagCollection(), m_connection, cond::DbSession::open(), python::CommonUtils::session, AlCaHLTBitMon_QueryRunRegistry::string, and cond::DbSession::transaction().
Referenced by fillTagCollectionFromDB().
{ // std::cout << "coraldb = " << coraldb << std::endl; // std::cout << "prefix = " << prefix << std::endl; // std::cout << "postfix = " << postfix << std::endl; // std::cout << "roottag = " << roottag << std::endl; if ( !roottag.empty() ) { if ( coraldb.empty() ) throw cond::Exception( std::string( "ESSource: requested global tag ") + roottag + std::string( " but not connection string given" ) ); cond::DbSession session = m_connection.createSession(); session.open( coraldb, cond::Auth::COND_READER_ROLE, true ); session.transaction().start( true ); cond::TagCollectionRetriever tagRetriever( session, prefix, postfix ); tagRetriever.getTagCollection( roottag,tagcoll ); session.transaction().commit(); } }
void CondDBESSource::newInterval | ( | const edm::eventsetup::EventSetupRecordKey & | iRecordType, |
const edm::ValidityInterval & | iInterval | ||
) | [protected, virtual] |
called when a new interval of validity occurs for iRecordType
Implements edm::eventsetup::DataProxyProvider.
Definition at line 536 of file CondDBESSource.cc.
References edm::eventsetup::DataProxyProvider::invalidateProxies().
{ //LogDebug ("CondDBESSource")<<"newInterval"; invalidateProxies(iRecordType); }
void CondDBESSource::registerProxies | ( | const edm::eventsetup::EventSetupRecordKey & | iRecordKey, |
KeyedProxies & | aProxyList | ||
) | [protected, virtual] |
Implements edm::eventsetup::DataProxyProvider.
Definition at line 514 of file CondDBESSource.cc.
References b, alignCSCRings::e, combine::key, m_proxies, edm::eventsetup::EventSetupRecordKey::name(), AlCaHLTBitMon_ParallelJobs::p, and AlCaHLTBitMon_QueryRunRegistry::string.
{ std::string recordname=iRecordKey.name(); ProxyMap::const_iterator b = m_proxies.lower_bound(recordname); ProxyMap::const_iterator e = m_proxies.upper_bound(recordname); if ( b == e) { edm::LogInfo( "CondDBESSource" ) << "No DataProxy (Pluging) found for record \""<< recordname << "\"; from CondDBESSource::registerProxies"; return; } for (ProxyMap::const_iterator p=b;p!=e;++p) { if(0 != (*p).second.get()) { edm::eventsetup::TypeTag type = (*p).second->type(); edm::eventsetup::DataKey key( type, edm::eventsetup::IdTags((*p).second->label().c_str()) ); aProxyList.push_back(KeyedProxies::value_type(key,(*p).second->edmProxy())); } } }
void CondDBESSource::setIntervalFor | ( | const edm::eventsetup::EventSetupRecordKey & | iKey, |
const edm::IOVSyncValue & | iTime, | ||
edm::ValidityInterval & | oInterval | ||
) | [protected, virtual] |
Implements edm::EventSetupRecordIntervalFinder.
Definition at line 306 of file CondDBESSource.cc.
References cond::DbConnection::createSession(), edm::IOVSyncValue::eventID(), edm::ValidityInterval::first(), cond::fromIOVSyncValue(), edm::ValidityInterval::invalidInterval(), edm::ValidityInterval::last(), cond::limitedIOVSyncValue(), edm::IOVSyncValue::luminosityBlockNumber(), m_connection, m_lastLumi, m_lastRecordRuns, m_lastRun, m_policy, m_proxies, m_sessionPool, m_stats, m_tagCollection, max(), min, CondDBESSource::Stats::nActualReconnect, CondDBESSource::Stats::nActualRefresh, edm::eventsetup::EventSetupRecordKey::name(), CondDBESSource::Stats::nLumi, CondDBESSource::Stats::nReconnect, CondDBESSource::Stats::nRefresh, CondDBESSource::Stats::nRun, CondDBESSource::Stats::nSet, cond::DbSession::openReadOnly(), RECONNECT_EACH_RUN, REFRESH_ALWAYS, REFRESH_EACH_RUN, REFRESH_OPEN_IOVS, dqm_diff::start, AlCaHLTBitMon_QueryRunRegistry::string, edm::IOVSyncValue::time(), cond::TIMELIMIT(), dtNoiseCalibration_cfg::timetype, cond::timeTypeNames(), cond::timeTypeSpecs, and cond::toIOVSyncValue().
{ std::string recordname=iKey.name(); edm::LogInfo( "CondDBESSource" ) << "Getting data for record \""<< recordname << "\" to be consumed by "<< iTime.eventID() << ", timestamp: " << iTime.time().value() << "; from CondDBESSource::setIntervalFor"; m_stats.nSet++; //{ // not really required, keep here for the time being if(iTime.eventID().run()!=m_lastRun) { m_lastRun=iTime.eventID().run(); m_stats.nRun++; } if(iTime.luminosityBlockNumber()!=m_lastLumi) { m_lastLumi=iTime.luminosityBlockNumber(); m_stats.nLumi++; } //} bool doRefresh = false; if( m_policy == REFRESH_EACH_RUN || m_policy == RECONNECT_EACH_RUN ) { // find out the last run number for the proxy of the specified record std::map<std::string,unsigned int>::iterator iRec = m_lastRecordRuns.find( recordname ); if( iRec != m_lastRecordRuns.end() ){ unsigned int lastRecordRun = iRec->second; if( lastRecordRun != m_lastRun ){ // a refresh is required! doRefresh = true; iRec->second = m_lastRun; edm::LogInfo( "CondDBESSource" ) << "Preparing refresh for record \"" << recordname << "\" since there has been a transition from run " << lastRecordRun << " to run " << m_lastRun << "; from CondDBESSource::setIntervalFor"; } } else { doRefresh = true; m_lastRecordRuns.insert( std::make_pair( recordname, m_lastRun ) ); edm::LogInfo( "CondDBESSource" ) << "Preparing refresh for record \"" << recordname << "\" for " << iTime.eventID() << ", timestamp: " << iTime.time().value() << "; from CondDBESSource::setIntervalFor"; } if ( !doRefresh ) edm::LogInfo( "CondDBESSource" ) << "Though enabled, refresh not needed for record \"" << recordname << "\" for " << iTime.eventID() << ", timestamp: " << iTime.time().value() << "; from CondDBESSource::setIntervalFor"; } else if( m_policy == REFRESH_ALWAYS || m_policy == REFRESH_OPEN_IOVS ) { doRefresh = true; edm::LogInfo( "CondDBESSource" ) << "Forcing refresh for record \"" << recordname << "\" for " << iTime.eventID() << ", timestamp: " << iTime.time().value() << "; from CondDBESSource::setIntervalFor"; } oInterval = edm::ValidityInterval::invalidInterval(); // compute the smallest interval (assume all objects have the same timetype....) cond::ValidityInterval recordValidity(1,cond::TIMELIMIT); cond::TimeType timetype; bool userTime=true; //FIXME use equal_range ProxyMap::const_iterator pmBegin = m_proxies.lower_bound(recordname); ProxyMap::const_iterator pmEnd = m_proxies.upper_bound(recordname); if ( pmBegin == pmEnd ) { edm::LogInfo( "CondDBESSource" ) << "No DataProxy (Pluging) found for record \""<< recordname << "\"; from CondDBESSource::setIntervalFor"; return; } for ( ProxyMap::const_iterator pmIter = pmBegin; pmIter != pmEnd; ++pmIter ) { edm::LogInfo( "CondDBESSource" ) << "Processing record \"" << recordname << "\" and label \""<< pmIter->second->label() << "\" for " << iTime.eventID() << ", timestamp: " << iTime.time().value() << "; from CondDBESSource::setIntervalFor"; timetype = (*pmIter).second->proxy()->timetype(); cond::Time_t abtime = cond::fromIOVSyncValue( iTime, timetype ); userTime = ( 0 == abtime ); //std::cout<<"abtime "<<abtime<<std::endl; if (userTime) return; // oInterval invalid to avoid that make is called... if( doRefresh ) { std::string recKey = joinRecordAndLabel( recordname, pmIter->second->label() ); TagCollection::const_iterator tcIter = m_tagCollection.find( recKey ); if ( tcIter == m_tagCollection.end() ) { edm::LogInfo( "CondDBESSource" ) << "No Tag found for record \""<< recordname << "\" and label \""<< pmIter->second->label() << "\"; from CondDBESSource::setIntervalFor"; return; } // first reconnect if required if( m_policy == RECONNECT_EACH_RUN ) { edm::LogInfo( "CondDBESSource" ) << "Checking if the session must be closed and re-opened for getting correct conditions" << "; from CondDBESSource::setIntervalFor"; std::stringstream transId; //transId << "long" << m_lastRun; transId << m_lastRun; std::map<std::string,std::pair<cond::DbSession,std::string> >::iterator iSess = m_sessionPool.find( tcIter->second.pfn ); cond::DbSession theSession; bool reopen = false; if( iSess != m_sessionPool.end() ){ if( iSess->second.second != transId.str() ) { // the available session is open for a different run: reopen reopen = true; iSess->second.second = transId.str(); } theSession = iSess->second.first; } else { // no available session: probably first run analysed... theSession = m_connection.createSession(); m_sessionPool.insert(std::make_pair( tcIter->second.pfn,std::make_pair(theSession,transId.str()) )); reopen = true; } if( reopen ){ theSession.openReadOnly( tcIter->second.pfn, transId.str() ); edm::LogInfo( "CondDBESSource" ) << "Re-opening the session with connection string " << tcIter->second.pfn << " and new transaction Id " << transId.str() << "; from CondDBESSource::setIntervalFor"; } edm::LogInfo( "CondDBESSource" ) << "Reconnecting to \"" << tcIter->second.pfn << "\" for getting new payload for record \"" << recordname << "\" and label \""<< pmIter->second->label() << "\" from IOV tag \"" << tcIter->second.tag << "\" to be consumed by " << iTime.eventID() << ", timestamp: " << iTime.time().value() << "; from CondDBESSource::setIntervalFor"; bool isSizeIncreased = pmIter->second->proxy()->refresh( theSession ); if( isSizeIncreased ) edm::LogInfo( "CondDBESSource" ) << "After reconnecting, an increased size of the IOV sequence labeled by tag \"" << tcIter->second.tag << "\" was found; from CondDBESSource::setIntervalFor"; m_stats.nActualReconnect += isSizeIncreased; m_stats.nReconnect++; } else { edm::LogInfo( "CondDBESSource" ) << "Refreshing IOV sequence labeled by tag \"" << tcIter->second.tag << "\" for getting new payload for record \"" << recordname << "\" and label \""<< pmIter->second->label() << "\" to be consumed by " << iTime.eventID() << ", timestamp: " << iTime.time().value() << "; from CondDBESSource::setIntervalFor"; bool isSizeIncreased = pmIter->second->proxy()->refresh(); if( isSizeIncreased ) edm::LogInfo( "CondDBESSource" ) << "After refreshing, an increased size of the IOV sequence labeled by tag \"" << tcIter->second.tag << "\" was found; from CondDBESSource::setIntervalFor"; m_stats.nActualRefresh += isSizeIncreased; m_stats.nRefresh++; } } /* // make oInterval valid For Ever { oInterval = edm::ValidityInterval(cond::toIOVSyncValue(recordValidity.first, cond::runnumber, true), cond::toIOVSyncValue(recordValidity.second, cond::runnumber, false)); return; } */ //query the IOVSequence cond::ValidityInterval validity = (*pmIter).second->proxy()->setIntervalFor( abtime ); edm::LogInfo( "CondDBESSource" ) << "Validity coming from IOV sequence for record \"" << recordname << "\" and label \""<< pmIter->second->label() << "\": (" << validity.first << ", " << validity.second << ") for time (type: "<< cond::timeTypeNames( timetype ) << ") " << abtime << "; from CondDBESSource::setIntervalFor"; recordValidity.first = std::max(recordValidity.first,validity.first); recordValidity.second = std::min(recordValidity.second,validity.second); } if( m_policy == REFRESH_OPEN_IOVS ) { doRefresh = ( recordValidity.second == cond::timeTypeSpecs[timetype].endValue ); edm::LogInfo( "CondDBESSource" ) << "Validity for record \"" << recordname << "\" and the corresponding label(s) coming from Condition DB: (" << recordValidity.first << ", "<< recordValidity.first << ") as the last IOV element in the IOV sequence is infinity" << "; from CondDBESSource::setIntervalFor"; } // to force refresh we set end-value to the minimum such an IOV can extend to: current run or lumiblock if ( (!userTime) && recordValidity.second !=0 ) { edm::IOVSyncValue start = cond::toIOVSyncValue(recordValidity.first, timetype, true); edm::IOVSyncValue stop = doRefresh ? cond::limitedIOVSyncValue (iTime, timetype) : cond::toIOVSyncValue(recordValidity.second, timetype, false); oInterval = edm::ValidityInterval( start, stop ); } edm::LogInfo( "CondDBESSource" ) << "Setting validity for record \"" << recordname << "\" and corresponding label(s): starting at " << oInterval.first().eventID() << ", timestamp: " << oInterval.first().time().value() << ", ending at "<< oInterval.last().eventID() << ", timestamp: " << oInterval.last().time().value() << ", for "<< iTime.eventID() << ", timestamp: " << iTime.time().value() << "; from CondDBESSource::setIntervalFor"; }
Definition at line 60 of file CondDBESSource.h.
Referenced by CondDBESSource(), fillTagCollectionFromGT(), and setIntervalFor().
bool CondDBESSource::m_doDump [private] |
Definition at line 89 of file CondDBESSource.h.
Referenced by ~CondDBESSource().
unsigned int CondDBESSource::m_lastLumi [private] |
Definition at line 86 of file CondDBESSource.h.
Referenced by setIntervalFor().
std::map<std::string,unsigned int> CondDBESSource::m_lastRecordRuns [private] |
Definition at line 70 of file CondDBESSource.h.
Referenced by setIntervalFor().
unsigned int CondDBESSource::m_lastRun [private] |
Definition at line 85 of file CondDBESSource.h.
Referenced by setIntervalFor().
RefreshPolicy CondDBESSource::m_policy [private] |
Definition at line 87 of file CondDBESSource.h.
Referenced by CondDBESSource(), and setIntervalFor().
ProxyMap CondDBESSource::m_proxies [private] |
Definition at line 63 of file CondDBESSource.h.
Referenced by CondDBESSource(), registerProxies(), setIntervalFor(), and ~CondDBESSource().
std::map<std::string,std::pair<cond::DbSession,std::string> > CondDBESSource::m_sessionPool [private] |
Definition at line 69 of file CondDBESSource.h.
Referenced by setIntervalFor().
Stats CondDBESSource::m_stats [private] |
Definition at line 83 of file CondDBESSource.h.
Referenced by CondDBESSource(), setIntervalFor(), and ~CondDBESSource().
TagCollection CondDBESSource::m_tagCollection [private] |
Definition at line 68 of file CondDBESSource.h.
Referenced by CondDBESSource(), fillTagCollectionFromDB(), and setIntervalFor().