File indexing completed on 2022-01-16 23:25:22
0001 #ifndef CondCore_ESSources_CondDBESSource_h
0002 #define CondCore_ESSources_CondDBESSource_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067 #include <string>
0068 #include <map>
0069 #include <memory>
0070 #include <set>
0071 #include <mutex>
0072
0073 #include "CondCore/CondDB/interface/ConnectionPool.h"
0074
0075 #include "FWCore/Framework/interface/DataProxyProvider.h"
0076 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
0077 #include "FWCore/Concurrency/interface/SerialTaskQueue.h"
0078
0079 namespace edm {
0080 class ParameterSet;
0081 }
0082
0083 namespace cond {
0084 class DataProxyWrapperBase;
0085 }
0086
0087 class CondDBESSource : public edm::eventsetup::DataProxyProvider, public edm::EventSetupRecordIntervalFinder {
0088 public:
0089 using DataKey = edm::eventsetup::DataKey;
0090 using EventSetupRecordKey = edm::eventsetup::EventSetupRecordKey;
0091 typedef std::shared_ptr<cond::DataProxyWrapperBase> ProxyP;
0092 typedef std::multimap<std::string, ProxyP> ProxyMap;
0093
0094 typedef enum { NOREFRESH, REFRESH_ALWAYS, REFRESH_OPEN_IOVS, REFRESH_EACH_RUN, RECONNECT_EACH_RUN } RefreshPolicy;
0095
0096 explicit CondDBESSource(const edm::ParameterSet&);
0097 ~CondDBESSource() override;
0098
0099 protected:
0100 void setIntervalFor(const EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override;
0101
0102 KeyedProxiesVector registerProxies(const EventSetupRecordKey&, unsigned int iovIndex) override;
0103
0104 void initConcurrentIOVs(const EventSetupRecordKey& key, unsigned int nConcurrentIOVs) override;
0105
0106 bool isConcurrentFinder() const override { return true; }
0107
0108 private:
0109
0110
0111 cond::persistency::ConnectionPool m_connection;
0112 std::string m_connectionString;
0113 std::string m_frontierKey;
0114
0115
0116 ProxyMap m_proxies;
0117
0118 typedef std::map<std::string, cond::GTEntry_t> TagCollection;
0119
0120 TagCollection m_tagCollection;
0121 std::map<std::string, std::pair<cond::Time_t, bool> > m_refreshTimeForRecord;
0122 std::map<std::string, std::pair<cond::persistency::Session, std::string> > m_sessionPool;
0123 std::map<std::string, std::pair<cond::persistency::Session, std::string> > m_sessionPoolForLumiConditions;
0124 std::map<std::string, unsigned int> m_lastRecordRuns;
0125
0126 edm::SerialTaskQueue m_queue;
0127 std::mutex m_mutex;
0128
0129 struct Stats {
0130 int nData;
0131 int nSet;
0132 int nRun;
0133 int nLumi;
0134 int nRefresh;
0135 int nActualRefresh;
0136 int nReconnect;
0137 int nActualReconnect;
0138 };
0139
0140 Stats m_stats;
0141
0142 unsigned int m_lastRun;
0143 unsigned int m_lastLumi;
0144 RefreshPolicy m_policy;
0145
0146 bool m_doDump;
0147
0148 private:
0149 void fillList(const std::string& pfn,
0150 std::vector<std::string>& pfnList,
0151 const unsigned int listSize,
0152 const std::string& type);
0153
0154 void fillTagCollectionFromGT(const std::string& connectionString,
0155 const std::string& prefix,
0156 const std::string& postfix,
0157 const std::string& roottag,
0158 std::set<cond::GTEntry_t>& tagcoll,
0159 cond::GTMetadata_t& gtMetadata);
0160
0161 void fillTagCollectionFromDB(const std::vector<std::string>& connectionStringList,
0162 const std::vector<std::string>& prefixList,
0163 const std::vector<std::string>& postfixList,
0164 const std::vector<std::string>& roottagList,
0165 std::map<std::string, cond::GTEntry_t>& replacement,
0166 cond::GTMetadata_t& gtMetadata);
0167 };
0168 #endif