CMS 3D CMS Logo

Namespaces | Classes | Enumerations | Functions
cond::persistency Namespace Reference

Namespaces

 GLOBAL_TAG
 
 GLOBAL_TAG_MAP
 
 IOV
 
 PAYLOAD
 
 RUN_INFO
 
 TAG
 
 TAG_LOG
 

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
 
struct  IOVComp
 
class  IOVEditor
 
class  IOVEditorData
 
class  IOVProxy
 
class  IOVProxyData
 
struct  IOVRunComp
 
class  IOVSchema
 
struct  IOVTimeComp
 
class  IPayloadMigrationTable
 
class  IPayloadTable
 
class  IRunInfoSchema
 
class  IRunInfoTable
 
class  ITagLogTable
 
class  ITagMigrationTable
 
class  ITagTable
 
class  ITransaction
 
class  KeyList
 
class  PayloadProxy
 
class  PayloadProxy< cond::persistency::KeyList >
 
class  PayloadReader
 
class  Query
 
class  QueryIterator
 
class  RowBuffer
 
class  RunInfoEditor
 
class  RunInfoEditorData
 
class  RunInfoProxy
 
class  RunInfoProxyData
 
class  RunInfoSchema
 
class  Session
 
class  SessionImpl
 
class  TableDescription
 
class  Transaction
 
class  TransactionScope
 
class  UpdateBuffer
 

Enumerations

enum  DbAuthenticationSystem { UndefinedAuthentication =0, CondDbKey, CoralXMLFile }
 

Functions

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)
 
unsigned int countslash (const std::string &input)
 
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, std::shared_ptr< void > > fetch (const cond::Hash &payloadId, Session &session)
 
std::pair< std::string, std::shared_ptr< void > > fetchIfExists (const cond::Hash &payloadId, Session &session, bool &exists)
 
std::pair< std::string, std::shared_ptr< void > > fetchOne (const std::string &payloadTypeName, const cond::Binary &data, const cond::Binary &streamerInfo, std::shared_ptr< void > payloadPtr)
 
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, const std::string &signature)
 
std::string getConnectionProtocol (const std::string &connectionString)
 
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, const std::string &editingNote, bool override, bool serialize, bool forceInsert)
 
cond::Hash importPayload (Session &sourceSession, const cond::Hash &sourcePayloadId, Session &destSession, bool reserialize)
 
bool iovSorter (const std::tuple< cond::Time_t, cond::Hash, boost::posix_time::ptime > &f, const std::tuple< cond::Time_t, cond::Hash, boost::posix_time::ptime > &s)
 
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)
 
std::tuple< std::string, std::string, std::string > parseConnectionString (const std::string &connectionString)
 
std::string parseFipConnectionString (const std::string &fipConnect)
 
std::pair< std::string, std::string > parseTag (const std::string &tag)
 
template<typename T >
std::vector< T >::const_iterator search (const cond::Time_t &val, const std::vector< T > &container)
 
template<>
cond::Hash Session::storePayload< std::string > (const std::string &payload, const boost::posix_time::ptime &creationTime)
 
template<typename T , typename P >
void static_assert_is_same_decayed ()
 
void throwException (const std::string &message, const std::string &methodName)
 

Enumeration Type Documentation

Enumerator
UndefinedAuthentication 
CondDbKey 
CoralXMLFile 

Definition at line 28 of file ConnectionPool.h.

Function Documentation

std::string cond::persistency::convertoToOracleConnection ( const std::string &  input)
inline

Definition at line 116 of file Utils.h.

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

Referenced by CondDBESSource::CondDBESSource().

