1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
#ifndef CONDCORE_POPCON_ONLINEPOPCON_H
#define CONDCORE_POPCON_ONLINEPOPCON_H
//
// Authors:
// - Francesco Brivio (Milano-Bicocca)
// - Jan Chyczynski (AGH University of Krakow)
//
#include "CondCore/DBOutputService/interface/OnlineDBOutputService.h"
#include "CondCore/PopCon/interface/Exception.h"
#include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
namespace popcon {
// Populator of the Condition DB.
// Specific implementation for online lumi-based conditions (OnlineDBOutputService)
class OnlinePopCon {
public:
typedef cond::Time_t Time_t;
OnlinePopCon(const edm::ParameterSet& pset);
virtual ~OnlinePopCon();
template <typename Source>
void write(Source const& source);
private:
cond::persistency::Session initialize();
cond::persistency::Session preparePopCon();
void finalize();
private:
// DB service
edm::Service<cond::service::OnlineDBOutputService> m_dbService;
// PopCon infrastructure
cond::persistency::Session m_targetSession;
std::string m_targetConnectionString;
std::string m_authPath;
int m_authSys;
std::string m_recordName;
cond::TagInfo_t m_tagInfo;
cond::LogDBEntry_t m_logDBEntry;
// OnlinePopCon specific
int m_dbLoggerReturn_; // DB logger return value
bool m_useLockRecors; // whether to lock the records or not
// Version
static constexpr const char* const s_version = "1.0";
};
template <typename Source>
void OnlinePopCon::write(Source const& source) {
// Get data to be uploaded
typedef typename Source::Container Container;
std::pair<Container const*, std::string const> ret = source(initialize(), m_tagInfo, m_logDBEntry);
Container const& iovs = *ret.first;
// Check that only 1 iov/payload is provided
if (iovs.size() > 1) {
throw Exception("OnlinePopCon", "[write] More than one iov/payload provided!");
}
// If zero payloads to transfer, finalize and return
if (iovs.empty()) {
m_dbService->logger().logInfo() << "OnlinePopCon::write - Nothing to transfer";
finalize();
return;
}
// Upload
// Check if DB service is available
if (!m_dbService.isAvailable()) {
throw Exception("OnlinePopCon", "[write] DBService not available");
}
// Get the only payload to transfer
auto [originalSince, payload] = *iovs.begin();
// Log the original since
m_dbService->logger().logInfo() << "OnlinePopCon::write - original since: " << originalSince;
// Upload the payload
try {
auto targetSince = m_dbService->writeIOVForNextLumisection(*payload, m_recordName);
m_dbService->logger().logInfo() << "OnlinePopCon::write - writeForNextLumisection successful!";
m_dbService->logger().logInfo() << "OnlinePopCon::write - uploaded with since: " << targetSince;
} catch (const std::exception& e) {
m_dbService->logger().logError() << "OnlinePopCon::write - Error writing record: " << m_recordName;
m_dbService->logger().logError() << "Error is: " << e.what();
m_dbLoggerReturn_ = 2;
}
// Finalize
finalize();
}
} // namespace popcon
#endif // CONDCORE_POPCON_ONLINEPOPCON_H
|