CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Namespaces | Classes | Enumerations | Functions
cond::persistency Namespace Reference

Namespaces

 COND_LOG_TABLE
 
 GLOBAL_TAG
 
 GLOBAL_TAG_MAP
 
 IOV
 
 PAYLOAD
 
 PAYLOAD_MIGRATION
 
 TAG
 
 TAG_MIGRATION
 

Classes

struct  AttributeTypeName
 
struct  AttributeTypeName< boost::posix_time::ptime >
 
struct  AttributeTypeName< cond::Binary >
 
struct  AttributeTypeName< cond::SynchronizationType >
 
struct  AttributeTypeName< cond::TimeType >
 
class  BasePayloadProxy
 
class  BulkInserter
 
class  CondDBTransaction
 
class  CondGetter
 
class  ConnectionPool
 
struct  DefineQueryOutput
 
struct  DefineQueryOutput< boost::posix_time::ptime >
 
struct  DefineQueryOutput< cond::Binary >
 
struct  DefineQueryOutput< cond::SynchronizationType >
 
struct  DefineQueryOutput< cond::TimeType >
 
struct  DefineQueryOutput< std::array< char, n > >
 
class  DeleteBuffer
 
class  Exception
 Base exception class for the object to relational access. More...
 
struct  GetFromRow
 
struct  GetFromRow< boost::posix_time::ptime >
 
struct  GetFromRow< cond::Binary >
 
struct  GetFromRow< cond::SynchronizationType >
 
struct  GetFromRow< cond::TimeType >
 
struct  GetFromRow< std::array< char, n > >
 
class  GTEditor
 
class  GTEditorData
 
class  GTProxy
 
class  GTProxyData
 
class  GTSchema
 
class  IGTMapTable
 
class  IGTSchema
 
class  IGTTable
 
class  IIOVSchema
 
class  IIOVTable
 
class  IOVCache
 
struct  IOVComp
 
class  IOVEditor
 
class  IOVEditorData
 
class  IOVProxy
 
class  IOVProxyData
 
class  IOVSchema
 
class  IPayloadMigrationTable
 
class  IPayloadTable
 
class  ITagMigrationTable
 
class  ITagTable
 
class  ITransaction
 
class  KeyList
 
class  OraGTMapTable
 
class  OraGTSchema
 
class  OraGTTable
 
class  OraIOVSchema
 
class  OraIOVTable
 
class  OraPayloadTable
 
class  OraTagTable
 
class  OraTransaction
 
class  PayloadProxy
 
class  PayloadProxy< cond::persistency::KeyList >
 
class  Query
 
class  QueryIterator
 
class  RowBuffer
 
class  Session
 
class  SessionImpl
 
class  TableDescription
 
class  Transaction
 
class  TransactionScope
 
class  UpdateBuffer
 

Enumerations

enum  DbAuthenticationSystem { UndefinedAuthentication =0, CondDbKey, CoralXMLFile }
 
enum  UpdatePolicy { NEW =0, UPDATE, REPLACE }
 

Functions

BackendType checkBackendType (boost::shared_ptr< coral::ISessionProxy > &coralSession, const std::string &connectionString)
 
bool compareTags (const std::string &firstTag, Session &firstSession, const std::string &firstFileName, const std::string &secondTag, Session &secondSession, const std::string &secondFileName)
 
std::string convertoToOracleConnection (const std::string &input)
 
bool copyIov (Session &session, const std::string &sourceTag, const std::string &destTag, cond::Time_t souceSince, cond::Time_t destSince, const std::string &description, bool log)
 
size_t copyTag (const std::string &sourceTag, Session &sourceSession, const std::string &destTag, Session &destSession, UpdatePolicy policy, bool log, bool forValidation)
 
unsigned int countslash (const std::string &input)
 
static const boost::regex duplicate ("duplicateIOV[[:print:]]+?[S|s]ince[=| ]([[:alnum:]]+?);.*")
 
static const boost::regex exportIOV ("exportIOV[[:print:]]+?;since=([[:alnum:]]+?),[[:print:]]+?; *copied=([[:alnum:]]+?);.*")
 
size_t exportTagToFile (const std::string &tag, const std::string &destTag, Session &session, const std::string fileName)
 
template<typename T >
void f_add_column_description (coral::TableDescription &table, const std::string &columnName, size_t size=0, bool notNull=true)
 
std::pair< std::string,
boost::shared_ptr< void > > 
fetch (const cond::Hash &payloadId, Session &session)
 
std::pair< std::string,
boost::shared_ptr< void > > 
fetchIfExists (const cond::Hash &payloadId, Session &session, bool &exists)
 
std::pair< std::string,
boost::shared_ptr< void > > 
fetchOne (const std::string &payloadTypeName, const cond::Binary &data, const cond::Binary &streamerInfo, boost::shared_ptr< void > payloadPtr, bool is Ora)
 
std::pair< std::string,
boost::shared_ptr< void > > 
fetchOne (const std::string &payloadTypeName, const cond::Binary &data, const cond::Binary &streamerInfo, boost::shared_ptr< void > payloadPtr, bool isOra)
 
std::pair< std::string,
std::string > 
getConnectionParams (const std::string &connectionString, const std::string &transactionId)
 
std::string getConnectionProtocol (const std::string &connectionString)
 
bool getInsertionLogs (const std::string &tag, cond::DbSession &logDbSession, std::vector< std::pair< cond::Time_t, boost::posix_time::ptime > > &loggedInsertions)
 
cond::Hash import (Session &source, const cond::Hash &sourcePayloadId, const std::string &inputTypeName, const void *inputPtr, Session &destination)
 
size_t importIovs (const std::string &sourceTag, Session &sourceSession, const std::string &destTag, Session &destSession, cond::Time_t begin, cond::Time_t end, const std::string &description, bool log)
 
template<typename T , typename Arg1 >
bool is_same_any ()
 
template<typename T , typename Arg1 , typename Arg2 , typename... Args>
bool is_same_any ()
 
cond::Hash makeHash (const std::string &objectType, const cond::Binary &data)
 
size_t migrateTag (const std::string &sourceTag, Session &sourceSession, const std::string &destTag, Session &destSession, UpdatePolicy policy, cond::DbSession &logDbSession)
 
static const std::string ORA_IOV_TABLE_1 ("ORA_C_COND_IOVSEQUENCE")
 
static const std::string ORA_IOV_TABLE_2 ("ORA_C_COND_IOVSEQU_A0")
 
static const std::string ORA_IOV_TABLE_3 ("ORA_C_COND_IOVSEQU_A1")
 
std::tuple< std::string,
std::string, std::string > 
parseConnectionString (const std::string &connectionString)
 
std::pair< std::string,
std::string > 
parseTag (const std::string &tag)
 
static const std::string POOL_IOV_TABLE_DATA ("IOV_DATA")
 
static const boost::regex popcon_many ("PopCon[[:print:]]+?first payload Since ([[:alnum:]]+?),.*")
 
static const boost::regex popcon_one ("PopCon[[:print:]]+?;Since ([[:alnum:]]+?);.*")
 
template<typename T >
std::vector< T >::const_iterator search (const cond::Time_t &val, const std::vector< T > &container)
 
template<typename T , typename P >
void static_assert_is_same_decayed ()
 
void throwException (const std::string &message, const std::string &methodName)
 
static const std::string time_0 ("2008-01-01 00:00:42.000")
 
bool validateTag (const std::string &refTag, Session &refSession, const std::string &candTag, Session &candSession)
 

Enumeration Type Documentation

Enumerator
UndefinedAuthentication 
CondDbKey 
CoralXMLFile 

Definition at line 28 of file ConnectionPool.h.

Enumerator
NEW 
UPDATE 
REPLACE 

Definition at line 15 of file CondDBTools.h.

Function Documentation

BackendType cond::persistency::checkBackendType ( boost::shared_ptr< coral::ISessionProxy > &  coralSession,
const std::string &  connectionString 
)

Definition at line 63 of file SessionImpl.cc.

References cond::DbTransaction::commit(), cond::COND_DB, cond::DbSession::open(), cond::ORA_DB, run_regression::ret, cond::DbTransaction::start(), cond::DbSession::transaction(), and cond::UNKNOWN_DB.

Referenced by cond::persistency::ConnectionPool::createSession().