116  {
117 
118  // leave the connection string unmodified for sqlite
119  if( input.find("sqlite") == 0 || input.find("oracle") == 0) return input;
120 
121  //static const boost::regex trivial("oracle://(cms_orcon_adg|cms_orcoff_prep)/([_[:alnum:]]+?)");
122  static const boost::regex short_frontier("frontier://([[:alnum:]]+?)/([_[:alnum:]]+?)");
123  static const boost::regex long_frontier("frontier://((\\([-[:alnum:]]+?=[^\\)]+?\\))+)/([_[:alnum:]]+?)");
124  static const boost::regex long_frontier_serverurl("\\(serverurl=[^\\)]+?/([[:alnum:]]+?)\\)");
125 
126  static const std::map<std::string, std::string> frontierMap = {
127  {"PromptProd", "cms_orcon_adg"},
128  {"FrontierProd", "cms_orcon_adg"},
129  {"FrontierArc", "cms_orcon_adg"},
130  {"FrontierOnProd", "cms_orcon_adg"},
131  {"FrontierPrep", "cms_orcoff_prep"},
132  };
133 
134  boost::smatch matches;
135 
136  static const std::string technology("oracle://");
137  std::string service("");
138  std::string account("");
139 
140  bool match = false;
141  if (boost::regex_match(input, matches, short_frontier)){
142  service = matches[1];
143  account = matches[2];
144  match = true;
145  }
146 
147  if (boost::regex_match(input, matches, long_frontier)) {
148  std::string frontier_config(matches[1]);
149  boost::smatch matches2;
150  if (not boost::regex_search(frontier_config, matches2, long_frontier_serverurl))
151  throwException("No serverurl in matched long frontier","convertoToOracleConnection");
152  service = matches2[1];
153  account = matches[3];
154  match = true;
155  }
156 
157  if( !match ) throwException("Connection string "+input+" can't be converted to oracle connection.","convertoToOracleConnection");
158 
159  if( service == "FrontierArc" ){
160  size_t len = account.size()-5;
161  account = account.substr(0,len);
162  }
163 
164  auto it = frontierMap.find( service );
165  if( it == frontierMap.end() ) throwException("Connection string can't be converted.","convertoToOracleConnection");
166  service = it->second;
167 
168  return technology+service+"/"+account;
169  }
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:10
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
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 
)

Definition at line 150 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().

