38 : m_logger(iConfig.getUntrackedParameter<
std::
string>(
"jobName",
"DBOutputService")),
41 m_transactionActive(
false),
42 m_dbInitialised(
false),
47 m_autoCommit = iConfig.getUntrackedParameter<
bool>(
"autoCommit",
false);
48 m_writeTransactionDelay = iConfig.getUntrackedParameter<
unsigned int>(
"writeTransactionDelay", 0);
50 m_connection.setParameters(connectionPset);
51 m_connection.setLogDestination(m_logger);
52 m_connection.configure();
55 bool saveLogsOnDb = iConfig.getUntrackedParameter<
bool>(
"saveLogsOnDB",
false);
60 typedef std::vector<edm::ParameterSet>
Parameters;
62 for (Parameters::iterator itToPut =
toPut.begin(); itToPut !=
toPut.end(); ++itToPut)
63 fillRecord(*itToPut, timetypestr);
95 std::lock_guard<std::recursive_mutex>
lock(m_mutex);
99 for (
auto& iR : m_records) {
100 if (iR.second.m_isNewTag ==
false) {
105 doCommitTransaction();
110 std::lock_guard<std::recursive_mutex>
lock(m_mutex);
111 doStartTransaction();
114 for (
auto& iR : m_records) {
115 if (iR.second.m_isNewTag ==
false) {
120 doCommitTransaction();
134 if (!m_transactionActive) {
135 m_session.transaction().start(
false);
136 m_transactionActive =
true;
141 if (m_transactionActive) {
142 m_session.transaction().commit();
143 m_transactionActive =
false;
148 std::lock_guard<std::recursive_mutex>
lock(m_mutex);
149 doStartTransaction();
153 std::lock_guard<std::recursive_mutex>
lock(m_mutex);
154 doCommitTransaction();
158 if (!m_dbInitialised) {
159 if (!m_session.existsDatabase())
160 m_session.createDatabase();
162 for (
auto& iR : m_records) {
163 if (m_session.existsIov(iR.second.m_tag))
164 iR.second.m_isNewTag =
false;
167 m_dbInitialised =
true;
188 for (
auto&
time : m_currentTimes) {
194 for (
auto&
time : m_currentTimes) {
202 std::lock_guard<std::recursive_mutex>
lock(m_mutex);
203 doStartTransaction();
225 std::lock_guard<std::recursive_mutex>
lock(m_mutex);
230 m_logger.logInfo() <<
"Creating new tag " << myrecord.
m_tag <<
", adding iov with since " << firstSinceTime
231 <<
" pointing to payload id " << firstPayloadId;
232 doStartTransaction();
239 editor.
insert(firstSinceTime, firstPayloadId);
253 m_logger.logInfo() <<
"Creating new tag " << myrecord.
m_tag <<
" for payload type " <<
payloadType
254 <<
", adding iov with since " << firstSinceTime;
259 editor.
insert(firstSinceTime, firstPayloadId);
268 std::lock_guard<std::recursive_mutex>
lock(m_mutex);
272 "PoolDBOutputService::appendSinceTime");
275 doStartTransaction();
278 ret = appendSinceTime(payloadId,
time, myrecord);
289 m_logger.logInfo() <<
"Updating existing tag " << myrecord.
m_tag <<
", adding iov with since " <<
time;
306 std::lock_guard<std::recursive_mutex>
lock(m_mutex);
310 "PoolDBOutputService::appendSinceTime");
312 m_logger.logInfo() <<
"Updating existing tag " << myrecord.
m_tag <<
", removing iov with since " << sinceTime
313 <<
" pointing to payload id " << payloadId;
314 doStartTransaction();
318 editor.
erase(sinceTime, payloadId);
330 std::map<std::string, Record>::iterator it = m_records.find(
recordName);
331 if (it == m_records.end()) {
333 "PoolDBOutputService::lookUpRecord");
339 std::map<std::string, cond::UserLogInfo>::iterator it = m_logheaders.find(
recordName);
340 if (it == m_logheaders.end())
342 " from PoolDBOutputService::lookUpUserLogInfo");
347 std::lock_guard<std::recursive_mutex>
lock(m_mutex);
351 "PoolDBOutputService::closeIOV");
353 m_logger.logInfo() <<
"Updating existing tag " << myrecord.
m_tag <<
", closing with end of validity " << lastTill;
354 doStartTransaction();
359 editor.
flush(
"Tag closed.");
378 m_logger.logDebug() <<
"Fetching tag info for " <<
record.m_tag;
379 doStartTransaction();
384 if (m_session.existsIov(
record.m_tag)) {
398 std::lock_guard<std::recursive_mutex>
lock(m_mutex);