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 
67  typedef enum { NOREFRESH, REFRESH_ALWAYS, REFRESH_OPEN_IOVS, REFRESH_EACH_RUN, RECONNECT_EACH_RUN } RefreshPolicy;
68 
69  explicit CondDBESSource(const edm::ParameterSet&);
70  ~CondDBESSource() override;
71 
72 protected:
73  void setIntervalFor(const EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override;
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
88  ProxyMap m_proxies;
89 
90  typedef std::map<std::string, cond::GTEntry_t> TagCollection;
91  // the collections of tag, record/label used in this ESSource
92  TagCollection m_tagCollection;
93  std::map<std::string, std::pair<cond::persistency::Session, std::string> > m_sessionPool;
94  std::map<std::string, unsigned int> m_lastRecordRuns;
95 
96  struct Stats {
97  int nData;
98  int nSet;
99  int nRun;
100  int nLumi;
101  int nRefresh;
105  };
106 
108 
109  unsigned int m_lastRun;
110  unsigned int m_lastLumi;
111  RefreshPolicy m_policy;
112 
113  bool m_doDump;
114 
115 private:
116  void fillList(const std::string& pfn,
117  std::vector<std::string>& pfnList,
118  const unsigned int listSize,
119  const std::string& type);
120 
121  void fillTagCollectionFromGT(const std::string& connectionString,
122  const std::string& prefix,
123  const std::string& postfix,
124  const std::string& roottag,
125  std::set<cond::GTEntry_t>& tagcoll,
126  cond::GTMetadata_t& gtMetadata);
127 
128  void fillTagCollectionFromDB(const std::vector<std::string>& connectionStringList,
129  const std::vector<std::string>& prefixList,
130  const std::vector<std::string>& postfixList,
131  const std::vector<std::string>& roottagList,
132  std::map<std::string, cond::GTEntry_t>& replacement,
133  cond::GTMetadata_t& gtMetadata);
134 };
135 #endif
type
Definition: HCALResponse.h:21
std::map< std::string, cond::GTEntry_t > TagCollection
std::map< std::string, std::pair< cond::persistency::Session, std::string > > m_sessionPool
RefreshPolicy m_policy
cond::persistency::ConnectionPool m_connection
std::multimap< std::string, ProxyP > ProxyMap
std::shared_ptr< cond::DataProxyWrapperBase > ProxyP
std::vector< std::pair< DataKey, std::shared_ptr< DataProxy >>> KeyedProxiesVector
TagCollection m_tagCollection
std::string m_connectionString
ProxyMap m_proxies
Definition: plugin.cc:23
HLT enums.
unsigned int m_lastRun
bool isConcurrentFinder() const override
std::map< std::string, unsigned int > m_lastRecordRuns
unsigned int m_lastLumi