155  {
156  persistency::TransactionScope ssc( session.transaction() );
157  ssc.start( false );
158  std::cout <<" Loading source iov..."<<std::endl;
159  persistency::IOVProxy p = session.readIov( sourceTag, true );
160  if( p.loadedSize()==0 ) {
161  std::cout <<" Tag contains 0 iovs."<<std::endl;
162  return false;
163  } else {
164  std::cout <<" Iov size:"<<p.loadedSize()<<" timeType:"<<p.timeType()<<" payloadObjectType=\""<<p.payloadObjectType()<<"\""<<std::endl;
165  }
166 
167  auto iiov = p.find( sourceSince );
168  if( iiov == p.end() ){
169  std::cout <<"ERROR: No Iov valid found for target time "<<sourceSince<<std::endl;
170  return false;
171  }
172 
173  persistency::IOVEditor editor;
174  if( session.existsIov( destTag ) ){
175  if( !description.empty() ) std::cout <<" INFO. Destination Tag "<<destTag<<" already exists. Provided description will be ignored."<<std::endl;
176  editor = session.editIov( destTag );
177  if( editor.timeType() != p.timeType() )
178  throwException( "TimeType of the destination tag does not match with the source tag timeType.", "importIovs");
179  if( editor.payloadType() != p.payloadObjectType() )
180  throwException( "PayloadType of the destination tag does not match with the source tag payloadType.", "importIovs");
181  } else {
182  editor = session.createIov( p.payloadObjectType(), destTag, p.timeType(), p.synchronizationType() );
183  if( description.empty() ) editor.setDescription( "Created copying iovs from tag "+sourceTag );
184  else editor.setDescription( description );
185  }
186 
187  editor.insert( destSince, (*iiov).payloadId );
188 
189  std::cout <<" Flushing changes..."<<std::endl;
190  editor.flush();
191  ssc.commit();
192  return true;
193  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
unsigned int cond::persistency::countslash ( const std::string &  input)

Definition at line 13 of file DbConnectionString.cc.

References KineDebug3::count().

Referenced by getConnectionParams().

13  {
14  unsigned int count = 0;
15  std::string::size_type slashpos( 0 );
16  while( slashpos != std::string::npos ) {
17  slashpos = input.find('/', slashpos );
18  if( slashpos != std::string::npos ) {
19  ++count;
20  // start next search after this word
21  slashpos += 1;
22  }
23  }
24  return count;
25  }
uint16_t size_type
static std::string const input
Definition: EdmProvDump.cc:44
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 204 of file DbCore.h.

References findQualityFiles::size.

204  {
205  table.insertColumn( columnName, AttributeTypeName<T>()(), size );
206  if( notNull ) table.setNotNullConstraint( columnName );
207  }
size
Write out results.
std::pair< std::string, std::shared_ptr< void > > cond::persistency::fetch ( const cond::Hash payloadId,
Session session 
)

Definition at line 326 of file CondDBFetch.cc.

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

Referenced by importPayload().

326  {
327  std::shared_ptr<void> payloadPtr;
329  cond::Binary streamerInfo;
330  std::string payloadTypeName;
331  bool found = session.fetchPayloadData( payloadId, payloadTypeName, data, streamerInfo );
332  if( !found ) throwException( "Payload with id "+boost::lexical_cast<std::string>(payloadId)+" has not been found in the database.","fetch" );
333  return fetchOne(payloadTypeName, data, streamerInfo, payloadPtr );
334  }
std::pair< std::string, std::shared_ptr< void > > fetchOne(const std::string &payloadTypeName, const cond::Binary &data, const cond::Binary &streamerInfo, std::shared_ptr< void > payloadPtr)
Definition: CondDBFetch.cc:24
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::pair<std::string,std::shared_ptr<void> > cond::persistency::fetchIfExists ( const cond::Hash payloadId,
Session session,
bool &  exists 
)

Definition at line 25 of file CondDBImport.cc.

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

25  {
26  std::shared_ptr<void> payloadPtr;
28  cond::Binary streamerInfo;
29  std::string payloadTypeName;
30  exists = session.fetchPayloadData( payloadId, payloadTypeName, data, streamerInfo );
31  if( exists ) {
32  return fetchOne(payloadTypeName, data, streamerInfo, payloadPtr );
33  } else return std::make_pair( std::string(""), std::shared_ptr<void>() );
34  }
std::pair< std::string, std::shared_ptr< void > > fetchOne(const std::string &payloadTypeName, const cond::Binary &data, const cond::Binary &streamerInfo, std::shared_ptr< void > payloadPtr)
Definition: CondDBFetch.cc:24
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::pair< std::string, std::shared_ptr< void > > cond::persistency::fetchOne ( const std::string &  payloadTypeName,
const cond::Binary data,
const cond::Binary streamerInfo,
std::shared_ptr< void >  payloadPtr 
)

Definition at line 24 of file CondDBFetch.cc.

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

Referenced by fetch(), and fetchIfExists().

24  {
25 
26  bool match = false;
28  FETCH_PAYLOAD_CASE( std::vector<unsigned long long> )
174  FETCH_PAYLOAD_CASE( JME::JetResolutionObject )
213  FETCH_PAYLOAD_CASE( l1t::CaloParams )
214  FETCH_PAYLOAD_CASE( l1t::CaloConfig )
229  FETCH_PAYLOAD_CASE( lumi::LumiSectionData )
234  FETCH_PAYLOAD_CASE( PhysicsTools::Calibration::MVAComputerContainer )
243  //FETCH_PAYLOAD_CASE( PerformancePayload )
293  FETCH_PAYLOAD_CASE( cond::BaseKeyed )
304 
305  //
306  if( payloadTypeName == "PhysicsTools::Calibration::Histogram3D<double,double,double,double>" ){
307  auto payload = deserialize<PhysicsTools::Calibration::Histogram3D<double,double,double,double> >(payloadTypeName, data, streamerInfo );
308  payloadPtr = payload;
309  match = true;
310  }
311  if( payloadTypeName == "PhysicsTools::Calibration::Histogram2D<double,double,double>" ){
312  auto payload = deserialize<PhysicsTools::Calibration::Histogram2D<double,double,double> >(payloadTypeName, data, streamerInfo );
313  payloadPtr = payload;
314  match = true;
315  }
316  if( payloadTypeName == "std::vector<unsignedlonglong,std::allocator<unsignedlonglong>>" ){
317  auto payload = deserialize<std::vector<unsigned long long> >( payloadTypeName, data, streamerInfo );
318  payloadPtr = payload;
319  match = true;
320  }
321 
322  if( ! match ) throwException( "Payload type \""+payloadTypeName+"\" is unknown.","fetch" );
323  return std::make_pair( payloadTypeName, payloadPtr );
324  }
Definition: ESGain.h:7
delete x;
Definition: CaloConfig.h:22
#define FETCH_PAYLOAD_CASE(TYPENAME)
Definition: CondDBFetch.cc:3
Definition: DTT0.h:53
payload
payload postfix for testing
Histogram3D< double > HistogramD3D
Definition: Histogram3D.h:187
QGLikelihoodObject containing valid range and entries with category and histogram (mean is not used a...
Channel-mask mapping.
Category structure: ranges associated with QGLikelihood histograms.
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
Definition: plugin.cc:24
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
if(dp >Float(M_PI)) dp-
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.
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
The mapping between FramePosition and ROCInfo.
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,
const std::string &  signature 
)

Definition at line 39 of file DbConnectionString.cc.

References countslash(), getConnectionProtocol(), edm::Service< T >::isAvailable(), checklumidiff::l, edm::SiteLocalConfig::lookupCalibConnect(), parseFipConnectionString(), alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, and cond::throwException().

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

41  {
42  if( connectionString.empty() ) cond::throwException( "The connection string is empty.", "getConnectionParams" );
43  std::string protocol = getConnectionProtocol( connectionString );
44  std::string finalConn = connectionString;
45  std::string refreshConn( "" );
46  if( protocol == "frontier" ) {
47  std::string protocol( "frontier://" );
48  std::string::size_type fpos = connectionString.find( protocol );
49  unsigned int nslash = countslash( connectionString.substr( protocol.size(), connectionString.size() - fpos ) );
50  if( nslash==1 ) {
51  edm::Service<edm::SiteLocalConfig> localconfservice;
52  if( !localconfservice.isAvailable() ) {
53  cond::throwException( "edm::SiteLocalConfigService is not available", "getConnectionParams" );
54  }
55  finalConn = localconfservice->lookupCalibConnect( connectionString );
56  }
57  if( !transactionId.empty() ) {
58  size_t l = finalConn.rfind('/');
59  finalConn.insert( l, "(freshkey="+transactionId+')' );
60  }
61 
62  //When the signature parameter is set to sig, FroNTier requests that the server sends digital signatures on every response.
63  //We test here that the signature string, if defined, is actually set to sig, otherwise we throw an exception
64  std::string signatureParameter( "sig" );
65  if( !signature.empty() ) {
66  if( signature.compare( signatureParameter ) == 0 ) {
67  std::string::size_type s = finalConn.rfind('/');
68  finalConn.insert( s, "(security="+signature+')' );
69  } else {
70  cond::throwException( "The FroNTier security option is invalid.", "getConnectionParams" );
71  }
72  }
73 
74  std::string::size_type startRefresh = finalConn.find( "://" );
75  if( startRefresh != std::string::npos ) {
76  startRefresh += 3;
77  }
78  std::string::size_type endRefresh=finalConn.rfind( "/", std::string::npos );
79  if( endRefresh == std::string::npos ) {
80  refreshConn = finalConn;
81  } else {
82  refreshConn = finalConn.substr( startRefresh, endRefresh - startRefresh );
83  if( refreshConn.substr( 0, 1 ) != "(" ) {
84  //if the connect string is not a complicated parenthesized string,
85  // an http:// needs to be at the beginning of it
86  refreshConn.insert( 0, "http://" );
87  }
88  }
89  } else if( protocol == "sqlite_fip" ) {
90  finalConn = parseFipConnectionString( connectionString );
91  }
92  return std::make_pair( finalConn, refreshConn );
93  }
virtual std::string const lookupCalibConnect(std::string const &input) const =0
std::string getConnectionProtocol(const std::string &connectionString)
Definition: Utils.h:85
std::string parseFipConnectionString(const std::string &fipConnect)
uint16_t size_type
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:21
bool isAvailable() const
Definition: Service.h:46
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined signature
Definition: Activities.doc:4
unsigned int countslash(const std::string &input)
std::string cond::persistency::getConnectionProtocol ( const std::string &  connectionString)
inline

Definition at line 85 of file Utils.h.

References AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

Referenced by getConnectionParams(), and parseConnectionString().

85  {
86  size_t techEnd = connectionString.find( ':' );
87  if( techEnd == std::string::npos ) throwException( "Could not resolve the connection protocol on "+connectionString+".",
88  "getConnectionProtocol" );
89  std::string technology = connectionString.substr(0,techEnd);
90  return technology;
91  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
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 cmsStageWithFailover::destination, IMPORT_PAYLOAD_CASE, match(), MuonAssociatorByHits_cfi::obj, AlCaHLTBitMon_QueryRunRegistry::string, and throwException().

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> )
186  IMPORT_PAYLOAD_CASE( JME::JetResolutionObject )
225  IMPORT_PAYLOAD_CASE( l1t::CaloParams )
226  IMPORT_PAYLOAD_CASE( l1t::CaloConfig )
241  if( inputTypeName == "L1TriggerKeyList" ){
242  match = true;
243  throwException( "Import of \"L1TriggerKeyList\" type payloads is not supported.","import" );
244  }
245  //IMPORT_PAYLOAD_CASE( L1TriggerKeyList )
253  IMPORT_PAYLOAD_CASE( PhysicsTools::Calibration::MVAComputerContainer )
260  //IMPORT_PAYLOAD_CASE( PerformancePayload )
312  IMPORT_PAYLOAD_CASE( cond::BaseKeyed )
322  if( inputTypeName == "PhysicsTools::Calibration::Histogram3D<double,double,double,double>" ){
323  match = true;
325  payloadId = destination.storePayload( obj, boost::posix_time::microsec_clock::universal_time() );
326  }
327  if( inputTypeName == "PhysicsTools::Calibration::Histogram2D<double,double,double>" ){
328  match = true;
330  payloadId = destination.storePayload( obj, boost::posix_time::microsec_clock::universal_time() );
331  }
332  if( inputTypeName == "std::vector<unsignedlonglong,std::allocator<unsignedlonglong>>" ){
333  match = true;
334  const std::vector<unsigned long long>& obj = *static_cast<const std::vector<unsigned long long>*>( inputPtr );
335  payloadId = destination.storePayload( obj, boost::posix_time::microsec_clock::universal_time() );
336  }
337 
338  if( ! match ) throwException( "Payload type \""+inputTypeName+"\" is unknown.","import" );
339  }
340  return payloadId;
341  }
Definition: ESGain.h:7
delete x;
Definition: CaloConfig.h:22
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
Channel-mask mapping.
std::string Hash
Definition: Types.h:45
Category structure: ranges associated with QGLikelihood histograms.
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
Definition: plugin.cc:24
if(dp >Float(M_PI)) dp-
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.
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
The mapping between FramePosition and ROCInfo.
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,
const std::string &  editingNote,
bool  override,
bool  serialize,
bool  forceInsert 
)

