31 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseException.hh"
35 #include <toolbox/string.h>
40 using namespace oracle::occi;
61 std::cout <<
"===> WARNING! auth_path is specified as " << auth_path;
62 std::cout <<
" but is not used explicitely. Is it being used at all?" << std::endl;
69 session.
open(connect);
70 std::vector<std::string>
alltags;
95 std::cout <<
"===> WARNING! auth_path is specified as " << auth_path;
96 std::cout <<
" but is not used explicitely. Is it being used at all?" << std::endl;
103 session.
open(connect);
110 if(!metadata_svc.
hasTag(tag)){
119 out.push_back(ioviterator->since());
135 std::vector<std::string>
alltags;
139 query +=
" channel_map_id,subdet,ieta,iphi,depth ";
141 query +=
" cms_hcl_hcal_cond.hcal_channels ";
143 query +=
" subdet='HB' or subdet='HE' or subdet='HF' or subdet='HO' ";
146 oracle::occi::Statement* stmt = conn.
getStatement(query);
155 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::
toolbox::toString(
"Oracle exception : %s",e.getMessage().c_str()));
172 query +=
" select iovs.interval_of_validity_begin as iov, ";
173 query +=
" min(iovs.record_insertion_time) time ";
174 query +=
" from cms_hcl_core_iov_mgmnt.cond_tags tags ";
175 query +=
" inner join cms_hcl_core_iov_mgmnt.cond_iov2tag_maps i2t ";
176 query +=
" on tags.cond_tag_id=i2t.cond_tag_id ";
177 query +=
" inner join cms_hcl_core_iov_mgmnt.cond_iovs iovs ";
178 query +=
" on i2t.cond_iov_record_id=iovs.cond_iov_record_id ";
180 query +=
" tags.tag_name=:1 ";
181 query +=
"group by iovs.interval_of_validity_begin ";
185 query +=
"order by time asc ";
188 oracle::occi::Statement* stmt = conn.
getStatement(query);
190 stmt->setString(1,tagname);
194 out.push_back(rs->getInt(1));
199 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::
toolbox::toString(
"Oracle exception : %s",e.getMessage().c_str()));
207 std::vector<uint32_t> omds, orcon,
out;
209 orcon.push_back(100);
226 if (getListOfNewIovs(out, omds, orcon) == -1){
227 std::cout <<
"HcalO2OManager::getListOfNewIovs_test(): O2O is not possible" << std::endl;
229 else if (getListOfNewIovs(out, omds, orcon) == 0){
230 std::cout <<
"HcalO2OManager::getListOfNewIovs_test(): O2O is not needed, the tag is up to date" << std::endl;
233 std::cout <<
"HcalO2OManager::getListOfNewIovs_test(): O2O is possible" << std::endl;
234 std::cout <<
"HcalO2OManager::getListOfNewIovs_test(): " << out.size() <<
" IOVs to be copied to ORCON" << std::endl;
237 std::ostream_iterator<uint32_t>(
std::cout,
"\n")
244 const std::vector<uint32_t> & omds_iovs,
245 const std::vector<uint32_t> & orcon_iovs){
250 int _orcon_index_offset = 0;
251 if (omds_iovs.size() > 0 &&
252 orcon_iovs.size() > 0 &&
253 orcon_iovs[0] == 1 &&
255 std::cout << std::endl <<
"HcalO2OManager: First IOV in the OMDS tag is not 1," << std::endl;
256 std::cout <<
"HcalO2OManager: while it must be 1 in the offline tag." << std::endl;
257 std::cout <<
"HcalO2OManager: O2O will assume that IOV=1 in the offline tag" << std::endl;
258 std::cout <<
"HcalO2OManager: is filled with some safe default." << std::endl;
259 std::cout <<
"HcalO2OManager: IOV=1 will be ignored, and O2O will proceeed" << std::endl;
260 std::cout <<
"HcalO2OManager: as long as other inconsistencies are not detected." << std::endl << std::endl;
261 _orcon_index_offset = 1;
264 if (omds_iovs.size()+_orcon_index_offset < orcon_iovs.size()){
265 std::cout <<
"HcalO2OManager: too many IOVs in the Pool tag, cannot sync, exiting..." << std::endl;
270 unsigned int _index = 0;
272 bool enforce_strict_matching =
false;
274 for (std::vector<uint32_t>::const_iterator _iov = orcon_iovs.begin();
275 _iov != orcon_iovs.end();
277 _index = (int)(_iov - orcon_iovs.begin());
286 if (_orcon_index_offset == 1 && _index == 0)
continue;
299 if (omds_iovs[_index-_orcon_index_offset] != orcon_iovs[_index]){
302 std::cout <<
"HcalO2OManager: existing IOVs do not match, cannot sync in the strict sense." << std::endl;
303 std::cout <<
"HcalO2OManager: mismatched pair is (OMDS/offline): " << omds_iovs[_index-_orcon_index_offset] <<
"/" << orcon_iovs[_index] << std::endl;
304 std::cout <<
"HcalO2OManager: In the strict sense, the SYNCHRONIZATION OF THIS TAG HAS FAILED!" << std::endl;
305 std::cout <<
"HcalO2OManager: As an interim solution, I will still copy to the offline tag" << std::endl;
306 std::cout <<
"HcalO2OManager: those IOV from the OMDS tag that are newer than the last IOV" << std::endl;
307 std::cout <<
"HcalO2OManager: currently in the offline tag. " << std::endl;
311 if (enforce_strict_matching){
328 uint32_t _lastOrconIov = orcon_iovs[orcon_iovs.size()-1];
330 for (;_index < omds_iovs.size();++_index){
332 uint32_t _aIov = omds_iovs[_index];
334 if (_index == 0 && _aIov > _lastOrconIov){
335 iovs.push_back(_aIov);
338 else if (omds_iovs[_index]>omds_iovs[_index-1] &&
339 _aIov > _lastOrconIov){
340 iovs.push_back(omds_iovs[_index]);
344 if (enforce_strict_matching){
370 std::vector<uint32_t> omds_iovs;
371 std::vector<uint32_t> pool_iovs;
372 getListOfOmdsIovs(omds_iovs, _tag);
373 getListOfPoolIovs(pool_iovs, _tag, pool_connect_string, pool_auth_path);
374 int n_iovs = getListOfNewIovs(_iovs,
378 std::cout <<
"HcalO2OManager: O2O is not possible" << std::endl;
380 else if (n_iovs == 0){
381 std::cout <<
"HcalO2OManager: O2O is not needed, the tag is up to date" << std::endl;
384 edm::LogInfo(
"HcalO2OManager") <<
"These IOVs are to be updated:" << std::endl;
385 for (std::vector<uint32_t>::const_iterator
iov = _iovs.begin();
virtual char const * what() const
static PluginManager & configure(const Config &)
void open(const std::string &connectionString, bool readOnly=false)
DbConnectionConfiguration & configuration()
virtual ~HcalO2OManager()
const_iterator begin() const
oracle::occi::Statement * getStatement(const std::string &query)
const_iterator end() const
oracle::occi::SQLException SQLException
int getListOfNewIovs(std::vector< uint32_t > &iovs, const std::vector< uint32_t > &omds_iovs, const std::vector< uint32_t > &orcon_iovs)
PluginManager::Config config()
int getListOfUpdateIovs(std::vector< uint32_t > &_iovs, std::string _tag, std::string pool_connect_string, std::string pool_auth_path)
int start(bool readOnly=false)
start transaction
DbSession createSession() const
oracle::occi::ResultSet ResultSet
void setAuthenticationPath(const std::string &p)
std::vector< std::string > getListOfOmdsTags()
static std::atomic< unsigned int > counter
int getListOfPoolIovs(std::vector< uint32_t > &out, std::string tagname, std::string connect, std::string auth_path)
int getListOfOmdsIovs(std::vector< uint32_t > &out, std::string tagname)
std::vector< std::string > getListOfPoolTags(std::string connect, std::string auth_path)
int commit()
commit transaction. Will disconnect from database if connection timeout==0 or connectted time close t...
iov_range_iterator const_iterator
void getListOfNewIovs_test(void)