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::string fullyQualifiedTag (const std::string &tag, const std::string &connectionString)
 
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  ret = COND_DB;
74  } else {
75  ret = ORA_DB;
76  }
77  oraSession.transaction().commit();
78  return ret;
79  }
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 386 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().

391  {
392  size_t n1 = exportTagToFile( firstTag, firstTag, firstSession, firstFileName );
393  if( ! n1 ){
394  std::cout <<"Can't compare empty tag "<<firstTag<<std::endl;
395  return false;
396  }
397  size_t n2 = exportTagToFile( secondTag, firstTag, secondSession, secondFileName );
398  if( ! n2 ){
399  std::cout <<"Can't compare empty tag "<<secondTag<<std::endl;
400  return false;
401  }
402  if( n1 != n2 ) {
403  std::cout <<" Tag size is different. "<<firstSession.connectionString()<<":"<<firstTag<<": "<<n1<<" "<<
404  secondSession.connectionString()<<":"<<secondTag<<": "<<n2<<std::endl;
405  }
406 
407  FILE* file1 = fopen( firstFileName.c_str(), "r" );
408  if( file1 == NULL ){
409  throwException("Can't open file "+firstFileName, "compareTags" );
410  }
411  FILE* file2 = fopen( secondFileName.c_str(), "r" );
412  if( file2 == NULL ){
413  throwException("Can't open file "+secondFileName, "compareTags" );
414  }
415  int N = 10000;
416  char buf1[N];
417  char buf2[N];
418 
419  bool cmpOk = true;
420  size_t totSize = 0;
421  do {
422  size_t r1 = fread( buf1, 1, N, file1 );
423  size_t r2 = fread( buf2, 1, N, file2 );
424 
425  if( r1 != r2 || memcmp( buf1, buf2, r1)) {
426  cmpOk = false;
427  break;
428  }
429  totSize += r1;
430  } while(!feof(file2) || !feof(file2));
431 
432  std::cout <<" "<<totSize<<" bytes compared."<<std::endl;
433  fclose( file1 );
434  fclose( file2 );
435 
436  if( cmpOk ){
437  boost::filesystem::path fp1( firstFileName );
439  boost::filesystem::path fp2( secondFileName );
441  }
442 
443  return cmpOk;
444  }
#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:379
#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 84 of file Utils.h.

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

Referenced by CondDBESSource::CondDBESSource().

84  {
85 
86  // leave the connection string unmodified for sqlite
87  if( input.find("sqlite") == 0 || input.find("oracle") == 0) return input;
88 
89  //static const boost::regex trivial("oracle://(cms_orcon_adg|cms_orcoff_prep)/([_[:alnum:]]+?)");
90  static const boost::regex short_frontier("frontier://([[:alnum:]]+?)/([_[:alnum:]]+?)");
91  static const boost::regex long_frontier("frontier://((\\([-[:alnum:]]+?=[^\\)]+?\\))+)/([_[:alnum:]]+?)");
92  static const boost::regex long_frontier_serverurl("\\(serverurl=[^\\)]+?/([[:alnum:]]+?)\\)");
93 
94  static const std::map<std::string, std::string> frontierMap = {
95  {"PromptProd", "cms_orcon_adg"},
96  {"FrontierProd", "cms_orcon_adg"},
97  {"FrontierArc", "cms_orcon_adg"},
98  {"FrontierOnProd", "cms_orcon_adg"},
99  {"FrontierPrep", "cms_orcoff_prep"},
100  };
101 
102  boost::smatch matches;
103 
104  static const std::string technology("oracle://");
105  std::string service("");
106  std::string account("");
107 
108  bool match = false;
109  if (boost::regex_match(input, matches, short_frontier)){
110  service = matches[1];
111  account = matches[2];
112  match = true;
113  }
114 
115  if (boost::regex_match(input, matches, long_frontier)) {
116  std::string frontier_config(matches[1]);
117  boost::smatch matches2;
118  if (not boost::regex_search(frontier_config, matches2, long_frontier_serverurl))
119  throwException("No serverurl in matched long frontier","convertoToOracleConnection");
120  service = matches2[1];
121  account = matches[3];
122  match = true;
123  }
124 
125  if( !match ) throwException("Connection string "+input+" can't be converted to oracle connection.","convertoToOracleConnection");
126 
127  if( service == "FrontierArc" ){
128  size_t len = account.size()-5;
129  account = account.substr(0,len);
130  }
131 
132  auto it = frontierMap.find( service );
133  if( it == frontierMap.end() ) throwException("Connection string can't be converted.","convertoToOracleConnection");
134  service = it->second;
135 
136  return technology+service+"/"+account;
137  }
list account
Definition: dbtoconf.py:80
static std::string const input
Definition: EdmProvDump.cc:43
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
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 334 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().