Definition at line 37 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(), reco::dp, cond::persistency::Session::editIov(), idDealer::editor, end, cond::persistency::IOVProxy::end(), cond::persistency::Session::existsDatabase(), cond::persistency::Session::existsIov(), cond::persistency::IOVProxy::find(), cond::persistency::IOVEditor::flush(), cond::persistency::IOVProxy::getInterval(), importPayload(), cond::persistency::IOVEditor::insert(), cond::persistency::Session::iovProxy(), cond::persistency::IOVProxy::loadedSize(), cond::persistency::IOVProxy::loadRange(), AlCaHLTBitMon_ParallelJobs::p, cond::persistency::IOVProxy::payloadObjectType(), cond::persistency::IOVEditor::payloadType(), cond::persistency::Session::readIov(), cond::persistency::IOVEditor::setDescription(), ntuplemaker::since, createPayload::skip, cond::persistency::TransactionScope::start(), cond::persistency::IOVProxy::synchronizationType(), throwException(), cond::persistency::IOVEditor::timeType(), cond::persistency::IOVProxy::timeType(), and cond::persistency::Session::transaction().

47  {
48  persistency::TransactionScope ssc( sourceSession.transaction() );
49  ssc.start();
50  std::cout <<" Loading source iov..."<<std::endl;
51  persistency::IOVProxy p = sourceSession.readIov( sourceTag, true );
52  if( p.loadedSize()==0 ) {
53  std::cout <<" Tag contains 0 iovs."<<std::endl;
54  return 0;
55  } else {
56  std::cout <<" Iov size:"<<p.loadedSize()<<" timeType:"<<p.timeType()<<" payloadObjectType=\""<<p.payloadObjectType()<<"\""<<std::endl;
57  }
58  if( (*p.begin()).since > begin ) begin = (*p.begin()).since;
59  if( end < begin ) {
60  std::cout <<" No Iov in the selected range."<<std::endl;
61  return 0;
62  }
63  persistency::IOVEditor editor;
64  persistency::TransactionScope dsc( destSession.transaction() );
65  dsc.start( false );
66  bool exists = false;
67  if( !destSession.existsDatabase() ) {
68  destSession.createDatabase();
69  } else {
70  exists = destSession.existsIov( destTag );
71  }
72  persistency::IOVProxy dp;
73  if( exists ){
74  dp = destSession.readIov( destTag );
75  editor = destSession.editIov( destTag );
76  if( !description.empty() ) std::cout <<" INFO. Destination Tag "<<destTag<<" already exists. Provided description will be ignored."<<std::endl;
77  if( editor.timeType() != p.timeType() )
78  throwException( "TimeType of the destination tag does not match with the source tag timeType.", "importIovs");
79  if( editor.payloadType() != p.payloadObjectType() )
80  throwException( "PayloadType of the destination tag does not match with the source tag payloadType.", "importIovs");
81  } else {
82  editor = destSession.createIov( p.payloadObjectType(), destTag, p.timeType(), p.synchronizationType() );
83  if( description.empty() ) editor.setDescription( "Created copying tag "+sourceTag+" from "+sourceSession.connectionString() );
84  else editor.setDescription( description );
85  }
86  size_t niovs = 0;
87  std::set<cond::Hash> pids;
88  std::set<cond::Time_t> sinces;
89  auto iiov = p.find( begin );
90  cond::Time_t newSince = begin;
91  while( iiov != p.end() ){
92  // skip duplicated sinces
93  if( sinces.find( newSince ) != sinces.end() ){
94  std::cout <<" WARNING. Skipping duplicated since="<<newSince<<std::endl;
95  continue;
96  }
97  // make sure that we import the payload _IN_USE_
98  auto usedIov = p.getInterval( newSince );
99  cond::Hash ph = importPayload( sourceSession, usedIov.payloadId, destSession, reserialize );
100  pids.insert( ph );
101  bool skip = false;
102  if( exists ){
103  // don't insert if the same entry is already there...
104  auto ie = dp.find( newSince );
105  if( ie != dp.end() ){
106  if( ((*ie).since == newSince) && ((*ie).payloadId == usedIov.payloadId) ) {
107  skip = true;
108  }
109  }
110  }
111  if( !skip ){
112  editor.insert( newSince, ph );
113  sinces.insert( newSince );
114  niovs++;
115  if( niovs && (niovs%1000==0) ) std::cout <<" Total of iov inserted: "<<niovs<<" payloads: "<<pids.size()<<std::endl;
116  }
117  iiov++;
118  if( iiov == p.end() || (*iiov).since > end ){
119  break;
120  } else {
121  newSince = (*iiov).since;
122  }
123  }
124  if( exists && override ){
125  std::cout <<" Adding overlying iovs..."<<std::endl;
126  persistency::IOVProxy dp;
127  dp = destSession.iovProxy();
128  dp.loadRange( destTag, begin, end );
129  std::set<cond::Time_t> extraSinces;
130  for( auto iov : dp ){
131  auto siov = p.getInterval( iov.since );
132  if( siov.since != iov.since ) {
133  if( extraSinces.find( iov.since )==extraSinces.end() ){
134  editor.insert( iov.since, siov.payloadId );
135  extraSinces.insert( iov.since );
136  niovs++;
137  if( niovs && (niovs%1000==0) ) std::cout <<" Total of iov inserted: "<<niovs<<" payloads: "<<pids.size()<<std::endl;
138  }
139  }
140  }
141  }
142  std::cout <<" Total of iov inserted: "<<niovs<<" payloads: "<<pids.size()<<std::endl;
143  std::cout <<" Flushing changes..."<<std::endl;
144  editor.flush( editingNote, forceInsert );
145  dsc.commit();
146  ssc.commit();
147  return niovs;
148  }
unsigned long long Time_t
Definition: Time.h:16
std::string Hash
Definition: Types.h:45
#define end
Definition: vmac.h:37
cond::Hash importPayload(Session &sourceSession, const cond::Hash &sourcePayloadId, Session &destSession, bool reserialize)
Definition: CondDBTools.cc:16
auto dp
Definition: deltaR.h:22
#define begin
Definition: vmac.h:30
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
cond::Hash cond::persistency::importPayload ( Session sourceSession,
const cond::Hash sourcePayloadId,
Session destSession,
bool  reserialize 
)

