50 m_logConnectionString(
""),
57 m_closeIOV=iConfig.getUntrackedParameter<
bool>(
"closeIOV",m_closeIOV);
59 m_timetypestr=iConfig.getUntrackedParameter<
std::string >(
"timetype",
"runnumber");
65 connection.configure();
69 m_session = connection.createSession( connectionString,
true, backType );
71 if( iConfig.exists(
"logconnect") ){
72 m_logConnectionString = iConfig.getUntrackedParameter<
std::string>(
"logconnect");
74 conn.configuration().setParameters( connectionPset );
80 typedef std::vector< edm::ParameterSet >
Parameters;
81 Parameters
toPut=iConfig.getParameter<Parameters>(
"toPut");
82 for(Parameters::iterator itToPut = toPut.begin(); itToPut != toPut.end(); ++itToPut)
83 fillRecord( *itToPut);
114 return this->lookUpRecord(recordName).m_tag;
119 Record& myrecord=this->lookUpRecord(recordName);
126 std::lock_guard<std::recursive_mutex>
lock(m_mutex);
127 m_session.transaction().start(
false);
131 if( !m_session.existsDatabase() ) m_session.createDatabase();
134 if(!m_logConnectionString.empty()){
135 m_logdb->connect( m_logConnectionString );
136 m_logdb->createLogDBIfNonExist();
149 m_session.transaction().commit();
172 for(
auto&
time : m_currentTimes) {
179 for(
auto&
time : m_currentTimes) {
211 std::lock_guard<std::recursive_mutex>
lock(m_mutex);
214 Record& myrecord=this->lookUpRecord(recordName);
215 if(!myrecord.m_isNewTag) {
216 cond::throwException( myrecord.m_tag +
" is not a new tag",
"PoolDBOutputService::createNewIOV");
219 if( withlogging && m_logConnectionString.empty() )
221 "PoolDBOutputService::createNewIOV");
227 editor.
insert( firstSinceTime, firstPayloadId );
229 myrecord.m_isNewTag=
false;
231 std::string destconnect=m_session.connectionString();
233 m_logdb->logOperationNow(a,destconnect,payloadType,firstPayloadId,myrecord.m_tag,myrecord.timetypestr(),0,firstSinceTime);
237 std::string destconnect=m_session.connectionString();
239 m_logdb->logFailedOperationNow(a,destconnect,payloadType,firstPayloadId,myrecord.m_tag,myrecord.timetypestr(),0,firstSinceTime,
std::string(er.what()));
242 "PoolDBOutputService::createNewIOV");
253 std::lock_guard<std::recursive_mutex>
lock(m_mutex);
255 Record& myrecord=this->lookUpRecord(recordName);
256 if(!myrecord.m_isNewTag) {
257 cond::throwException( myrecord.m_tag +
" is not a new tag",
"PoolDBOutputService::createNewIOV");
260 if( withlogging && m_logConnectionString.empty() )
262 "PoolDBOutputService::createNewIOV");
270 editor.
insert( firstSinceTime, firstPayloadId );
272 myrecord.m_isNewTag=
false;
274 std::string destconnect=m_session.connectionString();
276 m_logdb->logOperationNow(a,destconnect,payloadType,firstPayloadId,myrecord.m_tag,myrecord.timetypestr(),0,firstSinceTime);
280 std::string destconnect=m_session.connectionString();
282 m_logdb->logFailedOperationNow(a,destconnect,payloadType,firstPayloadId,myrecord.m_tag,myrecord.timetypestr(),0,firstSinceTime,
std::string(er.what()));
285 "PoolDBOutputService::createNewIOV");
295 std::lock_guard<std::recursive_mutex>
lock(m_mutex);
297 Record& myrecord=this->lookUpRecord(recordName);
298 if( myrecord.m_isNewTag ) {
300 "PoolDBOutputService::appendSinceTime");
302 if( withlogging && m_logConnectionString.empty() )
304 "PoolDBOutputService::createNewIOV");
309 editor.
insert( time, payloadId );
313 std::string destconnect=m_session.connectionString();
315 m_logdb->logOperationNow(a,destconnect,payloadType,payloadId,myrecord.m_tag,myrecord.timetypestr(),0,
time);
319 std::string destconnect=m_session.connectionString();
321 m_logdb->logFailedOperationNow(a,destconnect,payloadType,payloadId,myrecord.m_tag,myrecord.timetypestr(),0,
time,
std::string(er.what()));
324 "PoolDBOutputService::appendSinceTime");
331 std::lock_guard<std::recursive_mutex>
lock(m_mutex);
332 if (!m_dbstarted) this->initDB(
false );
334 std::map<std::string,Record>::iterator it=m_callbacks.find(recordName);
335 if(it==m_callbacks.end()) {
336 cond::throwException(
"The record \""+recordName +
"\" has not been registered.",
"PoolDBOutputService::lookUpRecord");
338 if( !m_session.existsIov( it->second.m_tag) ){
339 it->second.m_isNewTag=
true;
341 it->second.m_isNewTag=
false;
349 std::map<std::string,cond::UserLogInfo>::iterator it=m_logheaders.find(recordName);
350 if(it==m_logheaders.end())
throw cond::Exception(
"Log db was not set for record " + recordName +
" from PoolDBOutputService::lookUpUserLogInfo");
357 std::lock_guard<std::recursive_mutex>
lock(m_mutex);
359 Record & myrecord = lookUpRecord(recordName);
364 "PoolDBOutputService::closeIOV");
384 if( !m_logdb.get() )
throw cond::Exception(
"Log database is not set from PoolDBOutputService::queryLog");
392 std::lock_guard<std::recursive_mutex>
lock(m_mutex);
static thread_local int s_streamIndex
const TimeTypeSpecs timeTypeSpecs[]
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
boost::uint64_t value() const
void closeIOV(Time_t lastTill, const std::string &recordName, bool withlogging=false)
void initDB(bool forReading=true)
void preEventProcessing(edm::StreamContext const &)
void fillRecord(edm::ParameterSet &pset)
std::map< std::string, cond::UserLogInfo > m_logheaders
cond::persistency::Session session() const
LuminosityBlockID const & luminosityBlockID() const
std::pair< Time_t, Time_t > ValidityInterval
void setDescription(const std::string &description)
void preGlobalBeginLumi(edm::GlobalContext const &)
void setParameters(const edm::ParameterSet &connectionPset)
std::string tag(const std::string &recordName)
unsigned int maxNumberOfStreams() const
cond::ValidityInterval lastInterval
void appendSinceTime(T *payloadObj, cond::Time_t sinceTime, const std::string &recordName, bool withlogging=false)
unsigned long long Time_t
vector< ParameterSet > Parameters
TimeType timeTypeFromName(const std::string &name)
bool isNewTagRequest(const std::string &recordName)
Record & lookUpRecord(const std::string &recordName)
cond::Time_t beginOfTime() const
void createNewIOV(T *firstPayloadObj, cond::Time_t firstSinceTime, cond::Time_t firstTillTime, const std::string &recordName, bool withlogging=false)
void setLogHeaderForRecord(const std::string &recordName, const std::string &provenance, const std::string &usertext)
StreamID const & streamID() const
void insert(cond::Time_t since, const cond::Hash &payloadHash, bool checkType=false)
unsigned int value() const
virtual ~PoolDBOutputService()
void throwException(std::string const &message, std::string const &methodName)
void tagInfo(const std::string &recordName, cond::TagInfo_t &result)
std::string lastPayloadToken
cond::Time_t endOfTime() const
void preGlobalBeginRun(edm::GlobalContext const &)
std::string m_logConnectionString
static constexpr BackendType DEFAULT_DB
cond::Time_t currentTime() const
void postModuleEvent(edm::StreamContext const &, edm::ModuleCallingContext const &)
void setEndOfValidity(cond::Time_t validity)
cond::TimeType m_timetype
std::map< std::string, Record > m_callbacks
void preModuleEvent(edm::StreamContext const &, edm::ModuleCallingContext const &)
std::string payloadType() const
std::string m_timetypestr
cond::UserLogInfo & lookUpUserLogInfo(const std::string &recordName)
TimeValue_t value() const
const cond::Logger & queryLog() const
PoolDBOutputService(const edm::ParameterSet &iConfig, edm::ActivityRegistry &iAR)
Timestamp const & timestamp() const