340  {
341  persistency::TransactionScope ssc( session.transaction() );
342  ssc.start( false );
343  if( log ) std::cout <<" Loading source iov..."<<std::endl;
344  persistency::IOVProxy p = session.readIov( sourceTag, true );
345  if( p.loadedSize()==0 ) {
346  if( log ) std::cout <<" Tag contains 0 iovs."<<std::endl;
347  return false;
348  } else {
349  if( log ) std::cout <<" Iov size:"<<p.loadedSize()<<" timeType:"<<p.timeType()<<" payloadObjectType=\""<<p.payloadObjectType()<<"\""<<std::endl;
350  }
351 
352  auto iiov = p.find( sourceSince );
353  if( iiov == p.end() ){
354  if( log ) std::cout <<"ERROR: No Iov valid found for target time "<<sourceSince<<std::endl;
355  return false;
356  }
357 
358  persistency::IOVEditor editor;
359  if( session.existsIov( destTag ) ){
360  editor = session.editIov( destTag );
361  if( editor.timeType() != p.timeType() )
362  throwException( "TimeType of the destination tag does not match with the source tag timeType.", "importIovs");
363  if( editor.payloadType() != p.payloadObjectType() )
364  throwException( "PayloadType of the destination tag does not match with the source tag payloadType.", "importIovs");
365  } else {
366  editor = session.createIov( p.payloadObjectType(), destTag, p.timeType(), p.synchronizationType() );
367  if( description.empty() ) editor.setDescription( "Created copying iovs from tag "+sourceTag );
368  else editor.setDescription( description );
369  }
370 
371  editor.insert( destSince, (*iiov).payloadId );
372 
373  if( log ) std::cout <<" Flushing changes..."<<std::endl;
374  editor.flush();
375  ssc.commit();
376  return true;
377  }
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)
Definition: CondDBFetch.cc:294
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:43
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 379 of file CondDBTools.cc.

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

Referenced by compareTags().

379  {
380  ConnectionPool localPool;
381  Session writeSession = localPool.createSession( "sqlite:"+fileName, true );
382  size_t ret = copyTag( tag, session, destTag, writeSession, NEW, false,true );
383  return ret;
384  }
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 294 of file CondDBFetch.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().

294  {
295  boost::shared_ptr<void> payloadPtr;
297  cond::Binary streamerInfo;
298  std::string payloadTypeName;
299  bool found = session.fetchPayloadData( payloadId, payloadTypeName, data, streamerInfo );
300  if( !found ) throwException( "Payload with id "+boost::lexical_cast<std::string>(payloadId)+" has not been found in the database.","fetchAndCompare" );
301  //std::cout <<"--> payload type "<<payloadTypeName<<" has blob size "<<data.size()<<std::endl;
302  bool isOra = session.isOraSession();
303  return fetchOne(payloadTypeName, data, streamerInfo, payloadPtr, isOra);
304  }
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 24 of file CondDBImport.cc.

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

Referenced by import().

24  {
25  boost::shared_ptr<void> payloadPtr;
27  cond::Binary streamerInfo;
28  std::string payloadTypeName;
29  exists = session.fetchPayloadData( payloadId, payloadTypeName, data, streamerInfo );
30  if( exists ) {
31  bool isOra = session.isOraSession();
32  return fetchOne(payloadTypeName, data, streamerInfo, payloadPtr, isOra);
33  } else return std::make_pair( std::string(""), boost::shared_ptr<void>() );
34  }
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 23 of file CondDBFetch.cc.

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