Definition at line 16 of file CondDBTools.cc.

References fetch(), cond::persistency::Session::fetchPayloadData(), cmsPerfSuiteHarvest::now, Phase2ITPixelClusterizer_cfi::payloadType, cond::persistency::Session::storePayloadData(), AlCaHLTBitMon_QueryRunRegistry::string, and cond::throwException().

Referenced by importIovs().

16  {
17  if( reserialize ){
18  std::pair<std::string,std::shared_ptr<void> > readBackPayload = fetch( sourcePayloadId, sourceSession );
19  return import( sourceSession, sourcePayloadId, readBackPayload.first, readBackPayload.second.get(), destSession );
20  } else {
22  cond::Binary payloadData;
23  cond::Binary streamerInfoData;
24  if( !sourceSession.fetchPayloadData( sourcePayloadId, payloadType, payloadData, streamerInfoData ) ){
25  cond::throwException( "Payload with hash"+sourcePayloadId+" has not been found in the source database.","importPayload");
26  }
27  boost::posix_time::ptime now = boost::posix_time::microsec_clock::universal_time();
28  return destSession.storePayloadData( payloadType, std::make_pair( payloadData, streamerInfoData ),now );
29  }
30  }
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:21
std::pair< std::string, std::shared_ptr< void > > fetch(const cond::Hash &payloadId, Session &session)
Definition: CondDBFetch.cc:326
bool cond::persistency::iovSorter ( const std::tuple< cond::Time_t, cond::Hash, boost::posix_time::ptime > &  f,
const std::tuple< cond::Time_t, cond::Hash, boost::posix_time::ptime > &  s 
)