64  {
66  cond::DbSession oraSession;
67  oraSession.open( coralSession, connectionString );
68  oraSession.transaction().start( true );
69  std::unique_ptr<IIOVSchema> iovSchemaHandle( new OraIOVSchema( oraSession ) );
70  std::unique_ptr<IGTSchema> gtSchemaHandle( new OraGTSchema( oraSession ) );
71  if( !iovSchemaHandle->exists() && !gtSchemaHandle->exists() ){
72  iovSchemaHandle.reset( new IOVSchema( coralSession->nominalSchema() ) );
73  if( iovSchemaHandle->exists() ){
74  ret = COND_DB;
75  }
76  } else {
77  // edm::LogWarning("CondDB") << "You are using conditions from the old database via: "
78  // << connectionString
79  // << std::endl;
80  ret = ORA_DB;
81  }
82  oraSession.transaction().commit();
83  return ret;
84  }
DbTransaction & transaction()
Definition: DbSession.cc:208
void open(const std::string &connectionString, bool readOnly=false)
Definition: DbSession.cc:159
int commit()
commit transaction.
int start(bool readOnly=false)
start transaction
BackendType
Definition: Types.h:23
bool cond::persistency::compareTags ( const std::string &  firstTag,
Session firstSession,
const std::string &  firstFileName,
const std::string &  secondTag,
Session secondSession,
const std::string &  secondFileName 
)

Definition at line 385 of file CondDBTools.cc.

References cond::persistency::Session::connectionString(), gather_cfg::cout, exportTagToFile(), timingPdfMaker::file1, N, NULL, cmsHarvester::path, diffTwoXMLs::r1, diffTwoXMLs::r2, python.multivaluedict::remove(), and throwException().

Referenced by validateTag().

390  {
391  size_t n1 = exportTagToFile( firstTag, firstTag, firstSession, firstFileName );
392  if( ! n1 ){
393  std::cout <<"Can't compare empty tag "<<firstTag<<std::endl;
394  return false;
395  }
396  size_t n2 = exportTagToFile( secondTag, firstTag, secondSession, secondFileName );
397  if( ! n2 ){
398  std::cout <<"Can't compare empty tag "<<secondTag<<std::endl;
399  return false;
400  }
401  if( n1 != n2 ) {
402  std::cout <<" Tag size is different. "<<firstSession.connectionString()<<":"<<firstTag<<": "<<n1<<" "<<
403  secondSession.connectionString()<<":"<<secondTag<<": "<<n2<<std::endl;
404  }
405 
406  FILE* file1 = fopen( firstFileName.c_str(), "r" );
407  if( file1 == NULL ){
408  throwException("Can't open file "+firstFileName, "compareTags" );
409  }
410  FILE* file2 = fopen( secondFileName.c_str(), "r" );
411  if( file2 == NULL ){
412  throwException("Can't open file "+secondFileName, "compareTags" );
413  }
414  int N = 10000;
415  char buf1[N];
416  char buf2[N];
417 
418  bool cmpOk = true;
419  size_t totSize = 0;
420  do {
421  size_t r1 = fread( buf1, 1, N, file1 );
422  size_t r2 = fread( buf2, 1, N, file2 );
423 
424  if( r1 != r2 || memcmp( buf1, buf2, r1)) {
425  cmpOk = false;
426  break;
427  }
428  totSize += r1;
429  } while(!feof(file2) || !feof(file2));
430 
431  std::cout <<" "<<totSize<<" bytes compared."<<std::endl;
432  fclose( file1 );
433  fclose( file2 );
434 
435  if( cmpOk ){
436  boost::filesystem::path fp1( firstFileName );
438  boost::filesystem::path fp2( secondFileName );
440  }
441 
442  return cmpOk;
443  }
#define NULL
Definition: scimark2.h:8
tuple path
else: Piece not in the list, fine.
size_t exportTagToFile(const std::string &tag, const std::string &destTag, Session &session, const std::string fileName)
Definition: CondDBTools.cc:378
#define N
Definition: blowfish.cc:9
tuple cout
Definition: gather_cfg.py:121
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
std::string cond::persistency::convertoToOracleConnection ( const std::string &  input)
inline

Definition at line 66 of file Utils.h.

References dbtoconf::account, match(), fff_monitoring::service, AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

66  {
67 
68  //static const boost::regex trivial("oracle://(cms_orcon_adg|cms_orcoff_prep)/([_[:alnum:]]+?)");
69  static const boost::regex short_frontier("frontier://([[:alnum:]]+?)/([_[:alnum:]]+?)");
70  static const boost::regex long_frontier("frontier://((\\([-[:alnum:]]+?=[^\\)]+?\\))+)/([_[:alnum:]]+?)");
71  static const boost::regex long_frontier_serverurl("\\(serverurl=[^\\)]+?/([[:alnum:]]+?)\\)");
72 
73  static const std::map<std::string, std::string> frontierMap = {
74  {"PromptProd", "cms_orcon_adg"},
75  {"FrontierProd", "cms_orcon_adg"},
76  {"FrontierArc", "cms_orcon_adg"},
77  {"FrontierOnProd", "cms_orcon_adg"},
78  {"FrontierPrep", "cms_orcoff_prep"},
79  };
80 
81  boost::smatch matches;
82 
83  static const std::string technology("oracle://");
84  std::string service("");
85  std::string account("");
86 
87  bool match = false;
88  if (boost::regex_match(input, matches, short_frontier)){
89  service = matches[1];
90  account = matches[2];
91  match = true;
92  }
93 
94  if (boost::regex_match(input, matches, long_frontier)) {
95  std::string frontier_config(matches[1]);
96  boost::smatch matches2;
97  if (not boost::regex_search(frontier_config, matches2, long_frontier_serverurl))
98  throwException("No serverurl in matched long frontier","convertoToOracleConnection");
99  service = matches2[1];
100  account = matches[3];
101  match = true;
102  }
103 
104  if( !match ) throwException("Connection string can't be converted.","convertoToOracleConnection");
105 
106  if( service == "FrontierArc" ){
107  size_t len = account.size()-5;
108  account = account.substr(0,len);
109  }
110 
111  auto it = frontierMap.find( service );
112  if( it == frontierMap.end() ) throwException("Connection string can't be converted.","convertoToOracleConnection");
113  service = it->second;
114 
115  return technology+service+"/"+account;
116  }
list account
Definition: dbtoconf.py:80
static std::string const input
Definition: EdmProvDump.cc:44
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
bool cond::persistency::copyIov ( Session session,
const std::string &  sourceTag,
const std::string &  destTag,
cond::Time_t  souceSince,
cond::Time_t  destSince,
const std::string &  description,
bool  log 
)

Definition at line 333 of file CondDBTools.cc.

References gather_cfg::cout, cond::persistency::Session::createIov(), cond::persistency::Session::editIov(), idDealer::editor, cond::persistency::IOVProxy::end(), cond::persistency::Session::existsIov(), cond::persistency::IOVProxy::find(), cond::persistency::IOVEditor::flush(), cond::persistency::IOVEditor::insert(), cond::persistency::IOVProxy::loadedSize(), AlCaHLTBitMon_ParallelJobs::p, cond::persistency::IOVProxy::payloadObjectType(), cond::persistency::IOVEditor::payloadType(), cond::persistency::Session::readIov(), cond::persistency::IOVEditor::setDescription(), cond::persistency::TransactionScope::start(), cond::persistency::IOVProxy::synchronizationType(), throwException(), cond::persistency::IOVEditor::timeType(), cond::persistency::IOVProxy::timeType(), and cond::persistency::Session::transaction().