23  {
24 
25  bool match = false;
27  FETCH_PAYLOAD_CASE( std::vector<unsigned long long> )
202  FETCH_PAYLOAD_CASE( lumi::LumiSectionData )
207  FETCH_PAYLOAD_CASE( PhysicsTools::Calibration::MVAComputerContainer )
215  //FETCH_PAYLOAD_CASE( PerformancePayload )
262  FETCH_PAYLOAD_CASE( cond::BaseKeyed )
272 
273  //
274  if( payloadTypeName == "PhysicsTools::Calibration::Histogram3D<double,double,double,double>" ){
275  auto payload = deserialize<PhysicsTools::Calibration::Histogram3D<double,double,double,double> >(payloadTypeName, data, streamerInfo, isOra );
276  payloadPtr = payload;
277  match = true;
278  }
279  if( payloadTypeName == "PhysicsTools::Calibration::Histogram2D<double,double,double>" ){
280  auto payload = deserialize<PhysicsTools::Calibration::Histogram2D<double,double,double> >(payloadTypeName, data, streamerInfo, isOra );
281  payloadPtr = payload;
282  match = true;
283  }
284  if( payloadTypeName == "std::vector<unsignedlonglong,std::allocator<unsignedlonglong>>" ){
285  auto payload = deserialize<std::vector<unsigned long long> >( payloadTypeName, data, streamerInfo, isOra );
286  payloadPtr = payload;
287  match = true;
288  }
289 
290  if( ! match ) throwException( "Payload type \""+payloadTypeName+"\" is unknown.","fetch" );
291  return std::make_pair( payloadTypeName, payloadPtr );
292  }
Definition: ESGain.h:7
tuple lumi
Definition: fjr2json.py:35
#define FETCH_PAYLOAD_CASE(TYPENAME)
Definition: CondDBFetch.cc:3
Definition: DTT0.h:53
Histogram3D< double > HistogramD3D
Definition: Histogram3D.h:187
QGLikelihoodObject containing valid range and entries with category and histogram (mean is not used a...
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:10
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::string cond::persistency::fullyQualifiedTag ( const std::string &  tag,
const std::string &  connectionString 
)

Definition at line 8 of file GTProxy.cc.

Referenced by CondDBESSource::CondDBESSource().

8  {
9  if(connectionString.empty()) return tag;
10  return tag+"@["+connectionString+"]";
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:53
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 53 of file Utils.h.

References AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

Referenced by getConnectionParams(), and parseConnectionString().

53  {
54  size_t techEnd = connectionString.find( ':' );
55  if( techEnd == std::string::npos ) throwException( "Could not resolve the connection protocol on "+connectionString+".",
56  "getConnectionProtocol" );
57  std::string technology = connectionString.substr(0,techEnd);
58  return technology;
59  }
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(), plotBeamSpotDB::first, h, visualization-live-secondInstance_cfg::m, matches, 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
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 36 of file CondDBImport.cc.

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

36  {
37  cond::Hash payloadId("");
38  bool newInsert = false;
39  bool match = false;
40  if( inputPtr ){
42  IMPORT_PAYLOAD_CASE( std::vector<unsigned long long> )
215  if( inputTypeName == "L1TriggerKeyList" ){
216  match = true;
217  const L1TriggerKeyList& obj = *static_cast<const L1TriggerKeyList*>( inputPtr );
218  L1TriggerKeyList converted;
219  for( const auto& kitem : obj.tscKeyToTokenMap() ){
220  std::string pid("0");
221  std::string sourcePid = source.parsePoolToken( kitem.second );
222  if( !destination.lookupMigratedPayload( source.connectionString(), sourcePid, pid ) ){
223  std::cout <<"WARNING: L1Trigger key stored on "<<sourcePid<<" has not been migrated (yet?). Attemping to do the export..."<<std::endl;
224  bool exists = false;
225  std::pair<std::string,boost::shared_ptr<void> > missingPayload = fetchIfExists( sourcePid, source, exists );
226  if( exists ) pid = import( source, sourcePid, missingPayload.first, missingPayload.second.get(), destination );
227  std::cout <<"WARNING: OID "<<sourcePid<<" will be mapped to HASH "<<pid<<std::endl;
228  if( pid != "0" ) destination.addMigratedPayload( source.connectionString(), sourcePid, pid );
229  }
230  converted.addKey( kitem.first, pid );
231  }
232  for( const auto& ritem : obj.recordTypeToKeyToTokenMap() ){
233  for( const auto& kitem : ritem.second ){
234  std::string pid("0");
235  std::string sourcePid = source.parsePoolToken( kitem.second );
236  if( !destination.lookupMigratedPayload( source.connectionString(), sourcePid, pid ) ){
237  std::cout <<"WARNING: L1Trigger key stored on "<<sourcePid<<" has not been migrated (yet?). Attemping to do the export..."<<std::endl;
238  bool exists = false;
239  std::pair<std::string,boost::shared_ptr<void> > missingPayload = fetchIfExists( sourcePid, source, exists );
240  if( exists ) pid = import( source, sourcePid, missingPayload.first, missingPayload.second.get(), destination );
241  std::cout <<"WARNING: OID "<<sourcePid<<" will be mapped to HASH "<<pid<<std::endl;
242  if( pid != "0" ) destination.addMigratedPayload( source.connectionString(), sourcePid, pid );
243  }
244  converted.addKey( ritem.first, kitem.first, pid );
245  }
246  }
247  payloadId = destination.storePayload( converted, boost::posix_time::microsec_clock::universal_time() );
248  }
249  //IMPORT_PAYLOAD_CASE( L1TriggerKeyList )
257  IMPORT_PAYLOAD_CASE( PhysicsTools::Calibration::MVAComputerContainer )
263  //IMPORT_PAYLOAD_CASE( PerformancePayload )
312  IMPORT_PAYLOAD_CASE( cond::BaseKeyed )
321  if( inputTypeName == "PhysicsTools::Calibration::Histogram3D<double,double,double,double>" ){
322  match = true;
324  payloadId = destination.storePayload( obj, boost::posix_time::microsec_clock::universal_time() );
325  }
326  if( inputTypeName == "PhysicsTools::Calibration::Histogram2D<double,double,double>" ){
327  match = true;
329  payloadId = destination.storePayload( obj, boost::posix_time::microsec_clock::universal_time() );
330  }
331  if( inputTypeName == "std::vector<unsignedlonglong,std::allocator<unsignedlonglong>>" ){
332  match = true;
333  const std::vector<unsigned long long>& obj = *static_cast<const std::vector<unsigned long long>*>( inputPtr );
334  payloadId = destination.storePayload( obj, boost::posix_time::microsec_clock::universal_time() );
335  }
336 
337  if( ! match ) throwException( "Payload type \""+inputTypeName+"\" is unknown.","import" );
338  }
339  return payloadId;
340  }
Definition: ESGain.h:7
Definition: DTT0.h:53
Histogram3D< double > HistogramD3D
Definition: Histogram3D.h:187
QGLikelihoodObject containing valid range and entries with category and histogram (mean is not used a...
#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:10
std::pair< std::string, boost::shared_ptr< void > > fetchIfExists(const cond::Hash &payloadId, Session &session, bool &exists)
Definition: CondDBImport.cc:24
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:42
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  return 0;
278  }
279  persistency::IOVEditor editor;
280  persistency::TransactionScope dsc( destSession.transaction() );
281  dsc.start( false );
282  bool exists = false;
283  if( !destSession.existsDatabase() ) {
284  destSession.createDatabase();
285  } else {
286  exists = destSession.existsIov( destTag );
287  }
288  if( exists ){
289  editor = destSession.editIov( destTag );
290  if( editor.timeType() != p.timeType() )
291  throwException( "TimeType of the destination tag does not match with the source tag timeType.", "importIovs");
292  if( editor.payloadType() != p.payloadObjectType() )
293  throwException( "PayloadType of the destination tag does not match with the source tag payloadType.", "importIovs");
294  } else {
295  editor = destSession.createIov( p.payloadObjectType(), destTag, p.timeType(), p.synchronizationType() );
296  if( description.empty() ) editor.setDescription( "Created copying tag "+sourceTag+" from "+sourceSession.connectionString() );
297  else editor.setDescription( description );
298  }
299  size_t niovs = 0;
300  std::set<cond::Hash> pids;
301  std::set<cond::Time_t> sinces;
302  auto iiov = p.find( begin );
303  cond::Time_t newSince = begin;
304  while( iiov != p.end() ){
305  // skip duplicated sinces
306  if( sinces.find( newSince ) != sinces.end() ){
307  if( log ) std::cout <<" WARNING. Skipping duplicated since="<<newSince<<std::endl;
308  continue;
309  }
310  sinces.insert( newSince );
311  // make sure that we import the payload _IN_USE_
312  auto usedIov = p.getInterval( newSince );
313  std::pair<std::string,boost::shared_ptr<void> > readBackPayload = fetch( usedIov.payloadId, sourceSession );
314  cond::Hash ph = import( sourceSession, usedIov.payloadId, readBackPayload.first, readBackPayload.second.get(), destSession );
315  editor.insert( newSince, ph );
316  pids.insert( ph );
317  niovs++;
318  if( log && niovs && (niovs%1000==0) ) std::cout <<" Total of iov inserted: "<<niovs<<" payloads: "<<pids.size()<<std::endl;
319  iiov++;
320  if( iiov == p.end() || (*iiov).since > end ){
321  break;
322  } else {
323  newSince = (*iiov).since;
324  }
325  }
326  if( log ) std::cout <<" Total of iov inserted: "<<niovs<<" payloads: "<<pids.size()<<std::endl;
327  if( log ) std::cout <<" Flushing changes..."<<std::endl;
328  editor.flush();
329  dsc.commit();
330  ssc.commit();
331  return niovs;
332  }
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)
Definition: CondDBFetch.cc:294
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)
Definition: CondDBFetch.cc:294
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:282
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 61 of file Utils.h.

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