Definition at line 164 of file IOVEditor.cc.

References f.

Referenced by cond::persistency::IOVEditor::flush().

164  {
165  return std::get<0>(f) < std::get<0>(s);
166  }
double f[11][100]
template<typename T , typename Arg1 >
bool cond::persistency::is_same_any ( )

Definition at line 209 of file DbCore.h.

References relativeConstraints::value.

template<typename T , typename Arg1 , typename Arg2 , typename... Args>
bool cond::persistency::is_same_any ( )

Definition at line 213 of file DbCore.h.

213  {
214  return is_same_any<T, Arg1>() || is_same_any<T, Arg2, Args...>();
215  };
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, mps_fire::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  }
size_t size() const
Definition: Binary.cc:54
const void * data() const
Definition: Binary.cc:45
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::tuple<std::string,std::string,std::string> cond::persistency::parseConnectionString ( const std::string &  connectionString)
inline

Definition at line 93 of file Utils.h.

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

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

93  {
94  std::string protocol = getConnectionProtocol( connectionString );
96  std::string databaseName("");
97  if( protocol == "sqlite" || protocol == "sqlite_file" || protocol == "sqlite_fip" ){
98  databaseName = connectionString.substr( protocol.size()+1 );
99  } else if ( protocol == "oracle" || protocol == "frontier" ){
100  size_t ptr = protocol.size()+1;
101  if( connectionString.substr( ptr,2 )!="//" ) throwException( "Connection string "+connectionString+
102  " is invalid format for technology \""+
103  protocol+"\".","parseConnectionString" );
104  ptr += 2;
105  size_t serviceEnd = connectionString.find( '/', ptr );
106  if( serviceEnd == std::string::npos ) throwException( "Connection string "+connectionString+" is invalid.",
107  "parseConnectionString" );
108  serviceName = connectionString.substr( ptr, serviceEnd-ptr );
109  ptr = serviceEnd+1;
110  databaseName = connectionString.substr( ptr );
111  } else throwException( "Technology "+protocol+" is not known.","parseConnectionString" );
112 
113  return std::make_tuple( protocol, serviceName, databaseName );
114  }
std::string getConnectionProtocol(const std::string &connectionString)
Definition: Utils.h:85
static const std::string serviceName
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::string cond::persistency::parseFipConnectionString ( const std::string &  fipConnect)

