CMS 3D CMS Logo

CondDBESSource.h
Go to the documentation of this file.
1 #ifndef CondCore_ESSources_CondDBESSource_h
2 #define CondCore_ESSources_CondDBESSource_h
3 //
4 // Package: CondCore/ESSources
5 // Class: CondDBESSource
6 //
7 /*
8  Description: EventSetup source module for serving data from offline database
9 */
10 //
11 // Author: Zhen Xie
12 //
13 
14 // Some comments on concurrency. There are 3 relevant things the Framework is
15 // doing that prevent concurrency issues. This happens automatically and
16 // CondDBESSource can rely on the Framework taking care of this.
17 //
18 // 1. There is a recursive global mutex which is locked while calls to
19 // DataProxy::make and setIntervalFor are executing that allows only
20 // 1 thread to be running one of those functions at a time. (There
21 // is some discussion about replacing this mutex with lockfree concurrency
22 // mechanisms someday in the future, although this would be done in such
23 // a way as to provide similar protection against data races.)
24 //
25 // 2. Calls are sequenced that a call to setIntervalFor is made, then
26 // all related calls to DataProxy::initializeForNewIOV are made before
27 // another call to setIntervalFor is made. It is configurable how many
28 // IOVs can be running concurrently. The Framework will not call
29 // initializeForNewIOV or start running a new IOV unless the
30 // number of active IOVs is less than that configured number.
31 //
32 // 3. Independent of the above two items, after a call is made to
33 // DataProxy::initializeForNewIOV for a particular
34 // EventSetupRecordKey and iovIndex, all calls to DataProxy::make
35 // associated with that whose data is requested will be completed
36 // and processing of luminosity blocks associated with that will
37 // be completed before another call to DataProxy::initializeForNewIOV
38 // is made for that EventSetupRecordKey and iovIndex.
39 
40 // system include files
41 #include <string>
42 #include <map>
43 #include <memory>
44 #include <set>
45 // user include files
47 
50 //#include "CondCore/DBCommon/interface/Time.h"
51 
52 namespace edm {
53  class ParameterSet;
54 }
55 
56 namespace cond {
57  class DataProxyWrapperBase;
58 }
59 
61 public:
64  typedef std::shared_ptr<cond::DataProxyWrapperBase> ProxyP;
65  typedef std::multimap<std::string, ProxyP> ProxyMap;
66 
68 
69  explicit CondDBESSource(const edm::ParameterSet&);
70  ~CondDBESSource() override;
71 
72 protected:
74 
75  KeyedProxiesVector registerProxies(const EventSetupRecordKey&, unsigned int iovIndex) override;
76 
77  void initConcurrentIOVs(const EventSetupRecordKey& key, unsigned int nConcurrentIOVs) override;
78 
79  bool isConcurrentFinder() const override { return true; }
80 
81 private:
82  // ----------member data ---------------------------
83 
86 
87  // Container of DataProxy, implemented as multi-map keyed by records
89 
90  typedef std::map<std::string, cond::GTEntry_t> TagCollection;
91  // the collections of tag, record/label used in this ESSource
93  std::map<std::string, cond::Time_t> m_refreshTimeForRecord;
94  std::map<std::string, std::pair<cond::persistency::Session, std::string> > m_sessionPool;
95  std::map<std::string, std::pair<cond::persistency::Session, std::string> > m_sessionPoolForLumiConditions;
96  std::map<std::string, cond::Time_t> m_lastRecordRuns;
97 
98  struct Stats {
99  int nData;
100  int nSet;
101  int nRun;
102  int nLumi;
103  int nRefresh;
107  };
108 
110 
111  unsigned int m_lastRun;
112  unsigned int m_lastLumi;
114 
115  bool m_doDump;
116 
117 private:
118  void fillList(const std::string& pfn,
119  std::vector<std::string>& pfnList,
120  const unsigned int listSize,
121  const std::string& type);
122 
124  const std::string& prefix,
125  const std::string& postfix,
126  const std::string& roottag,
127  std::set<cond::GTEntry_t>& tagcoll,
128  cond::GTMetadata_t& gtMetadata);
129 
130  void fillTagCollectionFromDB(const std::vector<std::string>& connectionStringList,
131  const std::vector<std::string>& prefixList,
132  const std::vector<std::string>& postfixList,
133  const std::vector<std::string>& roottagList,
134  std::map<std::string, cond::GTEntry_t>& replacement,
135  cond::GTMetadata_t& gtMetadata);
136 };
137 #endif
edm::eventsetup::DataProxyProvider
Definition: DataProxyProvider.h:64
CondDBESSource::REFRESH_EACH_RUN
Definition: CondDBESSource.h:67
CondDBESSource::fillList
void fillList(const std::string &pfn, std::vector< std::string > &pfnList, const unsigned int listSize, const std::string &type)
Definition: CondDBESSource.cc:284
ConnectionPool.h
CondDBESSource::m_connection
cond::persistency::ConnectionPool m_connection
Definition: CondDBESSource.h:84
CondDBESSource::Stats::nActualReconnect
int nActualReconnect
Definition: CondDBESSource.h:106
CondDBESSource::isConcurrentFinder
bool isConcurrentFinder() const override
Definition: CondDBESSource.h:79
CondDBESSource::Stats::nRun
int nRun
Definition: CondDBESSource.h:101
cond::GTMetadata_t
Definition: Types.h:101
CondDBESSource::initConcurrentIOVs
void initConcurrentIOVs(const EventSetupRecordKey &key, unsigned int nConcurrentIOVs) override
Definition: CondDBESSource.cc:577
edm
HLT enums.
Definition: AlignableModifier.h:19
CondDBESSource::TagCollection
std::map< std::string, cond::GTEntry_t > TagCollection
Definition: CondDBESSource.h:90
CondDBESSource::m_lastRun
unsigned int m_lastRun
Definition: CondDBESSource.h:111
edm::ValidityInterval
Definition: ValidityInterval.h:28
CondDBESSource::m_connectionString
std::string m_connectionString
Definition: CondDBESSource.h:85
EventSetupRecordKey
CondDBESSource::m_proxies
ProxyMap m_proxies
Definition: CondDBESSource.h:88
CondDBESSource::REFRESH_ALWAYS
Definition: CondDBESSource.h:67
edm::eventsetup::DataKey
Definition: DataKey.h:29
CondDBESSource::CondDBESSource
CondDBESSource(const edm::ParameterSet &)
Definition: CondDBESSource.cc:96
CondDBESSource::NOREFRESH
Definition: CondDBESSource.h:67
edm::EventSetupRecordIntervalFinder
Definition: EventSetupRecordIntervalFinder.h:33
CondDBESSource::m_doDump
bool m_doDump
Definition: CondDBESSource.h:115
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
CondDBESSource::m_sessionPoolForLumiConditions
std::map< std::string, std::pair< cond::persistency::Session, std::string > > m_sessionPoolForLumiConditions
Definition: CondDBESSource.h:95
CondDBESSource::REFRESH_OPEN_IOVS
Definition: CondDBESSource.h:67
CondDBESSource::m_lastLumi
unsigned int m_lastLumi
Definition: CondDBESSource.h:112
CondDBESSource::fillTagCollectionFromDB
void fillTagCollectionFromDB(const std::vector< std::string > &connectionStringList, const std::vector< std::string > &prefixList, const std::vector< std::string > &postfixList, const std::vector< std::string > &roottagList, std::map< std::string, cond::GTEntry_t > &replacement, cond::GTMetadata_t &gtMetadata)
Definition: CondDBESSource.cc:623
CondDBESSource::m_tagCollection
TagCollection m_tagCollection
Definition: CondDBESSource.h:92
CondDBESSource
Definition: CondDBESSource.h:60
CondDBESSource::Stats::nActualRefresh
int nActualRefresh
Definition: CondDBESSource.h:104
DataProxyProvider.h
CondDBESSource::m_stats
Stats m_stats
Definition: CondDBESSource.h:109
cond::persistency::ConnectionPool
Definition: ConnectionPool.h:35
edm::IOVSyncValue
Definition: IOVSyncValue.h:31
CondDBESSource::m_policy
RefreshPolicy m_policy
Definition: CondDBESSource.h:113
EventSetupRecordIntervalFinder.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CondDBESSource::Stats::nRefresh
int nRefresh
Definition: CondDBESSource.h:103
cond
Definition: plugin.cc:23
edm::ParameterSet
Definition: ParameterSet.h:36
ParameterSet
Definition: Functions.h:16
CondDBESSource::RECONNECT_EACH_RUN
Definition: CondDBESSource.h:67
CondDBESSource::RefreshPolicy
RefreshPolicy
Definition: CondDBESSource.h:67
CondDBESSource::setIntervalFor
void setIntervalFor(const EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
Definition: CondDBESSource.cc:328
CondDBESSource::Stats::nSet
int nSet
Definition: CondDBESSource.h:100
edm::eventsetup::DataProxyProvider::KeyedProxiesVector
std::vector< std::pair< DataKey, std::shared_ptr< DataProxy > >> KeyedProxiesVector
Definition: DataProxyProvider.h:196
CondDBESSource::registerProxies
KeyedProxiesVector registerProxies(const EventSetupRecordKey &, unsigned int iovIndex) override
Definition: CondDBESSource.cc:553
CondDBESSource::fillTagCollectionFromGT
void fillTagCollectionFromGT(const std::string &connectionString, const std::string &prefix, const std::string &postfix, const std::string &roottag, std::set< cond::GTEntry_t > &tagcoll, cond::GTMetadata_t &gtMetadata)
Definition: CondDBESSource.cc:589
CondDBESSource::ProxyMap
std::multimap< std::string, ProxyP > ProxyMap
Definition: CondDBESSource.h:65
type
type
Definition: HCALResponse.h:21
CondDBESSource::Stats::nReconnect
int nReconnect
Definition: CondDBESSource.h:105
CondDBESSource::Stats::nData
int nData
Definition: CondDBESSource.h:99
CondDBESSource::m_refreshTimeForRecord
std::map< std::string, cond::Time_t > m_refreshTimeForRecord
Definition: CondDBESSource.h:93
CondDBESSource::~CondDBESSource
~CondDBESSource() override
Definition: CondDBESSource.cc:302
CondDBESSource::ProxyP
std::shared_ptr< cond::DataProxyWrapperBase > ProxyP
Definition: CondDBESSource.h:64
CondDBESSource::m_lastRecordRuns
std::map< std::string, cond::Time_t > m_lastRecordRuns
Definition: CondDBESSource.h:96
l1RCTOmdsFedVectorProducer_cfi.connectionString
connectionString
Definition: l1RCTOmdsFedVectorProducer_cfi.py:4
CondDBESSource::Stats::nLumi
int nLumi
Definition: CondDBESSource.h:102
crabWrapper.key
key
Definition: crabWrapper.py:19
CondDBESSource::Stats
Definition: CondDBESSource.h:98
CondDBESSource::m_sessionPool
std::map< std::string, std::pair< cond::persistency::Session, std::string > > m_sessionPool
Definition: CondDBESSource.h:94
ZMuMuAnalysisNtupler_cff.prefix
prefix
Definition: ZMuMuAnalysisNtupler_cff.py:14