Referenced by CondDBESSource::CondDBESSource(), CondDBESSource::fillTagCollectionFromGT(), and validateTag().

61  {
62  std::string protocol = getConnectionProtocol( connectionString );
64  std::string databaseName("");
65  if( protocol == "sqlite" || protocol == "sqlite_file" || protocol == "sqlite_fip" ){
66  databaseName = connectionString.substr( protocol.size()+1 );
67  } else if ( protocol == "oracle" || protocol == "frontier" ){
68  size_t ptr = protocol.size()+1;
69  if( connectionString.substr( ptr,2 )!="//" ) throwException( "Connection string "+connectionString+
70  " is invalid format for technology \""+
71  protocol+"\".","parseConnectionString" );
72  ptr += 2;
73  size_t serviceEnd = connectionString.find( '/', ptr );
74  if( serviceEnd == std::string::npos ) throwException( "Connection string "+connectionString+" is invalid.",
75  "parseConnectionString" );
76  serviceName = connectionString.substr( ptr, serviceEnd-ptr );
77  ptr = serviceEnd+1;
78  databaseName = connectionString.substr( ptr );
79  } else throwException( "Technology "+protocol+" is not known.","parseConnectionString" );
80 
81  return std::make_tuple( protocol, serviceName, databaseName );
82  }
std::string getConnectionProtocol(const std::string &connectionString)
Definition: Utils.h:53
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 13 of file GTProxy.cc.

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

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

