14 #include "boost/shared_ptr.hpp"
43 buildName(
const std::string& iRecordName) {
44 return iRecordName+
"@NewProxy";
57 virtual ~CondGetterFromESSource(){}
60 CondDBESSource::ProxyMap::const_iterator
p = m_proxies.find(
name);
61 if ( p != m_proxies.end())
62 return (*p).second->proxy()->iov();
72 out << recName <<
" / " << proxy.
label() <<
": "
74 <<
state.size() <<
", " <<
state.revision() <<
", "
78 <<
" make " << proxy.
proxy()->stats.nMake
79 <<
", load " << proxy.
proxy()->stats.nLoad
81 if ( proxy.
proxy()->stats.nLoad>0) {
82 out <<
"\n oids,sinces:";
84 for (cond::BasePayloadProxy::ObjIds::const_iterator
id=ids.begin();
id!=ids.end(); ++
id)
87 << (*id).oid1 <<
"-"<< (*id).oid2 <<
","
107 doRefresh(iConfig.getUntrackedParameter<bool>(
"RefreshEachRun",
false)),
108 doDump(iConfig.getUntrackedParameter<bool>(
"DumpStat",
false))
118 std::string userconnect= iConfig.
getParameter<std::string>(
"connect");
128 std::map<std::string,cond::TagMetadata> replacement;
129 if( iConfig.
exists(
"toGet") ){
130 typedef std::vector< edm::ParameterSet >
Parameters;
132 for(Parameters::iterator itToGet = toGet.begin(); itToGet != toGet.end(); ++itToGet ) {
134 nm.
recordname=itToGet->getParameter<std::string>(
"record");
135 nm.
labelname=itToGet->getUntrackedParameter<std::string>(
"label",
"");
136 nm.
tag=itToGet->getParameter<std::string>(
"tag");
137 nm.
pfn=itToGet->getUntrackedParameter<std::string>(
"connect",userconnect);
140 replacement.insert(std::pair<std::string,cond::TagMetadata>(k,nm));
146 if( iConfig.
exists(
"globaltag")) globaltag=iConfig.
getParameter<std::string>(
"globaltag");
155 TagCollection::iterator it;
159 typedef std::map<std::string, cond::DbSession> Sessions;
170 std::vector<cond::DataProxyWrapperBase *> proxyWrappers(
m_tagCollection.size());
172 for(it=itBeg;it!=itEnd;++it){
173 proxyWrappers[ipb++] =
179 for(it=itBeg;it!=itEnd;++it){
180 Sessions::iterator p = sessions.find( it->pfn);
182 if (p==sessions.end()) {
185 nsess.
open( it->pfn,
true );
188 sessions.insert(std::make_pair(it->pfn,nsess));
189 }
else nsess = (*p).second;
192 transaction.
start(
true);
193 std::string iovtoken = metadata.
getToken(it->tag);
196 ProxyP proxy(proxyWrappers[ipb++]);
198 m_proxies.insert(std::make_pair(it->recordname, proxy));
200 proxy->lateInit(nsess,iovtoken,
201 it->labelname, it->pfn, it->tag
206 CondGetterFromESSource visitor(
m_proxies);
210 (*b).second->proxy()->loadMore(visitor);
227 std::cout <<
"CondDBESSource Statistics" << std::endl
234 std::cout <<
"Global Proxy Statistics" << std::endl
244 dumpInfo(
std::cout,(*b).first,*(*b).second);
263 std::string recordname=iKey.
name();
267 ProxyMap::const_iterator
b =
m_proxies.lower_bound(recordname);
268 ProxyMap::const_iterator
e =
m_proxies.upper_bound(recordname);
270 LogDebug (
"CondDBESSource")<<
"no DataProxy (Pluging) found for record "<<recordname;
278 for (ProxyMap::const_iterator p=b;p!=
e;++
p) {
294 timetype = (*p).second->proxy()->timetype();
297 userTime = (0==abtime);
304 recordValidity.first =
std::max(recordValidity.first,validity.first);
305 recordValidity.second =
std::min(recordValidity.second,validity.second);
313 if ( (!userTime) && recordValidity.second!=0) {
326 std::string recordname=iRecordKey.
name();
328 ProxyMap::const_iterator
b =
m_proxies.lower_bound(recordname);
329 ProxyMap::const_iterator
e =
m_proxies.upper_bound(recordname);
331 LogDebug (
"CondDBESSource")<<
"no DataProxy (Pluging) found for record "<<recordname;
335 for (ProxyMap::const_iterator p=b;p!=
e;++
p) {
336 if(0 != (*p).second.get()) {
357 const std::string &
prefix,
358 const std::string & postfix,
359 const std::string & roottag,
360 std::map<std::string,cond::TagMetadata>& replacement){
364 std::set< cond::TagMetadata > tagcoll;
366 if (!roottag.empty()) {
368 throw cond::Exception(std::string(
"ESSource: requested global tag ")+roottag+
" but not connection string given");
370 session.
open( coraldb,
true );
372 transaction.
start(
true);
378 std::set<cond::TagMetadata>::iterator it;
379 std::set<cond::TagMetadata>::iterator itBeg=tagcoll.begin();
380 std::set<cond::TagMetadata>::iterator itEnd=tagcoll.end();
383 for(it=itBeg; it!=itEnd; ++it){
384 std::string
k=it->recordname+
"@"+it->labelname;
385 std::map<std::string,cond::TagMetadata>::iterator
fid=replacement.find(k);
386 if(fid != replacement.end()){
390 m.
pfn=fid->second.pfn;
391 m.
tag=fid->second.tag;
394 replacement.erase(fid);
399 std::map<std::string,cond::TagMetadata>::iterator itrep;
400 std::map<std::string,cond::TagMetadata>::iterator itrepBeg=replacement.begin();
401 std::map<std::string,cond::TagMetadata>::iterator itrepEnd=replacement.end();
402 for(itrep=itrepBeg; itrep!=itrepEnd; ++itrep){
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
static HCTypeTag findType(const char *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
edm::IOVSyncValue limitedIOVSyncValue(cond::Time_t time, cond::TimeType timetype)
const EventID & eventID() const
DbTransaction & transaction()
void open(const std::string &connectionString, bool readOnly=false)
virtual void registerProxies(const edm::eventsetup::EventSetupRecordKey &iRecordKey, KeyedProxies &aProxyList)
void getTagCollection(const std::string &globaltag, std::set< cond::TagMetadata > &result)
DbConnectionConfiguration & configuration()
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::pair< Time_t, Time_t > ValidityInterval
void usingRecordWithKey(const EventSetupRecordKey &)
virtual ProxyP proxy() const =0
Container::value_type value_type
cond::DbConnection m_connection
void setParameters(const edm::ParameterSet &connectionPset)
void fillTagCollectionFromDB(const std::string &coraldb, const std::string &prefix, const std::string &postfix, const std::string &roottag, std::map< std::string, cond::TagMetadata > &replacement)
int start(bool readOnly=false)
start transaction
std::string const & label() const
edm::IOVSyncValue toIOVSyncValue(cond::Time_t time, cond::TimeType timetype, bool startOrStop)
unsigned long long Time_t
void invalidateProxies(const EventSetupRecordKey &iRecordKey)
const T & max(const T &a, const T &b)
bool isTransactional() const
std::vector< std::pair< DataKey, boost::shared_ptr< DataProxy > > > KeyedProxies
const char * name() const
virtual void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &)
int start(bool readOnly=false)
start transaction
std::vector< ObjId > ObjIds
std::multimap< std::string, ProxyP > ProxyMap
std::string const & connString() const
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
PoolDBESSource(const edm::ParameterSet &ps)
TagCollection m_tagCollection
DbSession createSession() const
const Time_t TIMELIMIT(std::numeric_limits< Time_t >::max())
std::string const & tag() const
std::vector< AlignmentParameters * > Parameters
heterocontainer::HCTypeTag TypeTag
const TypeTag & type() const
static const ValidityInterval & invalidInterval()
virtual void newInterval(const edm::eventsetup::EventSetupRecordKey &iRecordType, const edm::ValidityInterval &iInterval)
called when a new interval of validity occurs for iRecordType
cond::Time_t fromIOVSyncValue(edm::IOVSyncValue const &time, cond::TimeType timetype)
CondDBESSource(const edm::ParameterSet &)
int commit()
commit transaction. Will disconnect from database if connection timeout==0 or connectted time close t...
boost::shared_ptr< cond::DataProxyWrapperBase > ProxyP
boost::posix_time::ptime to_boost(Time_t iValue)
T get(const Candidate &c)
void findingRecordWithKey(const eventsetup::EventSetupRecordKey &)