File indexing completed on 2024-04-06 12:01:38
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/ESProductResolverProvider.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 ProductResolverWrapperBase;
0085 }
0086
0087 class CondDBESSource : public edm::eventsetup::ESProductResolverProvider, public edm::EventSetupRecordIntervalFinder {
0088 public:
0089 using DataKey = edm::eventsetup::DataKey;
0090 using EventSetupRecordKey = edm::eventsetup::EventSetupRecordKey;
0091 typedef std::shared_ptr<cond::ProductResolverWrapperBase> ResolverP;
0092 typedef std::multimap<std::string, ResolverP> ResolverMap;
0093
0094 typedef enum { NOREFRESH, REFRESH_ALWAYS, REFRESH_OPEN_IOVS, REFRESH_EACH_RUN, RECONNECT_EACH_RUN } RefreshPolicy;
0095
0096 std::string m_jsonDumpFilename;
0097
0098 explicit CondDBESSource(const edm::ParameterSet&);
0099 ~CondDBESSource() override;
0100
0101 protected:
0102 void setIntervalFor(const EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override;
0103
0104 KeyedResolversVector registerResolvers(const EventSetupRecordKey&, unsigned int iovIndex) override;
0105
0106 void initConcurrentIOVs(const EventSetupRecordKey& key, unsigned int nConcurrentIOVs) override;
0107
0108 bool isConcurrentFinder() const override { return true; }
0109
0110 private:
0111
0112
0113 cond::persistency::ConnectionPool m_connection;
0114 std::string m_connectionString;
0115 std::string m_frontierKey;
0116
0117
0118 ResolverMap m_resolvers;
0119
0120 typedef std::map<std::string, cond::GTEntry_t> TagCollection;
0121
0122 TagCollection m_tagCollection;
0123 std::map<std::string, std::pair<cond::Time_t, bool> > m_refreshTimeForRecord;
0124 std::map<std::string, std::pair<cond::persistency::Session, std::string> > m_sessionPool;
0125 std::map<std::string, std::pair<cond::persistency::Session, std::string> > m_sessionPoolForLumiConditions;
0126 std::map<std::string, unsigned int> m_lastRecordRuns;
0127
0128 edm::SerialTaskQueue m_queue;
0129 std::mutex m_mutex;
0130
0131 struct Stats {
0132 int nData;
0133 int nSet;
0134 int nRun;
0135 int nLumi;
0136 int nRefresh;
0137 int nActualRefresh;
0138 int nReconnect;
0139 int nActualReconnect;
0140 };
0141
0142 Stats m_stats;
0143
0144 unsigned int m_lastRun;
0145 unsigned int m_lastLumi;
0146 RefreshPolicy m_policy;
0147
0148 bool m_doDump;
0149
0150 private:
0151 void fillList(const std::string& pfn,
0152 std::vector<std::string>& pfnList,
0153 const unsigned int listSize,
0154 const std::string& type);
0155
0156 void fillTagCollectionFromGT(const std::string& connectionString,
0157 const std::string& prefix,
0158 const std::string& postfix,
0159 const std::string& roottag,
0160 std::set<cond::GTEntry_t>& tagcoll,
0161 cond::GTMetadata_t& gtMetadata);
0162
0163 void fillTagCollectionFromDB(const std::vector<std::string>& connectionStringList,
0164 const std::vector<std::string>& prefixList,
0165 const std::vector<std::string>& postfixList,
0166 const std::vector<std::string>& roottagList,
0167 std::map<std::string, cond::GTEntry_t>& replacement,
0168 cond::GTMetadata_t& gtMetadata);
0169
0170 void printStatistics(const Stats& stats) const;
0171 };
0172 #endif