13  {
14  std::string pfn("");
15  std::string t(tag);
16  size_t pos = tag.rfind("[");
17  if( pos != std::string::npos && tag.size() >= pos+2 ){
18  if( tag[pos-1]=='@' && tag[tag.size()-1]==']' ) {
19  pfn = tag.substr( pos+1,tag.size()-pos-2 );
20  t = tag.substr( 0, pos-1 );
21  }
22  }
23  return std::make_pair( t, pfn );
24  }
tuple t
Definition: tree.py:139
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 282 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().

282  {
283  if( !container.size() ) return container.end();
284  auto p = std::upper_bound( container.begin(), container.end(), val, IOVComp() );
285  return (p!= container.begin()) ? p-1 : container.end();
286  }
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::GLOBAL_TAG::Table::create(), cond::persistency::TAG::Table::create(), cond::persistency::GLOBAL_TAG_MAP::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::OraGTSchema::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::GTProxy::load(), cond::persistency::IOVProxy::load(), cond::persistency::PayloadProxy< std::vector< cond::Time_t > >::loadPayload(), makeHash(), migrateTag(), cond::persistency::Query< Types...>::next(), cond::persistency::SessionImpl::openDb(), 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::Session::storePayload(), 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 446 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.

449  {
450  std::cout <<" Validating..."<<std::endl;
451  std::tuple<std::string,std::string,std::string> connPars = persistency::parseConnectionString( refSession.connectionString() );
452  std::string dbLabel = std::get<2>( connPars );
453  std::string tagLabel = dbLabel+"_"+refTag;
454  std::string refFile = tagLabel+"_ref.db";
455  std::string candFile = tagLabel+"_cand.db";
456  bool ret = compareTags( refTag, refSession, refFile, candTag, candSession, candFile );
457  if( ret ) {
458  boost::filesystem::path refF( refFile );
459  if( boost::filesystem::exists(refF) ) boost::filesystem::remove( refF );
460  boost::filesystem::path candF( candFile );
461  if( boost::filesystem::exists(candF) ) boost::filesystem::remove( candF );
462  }
463  return ret;
464  }
std::tuple< std::string, std::string, std::string > parseConnectionString(const std::string &connectionString)
Definition: Utils.h:61
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:386