Definition at line 27 of file DbConnectionString.cc.

References connect(), edm::FileInPath::fullPath(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getConnectionParams().

27  {
28  std::string connect( "sqlite_file:" );
29  std::string::size_type pos = fipConnect.find( ':' );
30  std::string fipLocation = fipConnect.substr( pos+1 );
31  edm::FileInPath fip( fipLocation );
32  connect.append( fip.fullPath() );
33  return connect;
34  }
uint16_t size_type
edm::Handle< T > connect(const T *&ptr, edm::EDGetTokenT< T > token, const edm::Event &evt)
std::pair< std::string, std::string > cond::persistency::parseTag ( const std::string &  tag)

Definition at line 13 of file GTProxy.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and lumiQTWidget::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  }
template<typename T >
std::vector<T>::const_iterator cond::persistency::search ( const cond::Time_t val,
const std::vector< T > &  container 
)
template<>
cond::Hash cond::persistency::Session::storePayload< std::string > ( const std::string &  payload,
const boost::posix_time::ptime &  creationTime 
)
inline

Definition at line 202 of file Session.h.

References MillePedeFileConverter_cfg::e, cond::serialize(), AlCaHLTBitMon_QueryRunRegistry::string, throwException(), and cms::Exception::what().

202  {
203 
204  std::string payloadObjectType("std::string");
205  cond::Hash ret;
206  try{
207  ret = storePayloadData( payloadObjectType, serialize( payload ), creationTime );
208  } catch ( const cond::persistency::Exception& e ){
209  std::string em(e.what());
210  throwException( "Payload of type "+payloadObjectType+" could not be stored. "+em,"Session::storePayload");
211  }
212  return ret;
213  }
virtual char const * what() const
Definition: Exception.cc:141
Base exception class for the object to relational access.
Definition: Exception.h:11
std::pair< Binary, Binary > serialize(const T &payload)
Definition: Serialization.h:62
payload
payload postfix for testing
std::string Hash
Definition: Types.h:45
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
template<typename T , typename P >
void cond::persistency::static_assert_is_same_decayed ( )
inline

