47 m_connectionString(
""),
49 m_logConnectionString(
""),
60 if( iConfig.
exists(
"outOfOrder") ){
70 connection.configure();
76 if( iConfig.
exists(
"logconnect") ){
82 typedef std::vector< edm::ParameterSet >
Parameters;
84 for(Parameters::iterator itToPut = toPut.begin(); itToPut != toPut.end(); ++itToPut)
102 return this->lookUpRecord(recordName).m_tag;
107 Record& myrecord=this->lookUpRecord(recordName);
114 m_session.transaction().start(
false);
123 if(!m_logConnectionString.empty()){
124 m_logdb->connect( m_logConnectionString );
125 m_logdb->createLogDBIfNonExist();
138 m_session.transaction().commit();
147 m_currentTime=iEvtid.
run();
149 m_currentTime=iTime.
value();
160 m_currentTime=iLumiid.
value();
184 return m_currentTime;
194 Record& myrecord=this->lookUpRecord(recordName);
195 if(!myrecord.m_isNewTag) {
196 throw cond::Exception(myrecord.m_tag +
" is not a new tag from PoolDBOutputService::createNewIOV");
200 if( m_logConnectionString.empty() ) {
201 throw cond::Exception(
"Log db was not set from PoolDBOutputService::createNewIOV");
207 unsigned int payloadIdx=0;
210 editor.
create(myrecord.m_timetype, firstTillTime);
211 objToken = payloadToken(m_session);
212 objClass = m_session.classNameForItem( objToken );
213 unsigned int payloadIdx=editor.
append(firstSinceTime, objToken);
214 iovToken=editor.
token();
220 metadata.
addMapping(myrecord.m_tag,iovToken,myrecord.m_timetype);
222 m_newtags.push_back( std::pair<std::string,std::string>(myrecord.m_tag,iovToken) );
223 myrecord.m_iovtoken=iovToken;
224 myrecord.m_isNewTag=
false;
226 std::string destconnect=m_session.connectionString();
228 m_logdb->logOperationNow(a,destconnect,objClass,objToken,myrecord.m_tag,myrecord.timetypestr(),payloadIdx,firstSinceTime);
232 std::string destconnect=m_session.connectionString();
234 m_logdb->logFailedOperationNow(a,destconnect,objClass,objToken,myrecord.m_tag,myrecord.timetypestr(),payloadIdx,firstSinceTime,
std::string(er.what()));
248 Record& myrecord=this->lookUpRecord(recordName);
250 if( m_logConnectionString.empty() ) {
251 throw cond::Exception(
"Log db was not set from PoolDBOutputService::add");
257 unsigned int payloadIdx=0;
260 objToken = payloadToken(m_session);
261 objClass = m_session.classNameForItem( objToken );
262 payloadIdx= appendIOV(m_session,myrecord,objToken,time);
264 std::string destconnect=m_session.connectionString();
266 m_logdb->logOperationNow(a,destconnect,objClass,objToken,myrecord.m_tag,myrecord.timetypestr(),payloadIdx,
time);
270 std::string destconnect=m_session.connectionString();
272 m_logdb->logFailedOperationNow(a,destconnect,objClass,objToken,myrecord.m_tag,myrecord.timetypestr(),payloadIdx,
time,
std::string(er.what()));
281 if (!m_dbstarted) this->initDB(
false );
283 std::map<std::string,Record>::iterator it=m_callbacks.find(recordName);
284 if(it==m_callbacks.end()) {
288 if( !metadata.
hasTag(it->second.m_tag) ){
289 it->second.m_iovtoken=
"";
290 it->second.m_isNewTag=
true;
292 it->second.m_iovtoken=metadata.
getToken(it->second.m_tag);
293 it->second.m_isNewTag=
false;
300 std::map<std::string,cond::UserLogInfo>::iterator it=m_logheaders.find(recordName);
301 if(it==m_logheaders.end())
throw cond::Exception(
"Log db was not set for record " + recordName +
" from PoolDBOutputService::lookUpUserLogInfo");
320 editor.
append(sinceTime,payloadToken);
356 if( !m_logdb.get() )
throw cond::Exception(
"Log database is not set from PoolDBOutputService::queryLog");
const TimeTypeSpecs timeTypeSpecs[]
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::string create(cond::TimeType timetype)
void closeIOV(Time_t lastTill, const std::string &recordName, bool withlogging=false)
void initDB(bool forReading=true)
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
void open(const std::string &connectionString, bool readOnly=false)
void fillRecord(edm::ParameterSet &pset)
std::map< std::string, cond::UserLogInfo > m_logheaders
void watchPostModule(PostModule::slot_type const &iSlot)
void watchPreProcessEvent(PreProcessEvent::slot_type const &iSlot)
DbConnectionConfiguration & configuration()
boost::uint64_t value() const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::string const & token() const
std::pair< Time_t, Time_t > ValidityInterval
void add(GetToken const &token, cond::Time_t time, const std::string &recordName, bool withlogging=false)
cond::Time_t till() const
void preBeginLumi(const edm::LuminosityBlockID &, const edm::Timestamp &)
const_iterator end() const
void setScope(cond::IOVSequence::ScopeType scope)
set the scope
std::string lastPayloadToken
unsigned int freeInsert(cond::Time_t sinceTime, const std::string &payloadToken)
insert a payload with known since in any position
void watchPreModule(PreModule::slot_type const &iSlot)
void setParameters(const edm::ParameterSet &connectionPset)
std::string tag(const std::string &recordName)
unsigned long long Time_t
vector< ParameterSet > Parameters
bool isNewTagRequest(const std::string &recordName)
Record & lookUpRecord(const std::string &recordName)
cond::DbSession session() const
std::string const & token() const
cond::Time_t beginOfTime() const
static const std::string COND_WRITER_ROLE
std::string m_connectionString
cond::TimeType m_timetype
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)
void tagInfo(const std::string &recordName, cond::TagInfo &result)
TimeValue_t value() const
void postModule(const edm::ModuleDescription &desc)
virtual ~PoolDBOutputService()
void updateClosure(cond::Time_t newtillTime)
Update the closure of the iov sequence.
unsigned int append(cond::Time_t sinceTime, const std::string &payloadToken)
void preModule(const edm::ModuleDescription &desc)
cond::Time_t endOfTime() const
cond::Time_t since() const
static std::string container()
std::string m_logConnectionString
cond::ValidityInterval lastInterval
cond::Time_t currentTime() const
void stamp(std::string const &icomment, bool append=false)
void watchPreBeginLumi(PreBeginLumi::slot_type const &iSlot)
const TimeTypeSpecs & findSpecs(std::string const &name)
cond::TimeType m_timetype
std::map< std::string, Record > m_callbacks
bool createIOVContainer()
create iov tables
cond::DbSession m_session
void preEventProcessing(const edm::EventID &evtID, const edm::Timestamp &iTime)
std::string m_timetypestr
cond::UserLogInfo & lookUpUserLogInfo(const std::string &recordName)
const cond::Logger & queryLog() const
PoolDBOutputService(const edm::ParameterSet &iConfig, edm::ActivityRegistry &iAR)
std::auto_ptr< cond::Logger > m_logdb
unsigned int appendIOV(cond::DbSession &, Record &record, const std::string &payloadToken, cond::Time_t sinceTime)