339  {
340  persistency::TransactionScope ssc( session.transaction() );
341  ssc.start( false );
342  if( log ) std::cout <<" Loading source iov..."<<std::endl;
343  persistency::IOVProxy p = session.readIov( sourceTag, true );
344  if( p.loadedSize()==0 ) {
345  if( log ) std::cout <<" Tag contains 0 iovs."<<std::endl;
346  return false;
347  } else {
348  if( log ) std::cout <<" Iov size:"<<p.loadedSize()<<" timeType:"<<p.timeType()<<" payloadObjectType=\""<<p.payloadObjectType()<<"\""<<std::endl;
349  }
350 
351  auto iiov = p.find( sourceSince );
352  if( iiov == p.end() ){
353  if( log ) std::cout <<"ERROR: No Iov valid found for target time "<<sourceSince<<std::endl;
354  return false;
355  }
356 
357  persistency::IOVEditor editor;
358  if( session.existsIov( destTag ) ){
359  editor = session.editIov( destTag );
360  if( editor.timeType() != p.timeType() )
361  throwException( "TimeType of the destination tag does not match with the source tag timeType.", "importIovs");
362  if( editor.payloadType() != p.payloadObjectType() )
363  throwException( "PayloadType of the destination tag does not match with the source tag payloadType.", "importIovs");
364  } else {
365  editor = session.createIov( p.payloadObjectType(), destTag, p.timeType(), p.synchronizationType() );
366  if( description.empty() ) editor.setDescription( "Created copying iovs from tag "+sourceTag );
367  else editor.setDescription( description );
368  }
369 
370  editor.insert( destSince, (*iiov).payloadId );
371 
372  if( log ) std::cout <<" Flushing changes..."<<std::endl;
373  editor.flush();
374  ssc.commit();
375  return true;
376  }
tuple description
Definition: idDealer.py:66
tuple editor
Definition: idDealer.py:73
tuple cout
Definition: gather_cfg.py:121
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
size_t cond::persistency::copyTag ( const std::string &  sourceTag,
Session sourceSession,
const std::string &  destTag,
Session destSession,
UpdatePolicy  policy,
bool  log,
bool  forValidation 
)

Definition at line 29 of file CondDBTools.cc.

References cond::persistency::Session::clearIov(), cond::persistency::Session::connectionString(), gather_cfg::cout, cond::persistency::Session::createDatabase(), cond::persistency::Session::createIov(), cond::persistency::Session::editIov(), idDealer::editor, cond::persistency::Session::existsDatabase(), cond::persistency::Session::existsIov(), fetch(), cond::persistency::IOVEditor::flush(), cond::persistency::IOVEditor::insert(), o2o::iov, cond::persistency::IOVProxy::loadedSize(), NEW, AlCaHLTBitMon_ParallelJobs::p, cond::persistency::IOVProxy::payloadObjectType(), cond::persistency::Session::readIov(), REPLACE, cond::persistency::Transaction::rollback(), cond::persistency::IOVEditor::setDescription(), cond::persistency::IOVEditor::setValidationMode(), EcalCondDB::sinces, cond::persistency::TransactionScope::start(), cond::persistency::IOVProxy::synchronizationType(), throwException(), cond::persistency::IOVProxy::timeType(), and cond::persistency::Session::transaction().

Referenced by exportTagToFile().

35  {
36  persistency::TransactionScope ssc( sourceSession.transaction() );
37  ssc.start();
38  if( log && !forValidation ) std::cout <<" Loading source iov..."<<std::endl;
39  persistency::IOVProxy p = sourceSession.readIov( sourceTag, true );
40  if( p.loadedSize()==0 ) {
41  if( log ) std::cout <<" Tag contains 0 iovs."<<std::endl;
42  return 0;
43  }
44  if( log && !forValidation ) std::cout <<" Copying tag. Iov size:"<<p.loadedSize()<<" timeType:"<<p.timeType()<<" payloadObjectType=\""<<p.payloadObjectType()<<"\""<<std::endl;
45 
46  persistency::IOVEditor editor;
47  persistency::TransactionScope dsc( destSession.transaction() );
48  dsc.start( false );
49  bool exists = false;
50  if( !destSession.existsDatabase() ) {
51  destSession.createDatabase();
52  } else {
53  exists = destSession.existsIov( destTag );
54  }
55  if( exists ){
56  if( policy == REPLACE ){
57  destSession.clearIov( destTag );
58  } else if( policy == NEW ){
59  destSession.transaction().rollback();
60  throwException(" Tag \""+destTag+"\" already exists.","copyTag");
61  }
62  editor = destSession.editIov( destTag );
63  } else {
64  editor = destSession.createIov( p.payloadObjectType(), destTag, p.timeType(), p.synchronizationType() );
65  }
66  if( forValidation ) {
67  editor.setValidationMode();
68  editor.setDescription("Validation");
69  } else {
70  editor.setDescription("Tag "+sourceTag+" migrated from "+sourceSession.connectionString());
71  }
72  size_t niovs = 0;
73  std::set<cond::Hash> pids;
74  std::set<cond::Time_t> sinces;
75  for( auto iov : p ){
76  // skip duplicated sinces
77  if( sinces.find( iov.since ) != sinces.end() ){
78  if( log && !forValidation ) std::cout <<" WARNING. Skipping duplicated since="<<iov.since<<std::endl;
79  continue;
80  }
81  sinces.insert( iov.since );
82  // make sure that we import the payload _IN_USE_
83  auto usedIov = p.getInterval( iov.since );
84  std::pair<std::string,boost::shared_ptr<void> > readBackPayload = fetch( usedIov.payloadId, sourceSession );
85  cond::Hash ph = import( sourceSession, usedIov.payloadId, readBackPayload.first, readBackPayload.second.get(), destSession );
86  editor.insert( iov.since, ph );
87  pids.insert( ph );
88  niovs++;
89  if( log && !forValidation && niovs && (niovs%1000==0) ) std::cout <<" Total of iov inserted: "<<niovs<<" payloads: "<<pids.size()<<std::endl;
90  }
91  if( log && !forValidation) std::cout <<" Total of iov inserted: "<<niovs<<" payloads: "<<pids.size()<<std::endl;
92  if( log && !forValidation) std::cout <<" Flushing changes..."<<std::endl;
93  editor.flush();
94  dsc.commit();
95  ssc.commit();
96  return niovs;
97  }
list sinces
Definition: EcalCondDB.py:80
tuple iov
Definition: o2o.py:307
std::string Hash
Definition: Types.h:43
std::pair< std::string, boost::shared_ptr< void > > fetch(const cond::Hash &payloadId, Session &session)
tuple editor
Definition: idDealer.py:73
tuple cout
Definition: gather_cfg.py:121
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
unsigned int cond::persistency::countslash ( const std::string &  input)

Definition at line 15 of file DbConnectionString.cc.

References prof2calltree::count.

Referenced by getConnectionParams().

