31 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseException.hh"
32 #include "xgi/Utils.h"
33 #include "toolbox/string.h"
37 using namespace oracle::occi;
58 std::cout <<
"===> WARNING! auth_path is specified as " << auth_path;
59 std::cout <<
" but is not used explicitely. Is it being used at all?" << std::endl;
66 session.
open(connect);
67 std::vector<std::string>
alltags;
92 std::cout <<
"===> WARNING! auth_path is specified as " << auth_path;
93 std::cout <<
" but is not used explicitely. Is it being used at all?" << std::endl;
100 session.
open(connect);
107 if(!metadata_svc.
hasTag(tag)){
113 unsigned int counter=0;
116 out.push_back(ioviterator->since());
132 std::vector<std::string>
alltags;
136 query +=
" channel_map_id,subdet,ieta,iphi,depth ";
138 query +=
" cms_hcl_hcal_cond.hcal_channels ";
140 query +=
" subdet='HB' or subdet='HE' or subdet='HF' or subdet='HO' ";
143 oracle::occi::Statement* stmt = conn.
getStatement(query);
152 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::
toolbox::toString(
"Oracle exception : %s",e.getMessage().c_str()));
169 query +=
" select iovs.interval_of_validity_begin as iov, ";
170 query +=
" min(iovs.record_insertion_time) time ";
171 query +=
" from cms_hcl_core_iov_mgmnt.cond_tags tags ";
172 query +=
" inner join cms_hcl_core_iov_mgmnt.cond_iov2tag_maps i2t ";
173 query +=
" on tags.cond_tag_id=i2t.cond_tag_id ";
174 query +=
" inner join cms_hcl_core_iov_mgmnt.cond_iovs iovs ";
175 query +=
" on i2t.cond_iov_record_id=iovs.cond_iov_record_id ";
177 query +=
" tags.tag_name=:1 ";
178 query +=
"group by iovs.interval_of_validity_begin ";
182 query +=
"order by time asc ";
185 oracle::occi::Statement* stmt = conn.
getStatement(query);
187 stmt->setString(1,tagname);
191 out.push_back(rs->getInt(1));
196 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,::
toolbox::toString(
"Oracle exception : %s",e.getMessage().c_str()));
204 std::vector<uint32_t> omds, orcon,
out;
206 orcon.push_back(100);
223 if (getListOfNewIovs(out, omds, orcon) == -1){
224 std::cout <<
"HcalO2OManager::getListOfNewIovs_test(): O2O is not possible" << std::endl;
226 else if (getListOfNewIovs(out, omds, orcon) == 0){
227 std::cout <<
"HcalO2OManager::getListOfNewIovs_test(): O2O is not needed, the tag is up to date" << std::endl;
230 std::cout <<
"HcalO2OManager::getListOfNewIovs_test(): O2O is possible" << std::endl;
231 std::cout <<
"HcalO2OManager::getListOfNewIovs_test(): " << out.size() <<
" IOVs to be copied to ORCON" << std::endl;
234 std::ostream_iterator<uint32_t>(
std::cout,
"\n")
241 const std::vector<uint32_t> & omds_iovs,
242 const std::vector<uint32_t> & orcon_iovs){
247 int _orcon_index_offset = 0;
248 if (omds_iovs.size() > 0 &&
249 orcon_iovs.size() > 0 &&
250 orcon_iovs[0] == 1 &&
252 std::cout << std::endl <<
"HcalO2OManager: First IOV in the OMDS tag is not 1," << std::endl;
253 std::cout <<
"HcalO2OManager: while it must be 1 in the offline tag." << std::endl;
254 std::cout <<
"HcalO2OManager: O2O will assume that IOV=1 in the offline tag" << std::endl;
255 std::cout <<
"HcalO2OManager: is filled with some safe default." << std::endl;
256 std::cout <<
"HcalO2OManager: IOV=1 will be ignored, and O2O will proceeed" << std::endl;
257 std::cout <<
"HcalO2OManager: as long as other inconsistencies are not detected." << std::endl << std::endl;
258 _orcon_index_offset = 1;
261 if (omds_iovs.size()+_orcon_index_offset < orcon_iovs.size()){
262 std::cout <<
"HcalO2OManager: too many IOVs in the Pool tag, cannot sync, exiting..." << std::endl;
267 unsigned int _index = 0;
269 bool enforce_strict_matching =
false;
271 for (std::vector<uint32_t>::const_iterator _iov = orcon_iovs.begin();
272 _iov != orcon_iovs.end();
274 _index = (int)(_iov - orcon_iovs.begin());
283 if (_orcon_index_offset == 1 && _index == 0)
continue;
296 if (omds_iovs[_index-_orcon_index_offset] != orcon_iovs[_index]){
299 std::cout <<
"HcalO2OManager: existing IOVs do not match, cannot sync in the strict sense." << std::endl;
300 std::cout <<
"HcalO2OManager: mismatched pair is (OMDS/offline): " << omds_iovs[_index-_orcon_index_offset] <<
"/" << orcon_iovs[_index] << std::endl;
301 std::cout <<
"HcalO2OManager: In the strict sense, the SYNCHRONIZATION OF THIS TAG HAS FAILED!" << std::endl;
302 std::cout <<
"HcalO2OManager: As an interim solution, I will still copy to the offline tag" << std::endl;
303 std::cout <<
"HcalO2OManager: those IOV from the OMDS tag that are newer than the last IOV" << std::endl;
304 std::cout <<
"HcalO2OManager: currently in the offline tag. " << std::endl;
308 if (enforce_strict_matching){
325 uint32_t _lastOrconIov = orcon_iovs[orcon_iovs.size()-1];
327 for (;_index < omds_iovs.size();++_index){
329 uint32_t _aIov = omds_iovs[_index];
331 if (_index == 0 && _aIov > _lastOrconIov){
332 iovs.push_back(_aIov);
335 else if (omds_iovs[_index]>omds_iovs[_index-1] &&
336 _aIov > _lastOrconIov){
337 iovs.push_back(omds_iovs[_index]);
341 if (enforce_strict_matching){
367 std::vector<uint32_t> omds_iovs;
368 std::vector<uint32_t> pool_iovs;
369 getListOfOmdsIovs(omds_iovs, _tag);
370 getListOfPoolIovs(pool_iovs, _tag, pool_connect_string, pool_auth_path);
371 int n_iovs = getListOfNewIovs(_iovs,
375 std::cout <<
"HcalO2OManager: O2O is not possible" << std::endl;
377 else if (n_iovs == 0){
378 std::cout <<
"HcalO2OManager: O2O is not needed, the tag is up to date" << std::endl;
381 edm::LogInfo(
"HcalO2OManager") <<
"These IOVs are to be updated:" << std::endl;
382 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
std::string toString(const std::pair< T, T > &aT)
DbSession createSession() const
oracle::occi::ResultSet ResultSet
void setAuthenticationPath(const std::string &p)
std::vector< std::string > getListOfOmdsTags()
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)