Definition at line 81 of file DbCore.h.

References data, cond::Binary::get(), hcalTTPDigis_cfi::id, StGenEvtProducer_cfi::init, dataset::name, AlCaHLTBitMon_QueryRunRegistry::string, cond::synchronizationTypeNames(), cond::time::timeTypeName(), and relativeConstraints::value.

81  {
82  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" );
83  };
type
Definition: HCALResponse.h:21
Definition: value.py:1
void cond::persistency::throwException ( const std::string &  message,
const std::string &  methodName 
)

Definition at line 14 of file Exception.cc.

References cond::persistency::Exception::Exception().

Referenced by cond::CredentialStore::addUser(), L1CondDBPayloadWriterExt::analyze(), L1CondDBIOVWriterExt::analyze(), L1CondDBIOVWriter::analyze(), L1CondDBPayloadWriter::analyze(), cond::service::PoolDBOutputService::appendSinceTime(), MillePedeAlignmentAlgorithm::beginRun(), cond::persistency::RunInfoEditor::checkTransaction(), cond::persistency::GTEditor::checkTransaction(), cond::persistency::IOVEditor::checkTransaction(), cond::persistency::RunInfoProxy::checkTransaction(), cond::persistency::GTProxy::checkTransaction(), cond::persistency::IOVProxy::checkTransaction(), convertoToOracleConnection(), copyIov(), cond::persistency::Session::coralSession(), cond::persistency::GLOBAL_TAG::Table::create(), cond::persistency::TAG::Table::create(), cond::persistency::RUN_INFO::Table::create(), cond::persistency::GLOBAL_TAG_MAP::Table::create(), cond::persistency::PAYLOAD::Table::create(), cond::persistency::IOV::Table::create(), cond::persistency::TAG_LOG::Table::create(), cond::persistency::Session::createGlobalTag(), cond::persistency::Session::createIov(), cond::persistency::Session::createIovForPayload(), cond::service::PoolDBOutputService::createNewIOV(), cond::persistency::Query< Types... >::currentRow(), fetch(), fetchOne(), cond::persistency::Session::fetchPayload(), cond::persistency::RunInfoEditor::flush(), cond::persistency::GTEditor::flush(), cond::persistency::IOVEditor::flush(), cond::persistency::KeyList::get(), cond::persistency::RunInfoProxy::get(), getConnectionProtocol(), cond::persistency::IOVProxy::getInterval(), cond::persistency::IOVProxy::getMetadata(), cond::persistency::Session::getRunInfo(), import(), importIovs(), MillePedeAlignmentAlgorithm::initialize(), cond::persistency::GTEditor::load(), cond::persistency::GTProxy::load(), cond::persistency::IOVProxy::load(), cond::persistency::PayloadProxy< std::vector< cond::Time_t > >::loadPayload(), cond::persistency::IOVProxy::loadRange(), makeHash(), cond::persistency::Query< Types... >::next(), cond::persistency::SessionImpl::openDb(), cond::persistency::SessionImpl::openGTDb(), cond::persistency::SessionImpl::openIovDb(), cond::persistency::SessionImpl::openRunInfoDb(), cond::persistency::PayloadProxy< std::vector< cond::Time_t > >::operator()(), cond::persistency::GetFromRow< std::array< char, n > >::operator()(), parseConnectionString(), Session::storePayload< std::string >(), cond::CredentialStore::setPermission(), cond::CredentialStore::startSession(), cond::persistency::SessionImpl::startTransaction(), cond::persistency::Session::storePayload(), cond::CredentialStore::updateConnection(), cond::service::PoolDBOutputService::writeOne(), and cond::persistency::Exception::~Exception().

15  {
16  throw Exception( message, methodName );
17  }