15  {
16  unsigned int count=0;
17  std::string::size_type slashpos( 0 );
18  while( slashpos!=std::string::npos){
19  slashpos = input.find('/', slashpos );
20  if ( slashpos != std::string::npos ){
21  ++count;
22  // start next search after this word
23  slashpos += 1;
24  }
25  }
26  return count;
27  }
uint16_t size_type
static std::string const input
Definition: EdmProvDump.cc:44
static const boost::regex cond::persistency::duplicate ( "duplicateIOV]+?ince([[:alnum:]]+?);.*"  [[:print:][S|s][=|])
static
static const boost::regex cond::persistency::exportIOV ( "exportIOV]+?;  since[[:print:] = ([[:alnum:]]+?))
static

Referenced by getInsertionLogs().

size_t cond::persistency::exportTagToFile ( const std::string &  tag,
const std::string &  destTag,
Session session,
const std::string  fileName 
)

Definition at line 378 of file CondDBTools.cc.

References copyTag(), cond::persistency::ConnectionPool::createSession(), NEW, and run_regression::ret.

Referenced by compareTags().

378  {
379  ConnectionPool localPool;
380  Session writeSession = localPool.createSession( "sqlite:"+fileName, true );
381  size_t ret = copyTag( tag, session, destTag, writeSession, NEW, false,true );
382  return ret;
383  }
size_t copyTag(const std::string &sourceTag, Session &sourceSession, const std::string &destTag, Session &destSession, UpdatePolicy policy, bool log, bool forValidation)
Definition: CondDBTools.cc:29
template<typename T >
void cond::persistency::f_add_column_description ( coral::TableDescription &  table,
const std::string &  columnName,
size_t  size = 0,
bool  notNull = true 
)

Definition at line 205 of file DbCore.h.

References findQualityFiles::size.

205  {
206  table.insertColumn( columnName, AttributeTypeName<T>()(), size );
207  if( notNull ) table.setNotNullConstraint( columnName );
208  }
#define table(NAME)
Definition: DbCore.h:49
tuple size
Write out results.
std::pair< std::string, boost::shared_ptr< void > > cond::persistency::fetch ( const cond::Hash payloadId,
Session session 
)

Definition at line 340 of file CondDBImport.cc.

References data, fetchOne(), cond::persistency::Session::fetchPayloadData(), newFWLiteAna::found, cond::persistency::Session::isOraSession(), AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

Referenced by copyTag(), LMFDat::fetch(), importIovs(), and migrateTag().

340  {
341  boost::shared_ptr<void> payloadPtr;
343  cond::Binary streamerInfo;
344  std::string payloadTypeName;
345  bool found = session.fetchPayloadData( payloadId, payloadTypeName, data, streamerInfo );
346  if( !found ) throwException( "Payload with id "+boost::lexical_cast<std::string>(payloadId)+" has not been found in the database.","fetchAndCompare" );
347  //std::cout <<"--> payload type "<<payloadTypeName<<" has blob size "<<data.size()<<std::endl;
348  bool isOra = session.isOraSession();
349  return fetchOne(payloadTypeName, data, streamerInfo, payloadPtr, isOra);
350  }
std::pair< std::string, boost::shared_ptr< void > > fetchOne(const std::string &payloadTypeName, const cond::Binary &data, const cond::Binary &streamerInfo, boost::shared_ptr< void > payloadPtr, bool is Ora)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
std::pair<std::string,boost::shared_ptr<void> > cond::persistency::fetchIfExists ( const cond::Hash payloadId,
Session session,
bool &  exists 
)

Definition at line 45 of file CondDBImport.cc.

References data, fetchOne(), cond::persistency::Session::fetchPayloadData(), cond::persistency::Session::isOraSession(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by import().

45  {
46  boost::shared_ptr<void> payloadPtr;
48  cond::Binary streamerInfo;
49  std::string payloadTypeName;
50  exists = session.fetchPayloadData( payloadId, payloadTypeName, data, streamerInfo );
51  if( exists ) {
52  bool isOra = session.isOraSession();
53  return fetchOne(payloadTypeName, data, streamerInfo, payloadPtr, isOra);
54  } else return std::make_pair( std::string(""), boost::shared_ptr<void>() );
55  }
std::pair< std::string, boost::shared_ptr< void > > fetchOne(const std::string &payloadTypeName, const cond::Binary &data, const cond::Binary &streamerInfo, boost::shared_ptr< void > payloadPtr, bool is Ora)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::pair<std::string, boost::shared_ptr<void> > cond::persistency::fetchOne ( const std::string &  payloadTypeName,
const cond::Binary data,
const cond::Binary streamerInfo,
boost::shared_ptr< void >  payloadPtr,
bool is  Ora 
)

Referenced by fetch(), and fetchIfExists().

std::pair<std::string, boost::shared_ptr<void> > cond::persistency::fetchOne ( const std::string &  payloadTypeName,
const cond::Binary data,
const cond::Binary streamerInfo,
boost::shared_ptr< void >  payloadPtr,
bool  isOra 
)

Definition at line 351 of file CondDBImport.cc.

References data, FETCH_PAYLOAD_CASE, match(), AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

351  {
352 
353  bool match = false;
355  FETCH_PAYLOAD_CASE( std::vector<unsigned long long> )
518  FETCH_PAYLOAD_CASE( lumi::LumiSectionData )
521  FETCH_PAYLOAD_CASE( PhysicsTools::Calibration::MVAComputerContainer )
525  //FETCH_PAYLOAD_CASE( PerformancePayload )
568  FETCH_PAYLOAD_CASE( cond::BaseKeyed )
577 
578  //
579  if( payloadTypeName == "PhysicsTools::Calibration::Histogram3D<double,double,double,double>" ){
580  auto payload = deserialize<PhysicsTools::Calibration::Histogram3D<double,double,double,double> >(payloadTypeName, data, streamerInfo, isOra );
581  payloadPtr = payload;
582  match = true;
583  }
584  if( payloadTypeName == "PhysicsTools::Calibration::Histogram2D<double,double,double>" ){
585  auto payload = deserialize<PhysicsTools::Calibration::Histogram2D<double,double,double> >(payloadTypeName, data, streamerInfo, isOra );
586  payloadPtr = payload;
587  match = true;
588  }
589  if( payloadTypeName == "std::vector<unsignedlonglong,std::allocator<unsignedlonglong>>" ){
590  auto payload = deserialize<std::vector<unsigned long long> >( payloadTypeName, data, streamerInfo, isOra );
591  payloadPtr = payload;
592  match = true;
593  }
594 
595  if( ! match ) throwException( "Payload type \""+payloadTypeName+"\" is unknown.","fetch" );
596  return std::make_pair( payloadTypeName, payloadPtr );
597  }
Definition: ESGain.h:7
tuple lumi
Definition: fjr2json.py:35
#define FETCH_PAYLOAD_CASE(TYPENAME)
Definition: CondDBImport.cc:19
Definition: DTT0.h:53
Histogram3D< double > HistogramD3D
Definition: Histogram3D.h:187
QGLikelihoodObject containing valid range and entries with category, histogram and mean...
Category structure: ranges associated with QGLikelihood histograms.
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
QGLikelihoodSystematicsObject containing the parameters for the systematic smearing.
if(conf.exists("allCellsPositionCalc"))
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
std::pair< std::string, std::string > cond::persistency::getConnectionParams ( const std::string &  connectionString,
const std::string &  transactionId 
)

Definition at line 29 of file DbConnectionString.cc.

References countslash(), getConnectionProtocol(), cond::FipProtocolParser::getRealConnect(), edm::Service< T >::isAvailable(), prof2calltree::l, edm::SiteLocalConfig::lookupCalibConnect(), geometryXMLtoCSV::parser, AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

Referenced by cond::persistency::ConnectionPool::createCoralSession(), and cond::persistency::ConnectionPool::createSession().

30  {
31  if( connectionString.empty() ) throwException( "The connection string is empty.","getConnectionParams");
32  std::string protocol = getConnectionProtocol( connectionString );
33  std::string finalConn = connectionString;
34  std::string refreshConn("");
35  if( protocol == "frontier" ){
36  std::string protocol("frontier://");
37  std::string::size_type fpos=connectionString.find(protocol);
38  unsigned int nslash=countslash(connectionString.substr(protocol.size(),connectionString.size()-fpos));
39  if(nslash==1){
40  edm::Service<edm::SiteLocalConfig> localconfservice;
41  if( !localconfservice.isAvailable() ){
42  throwException("edm::SiteLocalConfigService is not available","getConnectionParams");
43  }
44  finalConn=localconfservice->lookupCalibConnect(connectionString);
45  }
46  if (!transactionId.empty()) {
47  size_t l = finalConn.rfind('/');
48  finalConn.insert(l,"(freshkey="+transactionId+')');
49  }
50 
51  std::string::size_type startRefresh = finalConn.find("://");
52  if (startRefresh != std::string::npos){
53  startRefresh += 3;
54  }
55  std::string::size_type endRefresh=finalConn.rfind("/", std::string::npos);
56  if (endRefresh == std::string::npos){
57  refreshConn = finalConn;
58  } else{
59  refreshConn = finalConn.substr(startRefresh, endRefresh-startRefresh);
60  if(refreshConn.substr(0,1) != "("){
61  //if the connect string is not a complicated parenthesized string,
62  // an http:// needs to be at the beginning of it
63  refreshConn.insert(0, "http://");
64  }
65  }
66  } else if ( protocol == "sqlite_fip" ){
68  finalConn = parser.getRealConnect( connectionString );
69  }
70  return std::make_pair( finalConn, refreshConn );
71  }
std::string getConnectionProtocol(const std::string &connectionString)
Definition: Utils.h:35
std::string getRealConnect(const std::string &fipConnect) const
virtual std::string const lookupCalibConnect(std::string const &input) const =0
uint16_t size_type
bool isAvailable() const
Definition: Service.h:46
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
unsigned int countslash(const std::string &input)
std::string cond::persistency::getConnectionProtocol ( const std::string &  connectionString)
inline

Definition at line 35 of file Utils.h.

References AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

Referenced by getConnectionParams(), and parseConnectionString().

35  {
36  size_t techEnd = connectionString.find( ':' );
37  if( techEnd == std::string::npos ) throwException( "Could not resolve the connection protocol on "+connectionString+".",
38  "getConnectionProtocol" );
39  std::string technology = connectionString.substr(0,techEnd);
40  return technology;
41  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
bool cond::persistency::getInsertionLogs ( const std::string &  tag,
cond::DbSession logDbSession,
std::vector< std::pair< cond::Time_t, boost::posix_time::ptime > > &  loggedInsertions 
)

Definition at line 99 of file CondDBTools.cc.

References cond::DbTransaction::commit(), gather_cfg::cout, duplicate(), exportIOV(), first, h, m, cond::DbSession::nominalSchema(), popcon_many(), popcon_one(), lumiQueryAPI::q, alignCSCRings::s, python.multivaluedict::sort(), cond::DbTransaction::start(), AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, throwException(), and cond::DbSession::transaction().

Referenced by migrateTag().

101  {
102  logDbSession.transaction().start( true );
103  std::set<cond::Time_t> loggedSinces;
104  Query< COND_LOG_TABLE::EXECTIME, COND_LOG_TABLE::USERTEXT > q( logDbSession.nominalSchema() );
105  q.addCondition<COND_LOG_TABLE::IOVTAG>( tag );
106  for ( auto row : q ) {
107  if( std::get<1>( row ).empty() ) continue;
108  boost::smatch matches;
109  cond::Time_t since_t = 0;
110  size_t copied_n = 0;
111 
112  if (boost::regex_match(std::get<1>( row ), matches, popcon_many )){
113  since_t = boost::lexical_cast<unsigned long long>(matches[1]);
114  copied_n = 1;
115  } else if (boost::regex_match(std::get<1>( row ), matches, popcon_one )){
116  since_t = boost::lexical_cast<unsigned long long>(matches[1]);
117  copied_n = 1;
118  } else if (boost::regex_match(std::get<1>( row ), matches, exportIOV )){
119  since_t = boost::lexical_cast<unsigned long long>(matches[1]);
120  copied_n = boost::lexical_cast<unsigned long long>(matches[2]);
121  } else if( boost::regex_match(std::get<1>( row ), matches, duplicate )){
122  since_t = boost::lexical_cast<unsigned long long>(matches[1]);
123  copied_n = 1;
124  } else {
125  //throwException( "Tag "+tag+": could not parse the PopConLog info entry: "+std::get<1>( row ), "migrateTag" );
126  std::cout <<"ERROR: tag "<<tag<<": could not parse the PopConLog info entry: \""<<std::get<1>( row )<<"\""<<std::endl;
127  loggedSinces.clear();
128  break;
129  }
130  // if the insertion of a given since happens also later ( maybe it was deleted and re-written ), we keep the first insertion time...
131  if( loggedSinces.find( since_t ) == loggedSinces.end() && copied_n>0 ){
132  std::string s_t = std::get<0>( row );
133  int Y,M,D,h,m,s;
134  if(sscanf( s_t.c_str(), "%d-%d-%d-%d:%d:%d",&Y,&M,&D,&h,&m,&s) != 6 ){
135  throwException( "Tag "+tag+": time information can't be parsed.","migrateTag");
136  }
137  char parsable_s_t[23];
138  sprintf( parsable_s_t, "%04d-%02d-%02d %02d:%02d:%02d.000",Y,M,D,h,m,s );
139  //std::cout <<"## since="<<since_t<<" time="<<std::string( parsable_s_t )<<std::endl;
140  boost::posix_time::ptime insertionTime = boost::posix_time::time_from_string( std::string( parsable_s_t ) );
141  loggedInsertions.push_back( std::make_pair( since_t, insertionTime ) );
142  loggedSinces.insert( since_t );
143  }
144  }
145  logDbSession.transaction().commit();
146 
147  std::sort( loggedInsertions.begin(),
148  loggedInsertions.end(),
149  boost::bind( std::less<cond::Time_t>(),
152  ));
153  return loggedInsertions.size()>0;
154  }
DbTransaction & transaction()
Definition: DbSession.cc:208
static const boost::regex popcon_one("PopCon[[:print:]]+?;Since ([[:alnum:]]+?);.*")
int commit()
commit transaction.
int start(bool readOnly=false)
start transaction
unsigned long long Time_t
Definition: Time.h:16
static const boost::regex duplicate("duplicateIOV[[:print:]]+?[S|s]ince[=| ]([[:alnum:]]+?);.*")
static const boost::regex exportIOV("exportIOV[[:print:]]+?;since=([[:alnum:]]+?),[[:print:]]+?; *copied=([[:alnum:]]+?);.*")
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
bool first
Definition: L1TdeRCT.cc:75
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
coral::ISchema & nominalSchema()
Definition: DbSession.cc:243
static const boost::regex popcon_many("PopCon[[:print:]]+?first payload Since ([[:alnum:]]+?),.*")
tuple cout
Definition: gather_cfg.py:121
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
cond::Hash cond::persistency::import ( Session source,
const cond::Hash sourcePayloadId,
const std::string &  inputTypeName,
const void *  inputPtr,
Session destination 
)

Definition at line 57 of file CondDBImport.cc.

References L1TriggerKeyList::addKey(), gather_cfg::cout, roll_playback::destination, fetchIfExists(), IMPORT_PAYLOAD_CASE, match(), getGTfromDQMFile::obj, sysUtil::pid, L1TriggerKeyList::recordTypeToKeyToTokenMap(), source, AlCaHLTBitMon_QueryRunRegistry::string, throwException(), and L1TriggerKeyList::tscKeyToTokenMap().

57  {
58  cond::Hash payloadId("");
59  bool newInsert = false;
60  bool match = false;
61  if( inputPtr ){
63  IMPORT_PAYLOAD_CASE( std::vector<unsigned long long> )
223  if( inputTypeName == "L1TriggerKeyList" ){
224  match = true;
225  const L1TriggerKeyList& obj = *static_cast<const L1TriggerKeyList*>( inputPtr );
226  L1TriggerKeyList converted;
227  for( const auto& kitem : obj.tscKeyToTokenMap() ){
228  std::string pid("0");
229  std::string sourcePid = source.parsePoolToken( kitem.second );
230  if( !destination.lookupMigratedPayload( source.connectionString(), sourcePid, pid ) ){
231  std::cout <<"WARNING: L1Trigger key stored on "<<sourcePid<<" has not been migrated (yet?). Attemping to do the export..."<<std::endl;
232  bool exists = false;
233  std::pair<std::string,boost::shared_ptr<void> > missingPayload = fetchIfExists( sourcePid, source, exists );
234  if( exists ) pid = import( source, sourcePid, missingPayload.first, missingPayload.second.get(), destination );
235  std::cout <<"WARNING: OID "<<sourcePid<<" will be mapped to HASH "<<pid<<std::endl;
236  if( pid != "0" ) destination.addMigratedPayload( source.connectionString(), sourcePid, pid );
237  }
238  converted.addKey( kitem.first, pid );
239  }
240  for( const auto& ritem : obj.recordTypeToKeyToTokenMap() ){
241  for( const auto& kitem : ritem.second ){
242  std::string pid("0");
243  std::string sourcePid = source.parsePoolToken( kitem.second );
244  if( !destination.lookupMigratedPayload( source.connectionString(), sourcePid, pid ) ){
245  std::cout <<"WARNING: L1Trigger key stored on "<<sourcePid<<" has not been migrated (yet?). Attemping to do the export..."<<std::endl;
246  bool exists = false;
247  std::pair<std::string,boost::shared_ptr<void> > missingPayload = fetchIfExists( sourcePid, source, exists );
248  if( exists ) pid = import( source, sourcePid, missingPayload.first, missingPayload.second.get(), destination );
249  std::cout <<"WARNING: OID "<<sourcePid<<" will be mapped to HASH "<<pid<<std::endl;
250  if( pid != "0" ) destination.addMigratedPayload( source.connectionString(), sourcePid, pid );
251  }
252  converted.addKey( ritem.first, kitem.first, pid );
253  }
254  }
255  payloadId = destination.storePayload( converted, boost::posix_time::microsec_clock::universal_time() );
256  }
257  //IMPORT_PAYLOAD_CASE( L1TriggerKeyList )
263  IMPORT_PAYLOAD_CASE( PhysicsTools::Calibration::MVAComputerContainer )
267  //IMPORT_PAYLOAD_CASE( PerformancePayload )
310  IMPORT_PAYLOAD_CASE( cond::BaseKeyed )
319  if( inputTypeName == "PhysicsTools::Calibration::Histogram3D<double,double,double,double>" ){
320  match = true;
322  payloadId = destination.storePayload( obj, boost::posix_time::microsec_clock::universal_time() );
323  }
324  if( inputTypeName == "PhysicsTools::Calibration::Histogram2D<double,double,double>" ){
325  match = true;
327  payloadId = destination.storePayload( obj, boost::posix_time::microsec_clock::universal_time() );
328  }
329  if( inputTypeName == "std::vector<unsignedlonglong,std::allocator<unsignedlonglong>>" ){
330  match = true;
331  const std::vector<unsigned long long>& obj = *static_cast<const std::vector<unsigned long long>*>( inputPtr );
332  payloadId = destination.storePayload( obj, boost::posix_time::microsec_clock::universal_time() );
333  }
334 
335  if( ! match ) throwException( "Payload type \""+inputTypeName+"\" is unknown.","import" );
336  }
337  return payloadId;
338  }
Definition: ESGain.h:7
string destination
Definition: DTT0.h:53
Histogram3D< double > HistogramD3D
Definition: Histogram3D.h:187
QGLikelihoodObject containing valid range and entries with category, histogram and mean...
#define IMPORT_PAYLOAD_CASE(TYPENAME)
Definition: CondDBImport.cc:4
std::string Hash
Definition: Types.h:43
const RecordToKeyToToken & recordTypeToKeyToTokenMap() const
Category structure: ranges associated with QGLikelihood histograms.
tuple pid
Definition: sysUtil.py:22
const KeyToToken & tscKeyToTokenMap() const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
tuple cout
Definition: gather_cfg.py:121
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
std::pair< std::string, boost::shared_ptr< void > > fetchIfExists(const cond::Hash &payloadId, Session &session, bool &exists)
Definition: CondDBImport.cc:45
QGLikelihoodSystematicsObject containing the parameters for the systematic smearing.
if(conf.exists("allCellsPositionCalc"))
bool addKey(const std::string &tscKey, const std::string &payloadToken, bool overwriteKey=false)
static std::string const source
Definition: EdmProvDump.cc:43
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
size_t cond::persistency::importIovs ( const std::string &  sourceTag,
Session sourceSession,
const std::string &  destTag,
Session destSession,
cond::Time_t  begin,
cond::Time_t  end,
const std::string &  description,
bool  log 
)

Definition at line 256 of file CondDBTools.cc.

References begin, cond::persistency::IOVProxy::begin(), cond::persistency::Session::connectionString(), gather_cfg::cout, cond::persistency::Session::createDatabase(), cond::persistency::Session::createIov(), cond::persistency::Session::editIov(), idDealer::editor, end, cond::persistency::IOVProxy::end(), cond::persistency::Session::existsDatabase(), cond::persistency::Session::existsIov(), fetch(), cond::persistency::IOVProxy::find(), cond::persistency::IOVEditor::flush(), cond::persistency::IOVProxy::getInterval(), cond::persistency::IOVEditor::insert(), cond::persistency::IOVProxy::loadedSize(), AlCaHLTBitMon_ParallelJobs::p, cond::persistency::IOVProxy::payloadObjectType(), cond::persistency::IOVEditor::payloadType(), cond::persistency::Session::readIov(), cond::persistency::IOVEditor::setDescription(), EcalCondDB::sinces, cond::persistency::TransactionScope::start(), cond::persistency::IOVProxy::synchronizationType(), throwException(), cond::persistency::IOVEditor::timeType(), cond::persistency::IOVProxy::timeType(), and cond::persistency::Session::transaction().

263  {
264  persistency::TransactionScope ssc( sourceSession.transaction() );
265  ssc.start();
266  if( log ) std::cout <<" Loading source iov..."<<std::endl;
267  persistency::IOVProxy p = sourceSession.readIov( sourceTag, true );
268  if( p.loadedSize()==0 ) {
269  if( log ) std::cout <<" Tag contains 0 iovs."<<std::endl;
270  return 0;
271  } else {
272  if( log ) std::cout <<" Iov size:"<<p.loadedSize()<<" timeType:"<<p.timeType()<<" payloadObjectType=\""<<p.payloadObjectType()<<"\""<<std::endl;
273  }
274  if( (*p.begin()).since > begin ) begin = (*p.begin()).since;
275  if( end < begin ) {
276  if( log ) std::cout <<" No Iov in the selected range."<<std::endl;
277  }
278  persistency::IOVEditor editor;
279  persistency::TransactionScope dsc( destSession.transaction() );
280  dsc.start( false );
281  bool exists = false;
282  if( !destSession.existsDatabase() ) {
283  destSession.createDatabase();
284  } else {
285  exists = destSession.existsIov( destTag );
286  }
287  if( exists ){
288  editor = destSession.editIov( destTag );
289  if( editor.timeType() != p.timeType() )
290  throwException( "TimeType of the destination tag does not match with the source tag timeType.", "importIovs");
291  if( editor.payloadType() != p.payloadObjectType() )
292  throwException( "PayloadType of the destination tag does not match with the source tag payloadType.", "importIovs");
293  } else {
294  editor = destSession.createIov( p.payloadObjectType(), destTag, p.timeType(), p.synchronizationType() );
295  if( description.empty() ) editor.setDescription( "Created copying tag "+sourceTag+" from "+sourceSession.connectionString() );
296  else editor.setDescription( description );
297  }
298  size_t niovs = 0;
299  std::set<cond::Hash> pids;
300  std::set<cond::Time_t> sinces;
301  auto iiov = p.find( begin );
302  cond::Time_t newSince = begin;
303  while( iiov != p.end() ){
304  // skip duplicated sinces
305  if( sinces.find( newSince ) != sinces.end() ){
306  if( log ) std::cout <<" WARNING. Skipping duplicated since="<<newSince<<std::endl;
307  continue;
308  }
309  sinces.insert( newSince );
310  // make sure that we import the payload _IN_USE_
311  auto usedIov = p.getInterval( newSince );
312  std::pair<std::string,boost::shared_ptr<void> > readBackPayload = fetch( usedIov.payloadId, sourceSession );
313  cond::Hash ph = import( sourceSession, usedIov.payloadId, readBackPayload.first, readBackPayload.second.get(), destSession );
314  editor.insert( newSince, ph );
315  pids.insert( ph );
316  niovs++;
317  if( log && niovs && (niovs%1000==0) ) std::cout <<" Total of iov inserted: "<<niovs<<" payloads: "<<pids.size()<<std::endl;
318  iiov++;
319  if( iiov == p.end() || (*iiov).since > end ){
320  break;
321  } else {
322  newSince = (*iiov).since;
323  }
324  }
325  if( log ) std::cout <<" Total of iov inserted: "<<niovs<<" payloads: "<<pids.size()<<std::endl;
326  if( log ) std::cout <<" Flushing changes..."<<std::endl;
327  editor.flush();
328  dsc.commit();
329  ssc.commit();
330  return niovs;
331  }
list sinces
Definition: EcalCondDB.py:80
unsigned long long Time_t
Definition: Time.h:16
std::string Hash
Definition: Types.h:43
#define end
Definition: vmac.h:37
std::pair< std::string, boost::shared_ptr< void > > fetch(const cond::Hash &payloadId, Session &session)
tuple description
Definition: idDealer.py:66
tuple editor
Definition: idDealer.py:73
#define begin
Definition: vmac.h:30
tuple cout
Definition: gather_cfg.py:121
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
template<typename T , typename Arg1 >
bool cond::persistency::is_same_any ( )

Definition at line 210 of file DbCore.h.

References relativeConstraints::value.

210  {
212  };
template<typename T , typename Arg1 , typename Arg2 , typename... Args>
bool cond::persistency::is_same_any ( )

Definition at line 214 of file DbCore.h.

214  {
215  return is_same_any<T, Arg1>() || is_same_any<T, Arg2, Args...>();
216  };
cond::Hash cond::persistency::makeHash ( const std::string &  objectType,
const cond::Binary data 
)

Definition at line 10 of file IOVSchema.cc.

References cond::Binary::data(), cond::hash, i, cond::Binary::size(), throwException(), and tmp.

Referenced by cond::persistency::PAYLOAD::Table::insertIfNew().

10  {
11  SHA_CTX ctx;
12  if( !SHA1_Init( &ctx ) ){
13  throwException( "SHA1 initialization error.","IOVSchema::makeHash");
14  }
15  if( !SHA1_Update( &ctx, objectType.c_str(), objectType.size() ) ){
16  throwException( "SHA1 processing error (1).","IOVSchema::makeHash");
17  }
18  if( !SHA1_Update( &ctx, data.data(), data.size() ) ){
19  throwException( "SHA1 processing error (2).","IOVSchema::makeHash");
20  }
21  unsigned char hash[SHA_DIGEST_LENGTH];
22  if( !SHA1_Final(hash, &ctx) ){
23  throwException( "SHA1 finalization error.","IOVSchema::makeHash");
24  }
25 
26  char tmp[SHA_DIGEST_LENGTH*2+1];
27  // re-write bytes in hex
28  for (unsigned int i = 0; i < 20; i++) {
29  ::sprintf(&tmp[i * 2], "%02x", hash[i]);
30  }
31  tmp[20*2] = 0;
32  return tmp;
33  }
int i
Definition: DBlmapReader.cc:9
size_t size() const
Definition: Binary.cc:57
const void * data() const
Definition: Binary.cc:48
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
size_t cond::persistency::migrateTag ( const std::string &  sourceTag,
Session sourceSession,
const std::string &  destTag,
Session destSession,
UpdatePolicy  policy,
cond::DbSession logDbSession 
)

Definition at line 168 of file CondDBTools.cc.

References cond::persistency::Session::clearIov(), gather_cfg::cout, cond::persistency::Session::createDatabase(), cond::persistency::Session::createIov(), cond::persistency::Session::editIov(), idDealer::editor, cond::persistency::Session::existsDatabase(), cond::persistency::Session::existsIov(), fetch(), cond::persistency::IOVEditor::flush(), getInsertionLogs(), cond::persistency::IOVProxy::getMetadata(), cond::persistency::IOVEditor::insert(), o2o::iov, cond::persistency::IOVProxy::loadedSize(), NEW, AlCaHLTBitMon_ParallelJobs::p, cond::persistency::IOVProxy::payloadObjectType(), cond::persistency::Session::readIov(), REPLACE, cond::persistency::Transaction::rollback(), search(), edm::second(), cond::persistency::IOVEditor::setDescription(), EcalCondDB::sinces, cond::persistency::TransactionScope::start(), cond::persistency::IOVProxy::synchronizationType(), throwException(), time_0(), cond::persistency::IOVProxy::timeType(), and cond::persistency::Session::transaction().

173  {
174  persistency::TransactionScope ssc( sourceSession.transaction() );
175  ssc.start();
176  std::cout <<" Loading source iov..."<<std::endl;
177  persistency::IOVProxy p = sourceSession.readIov( sourceTag, true );
178  if( p.loadedSize()==0 ) {
179  std::cout <<" Tag contains 0 iovs."<<std::endl;
180  return 0;
181  }
182 
183  std::vector<std::pair<cond::Time_t,boost::posix_time::ptime> > loggedInsertions;
184  std::tuple<std::string, boost::posix_time::ptime, boost::posix_time::ptime > metadata = p.getMetadata();
185  boost::posix_time::ptime creationTime = boost::posix_time::time_from_string( time_0 );
186  if( p.loadedSize() == 1 ){
187  creationTime = std::get<2>(metadata);
188  //std::cout <<"## creation time="<<creationTime<<std::endl;
189  } else {
190  getInsertionLogs( sourceTag, logDbSession, loggedInsertions );
191  if( !loggedInsertions.empty() ) creationTime = loggedInsertions[0].second;
192  }
193 
194  std::cout <<" Copying tag. Iov size:"<<p.loadedSize()<<" timeType:"<<p.timeType()<<" payloadObjectType=\""<<p.payloadObjectType()<<"\""<<std::endl;
195 
196  persistency::IOVEditor editor;
197  persistency::TransactionScope dsc( destSession.transaction() );
198  dsc.start( false );
199  bool exists = false;
200  if( !destSession.existsDatabase() ) {
201  destSession.createDatabase();
202  } else {
203  exists = destSession.existsIov( destTag );
204  }
205  if( exists ){
206  if( policy == REPLACE ){
207  destSession.clearIov( destTag );
208  } else if( policy == NEW ){
209  destSession.transaction().rollback();
210  throwException(" Tag \""+destTag+"\" already exists.","copyTag");
211  }
212  editor = destSession.editIov( destTag );
213  } else {
214  editor = destSession.createIov( p.payloadObjectType(), destTag, p.timeType(), p.synchronizationType(), creationTime );
215  editor.setDescription( std::get<0>( metadata ));
216  }
217  size_t niovs = 0;
218  std::set<cond::Hash> pids;
219  std::set<cond::Time_t> sinces;
220  for( auto iov : p ){
221  // skip duplicated sinces
222  if( sinces.find( iov.since ) != sinces.end() ){
223  std::cout <<" WARNING. Skipping duplicated since="<<iov.since<<std::endl;
224  continue;
225  }
226  sinces.insert( iov.since );
227 
228  boost::posix_time::ptime insertionTime = creationTime;
229  if( !loggedInsertions.empty() ){
230  auto iL = search( iov.since, loggedInsertions );
231  if( iL != loggedInsertions.end() ) insertionTime = iL->second;
232  }
233 
234  // make sure that we import the payload _IN_USE_
235  auto usedIov = p.getInterval( iov.since );
236  std::pair<std::string,boost::shared_ptr<void> > readBackPayload = fetch( usedIov.payloadId, sourceSession );
237  cond::Hash ph = import( sourceSession, usedIov.payloadId, readBackPayload.first, readBackPayload.second.get(), destSession );
238  //std::cout <<"## inserting iov "<<iov.since<<" on time "<<insertionTime<<std::endl;
239  editor.insert( iov.since, ph, insertionTime );
240  pids.insert( ph );
241  niovs++;
242  if( niovs && (niovs%1000==0) ) {
243  std::cout <<" Total of iov inserted: "<<niovs<<" payloads: "<<pids.size()<<std::endl;
244  std::cout <<" Last since imported: "<<iov.since<<std::endl;
245  }
246  }
247  std::cout <<" Total of iov inserted: "<<niovs<<" payloads: "<<pids.size()<<std::endl;
248  std::cout <<" Flushing changes..."<<std::endl;
249  editor.flush();
250  dsc.commit();
251  ssc.commit();
252  return niovs;
253  }
list sinces
Definition: EcalCondDB.py:80
U second(std::pair< T, U > const &p)
tuple iov
Definition: o2o.py:307
std::string Hash
Definition: Types.h:43
std::pair< std::string, boost::shared_ptr< void > > fetch(const cond::Hash &payloadId, Session &session)
bool getInsertionLogs(const std::string &tag, cond::DbSession &logDbSession, std::vector< std::pair< cond::Time_t, boost::posix_time::ptime > > &loggedInsertions)
Definition: CondDBTools.cc:99
static const std::string time_0("2008-01-01 00:00:42.000")
tuple editor
Definition: idDealer.py:73
tuple cout
Definition: gather_cfg.py:121
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:252
static const std::string cond::persistency::ORA_IOV_TABLE_1 ( "ORA_C_COND_IOVSEQUENCE"  )
static
static const std::string cond::persistency::ORA_IOV_TABLE_2 ( "ORA_C_COND_IOVSEQU_A0"  )
static
static const std::string cond::persistency::ORA_IOV_TABLE_3 ( "ORA_C_COND_IOVSEQU_A1"  )
static
std::tuple<std::string,std::string,std::string> cond::persistency::parseConnectionString ( const std::string &  connectionString)
inline

Definition at line 43 of file Utils.h.

References getConnectionProtocol(), serviceName, AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

Referenced by validateTag().

43  {
44  std::string protocol = getConnectionProtocol( connectionString );
46  std::string databaseName("");
47  if( protocol == "sqlite" || protocol == "sqlite_file" || protocol == "sqlite_fip" ){
48  databaseName = connectionString.substr( protocol.size()+1 );
49  } else if ( protocol == "oracle" || protocol == "frontier" ){
50  size_t ptr = protocol.size()+1;
51  if( connectionString.substr( ptr,2 )!="//" ) throwException( "Connection string "+connectionString+
52  " is invalid format for technology \""+
53  protocol+"\".","parseConnectionString" );
54  ptr += 2;
55  size_t serviceEnd = connectionString.find( '/', ptr );
56  if( serviceEnd == std::string::npos ) throwException( "Connection string "+connectionString+" is invalid.",
57  "parseConnectionString" );
58  serviceName = connectionString.substr( ptr, serviceEnd-ptr );
59  ptr = serviceEnd+1;
60  databaseName = connectionString.substr( ptr );
61  } else throwException( "Technology "+protocol+" is not known.","parseConnectionString" );
62 
63  return std::make_tuple( protocol, serviceName, databaseName );
64  }
std::string getConnectionProtocol(const std::string &connectionString)
Definition: Utils.h:35
static const std::string serviceName
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
std::pair< std::string, std::string > cond::persistency::parseTag ( const std::string &  tag)

Definition at line 8 of file GTProxy.cc.

References dbtoconf::pfn, AlCaHLTBitMon_QueryRunRegistry::string, and edmStreamStallGrapher::t.

Referenced by CondDBESSource::CondDBESSource(), and CondDBESSource::setIntervalFor().

8  {
9  std::string pfn("");
10  std::string t(tag);
11  size_t pos = tag.rfind('@');
12  if( pos != std::string::npos && tag.size() >= pos+3 ){
13  if( tag[pos+1]=='[' && tag[tag.size()-1]==']' ) {
14  pfn = tag.substr( pos+2,tag.size()-pos-3 );
15  t = tag.substr( 0, pos );
16  }
17  }
18  return std::make_pair( t, pfn );
19  }
list pfn
Definition: dbtoconf.py:76
static const std::string cond::persistency::POOL_IOV_TABLE_DATA ( "IOV_DATA"  )
static
static const boost::regex cond::persistency::popcon_many ( "PopCon]+?first payload Since   ([[:alnum:]]+?)[[:print:],
.*"   
)
static

Referenced by getInsertionLogs().

static const boost::regex cond::persistency::popcon_one ( "PopCon]+?;Since ([[:alnum:]]+?);.*"  [[:print:])
static

Referenced by getInsertionLogs().

template<typename T >
std::vector< T >::const_iterator cond::persistency::search ( const cond::Time_t val,
const std::vector< T > &  container 
)

Definition at line 252 of file IOVProxy.cc.

References AlCaHLTBitMon_ParallelJobs::p.

Referenced by dqm_interfaces.DirID::__eq__(), ValidationMatrix::add_to_blacklist(), ValidationMatrix::do_comparisons_threaded(), AlignmentMonitorTemplate::event(), cond::persistency::IOVProxy::find(), FileNamesHelper::getJobID_fromFileName(), ValidationMatrix::guess_blacklists(), ValidationMatrix::guess_params(), migrateTag(), and duplicateReflexLibrarySearch::searchClassDefXml().

252  {
253  if( !container.size() ) return container.end();
254  auto p = std::upper_bound( container.begin(), container.end(), val, IOVComp() );
255  return (p!= container.begin()) ? p-1 : container.end();
256  }
template<typename T , typename P >
void cond::persistency::static_assert_is_same_decayed ( )
inline

Definition at line 82 of file DbCore.h.

References relativeConstraints::value.

82  {
83  static_assert( std::is_same<typename std::decay<T>::type, typename std::decay<P>::type>::value, "Parameter types don't match with the RowBuffer types" );
84  };
type
Definition: HCALResponse.h:21
void cond::persistency::throwException ( const std::string &  message,
const std::string &  methodName 
)

Definition at line 11 of file Exception.cc.

References edm::hlt::Exception.

Referenced by L1CondDBIOVWriter::analyze(), L1CondDBPayloadWriter::analyze(), cond::persistency::GTEditor::checkTransaction(), cond::persistency::IOVEditor::checkTransaction(), cond::persistency::GTProxy::checkTransaction(), cond::persistency::IOVProxy::checkTransaction(), compareTags(), convertoToOracleConnection(), copyIov(), copyTag(), cond::persistency::Session::coralSession(), cond::persistency::TAG::Table::create(), cond::persistency::PAYLOAD::Table::create(), cond::persistency::IOV::Table::create(), cond::persistency::TAG_MIGRATION::Table::create(), cond::persistency::PAYLOAD_MIGRATION::Table::create(), cond::persistency::Session::createGlobalTag(), cond::persistency::Session::createIov(), cond::persistency::Session::createIovForPayload(), cond::persistency::Query< Types...>::currentRow(), cond::persistency::OraIOVTable::erase(), fetch(), fetchOne(), cond::persistency::Session::fetchPayload(), cond::persistency::GTEditor::flush(), cond::persistency::IOVEditor::flush(), cond::persistency::KeyList::get(), getConnectionParams(), getConnectionProtocol(), getInsertionLogs(), cond::persistency::IOVProxy::getInterval(), cond::persistency::IOVProxy::getMetadata(), import(), importIovs(), cond::persistency::OraIOVTable::insertMany(), cond::persistency::OraIOVTable::insertOne(), cond::persistency::SessionImpl::isOra(), cond::persistency::GTEditor::load(), cond::persistency::IOVProxy::load(), cond::persistency::GTProxy::load(), cond::persistency::PayloadProxy< std::vector< cond::Time_t > >::loadPayload(), makeHash(), migrateTag(), cond::persistency::Query< Types...>::next(), cond::persistency::SessionImpl::openGTDb(), cond::persistency::SessionImpl::openIovDb(), cond::persistency::PayloadProxy< std::vector< cond::Time_t > >::operator()(), cond::persistency::GetFromRow< std::array< char, n > >::operator()(), parseConnectionString(), cond::persistency::IOVSchema::parsePoolToken(), cond::persistency::OraIOVSchema::payloadMigrationTable(), cond::CredentialStore::startSession(), cond::persistency::SessionImpl::startTransaction(), cond::persistency::OraIOVSchema::tagMigrationTable(), cond::persistency::OraTagTable::update(), cond::CredentialStore::updateConnection(), cond::persistency::Session::updateMigratedPayload(), and cond::persistency::Session::updateMigrationLog().

12  {
13  throw Exception( message, methodName );
14  }
static const std::string cond::persistency::time_0 ( "2008-01-01 00:00:42.000"  )
static

Referenced by migrateTag().

bool cond::persistency::validateTag ( const std::string &  refTag,
Session refSession,
const std::string &  candTag,
Session candSession 
)

Definition at line 445 of file CondDBTools.cc.

References compareTags(), cond::persistency::Session::connectionString(), gather_cfg::cout, dtTTrigAnalyzer_cfg::dbLabel, parseConnectionString(), cmsHarvester::path, python.multivaluedict::remove(), run_regression::ret, and AlCaHLTBitMon_QueryRunRegistry::string.

448  {
449  std::cout <<" Validating..."<<std::endl;
450  std::tuple<std::string,std::string,std::string> connPars = persistency::parseConnectionString( refSession.connectionString() );
451  std::string dbLabel = std::get<2>( connPars );
452  std::string tagLabel = dbLabel+"_"+refTag;
453  std::string refFile = tagLabel+"_ref.db";
454  std::string candFile = tagLabel+"_cand.db";
455  bool ret = compareTags( refTag, refSession, refFile, candTag, candSession, candFile );
456  if( ret ) {
457  boost::filesystem::path refF( refFile );
458  if( boost::filesystem::exists(refF) ) boost::filesystem::remove( refF );
459  boost::filesystem::path candF( candFile );
460  if( boost::filesystem::exists(candF) ) boost::filesystem::remove( candF );
461  }
462  return ret;
463  }
std::tuple< std::string, std::string, std::string > parseConnectionString(const std::string &connectionString)
Definition: Utils.h:43
tuple path
else: Piece not in the list, fine.
tuple cout
Definition: gather_cfg.py:121
bool compareTags(const std::string &firstTag, Session &firstSession, const std::string &firstFileName, const std::string &secondTag, Session &secondSession, const std::string &secondFileName)
Definition: CondDBTools.cc:385