CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FrontierProxy.cc
Go to the documentation of this file.
4 #include "RelationalAccess/IWebCacheControl.h"
7 //#include "CondCore/MetaDataService/interface/MetaDataNames.h"
9 
11 #include <string>
12 #include <vector>
13 
14 namespace cond{
16  public:
17  FrontierProxy();
19  void initialize( const DbConnection& connection) override;
20  std::string getRealConnectString( const std::string&userconnect ) const override;
21  std::string getRealConnectString( const std::string&userconnect, const std::string& transactionId ) const override;
22  bool isTransactional() const override { return false;}
23 
24  private:
25  //static unsigned int countslash(const std::string& input);
26  std::string makeRealConnectString( const std::string& initialConnection, const std::string& transactionId ) const ;
27  private:
29  std::vector<std::string> m_refreshtablelist;
30  };
31 }//ns cond
32 
33 
35  m_dbConnection(0),
36  m_refreshtablelist(){
37  m_refreshtablelist.reserve(10);
38  //table names for IOVSequence in the old POOL mapping
41  //table names for IOVSequence in ORA
42  //FIXME: do not use hard-coded names, ORA should provide them for a given container...
43  m_refreshtablelist.push_back("ORA_C_COND_IOVSEQUENCE");
44  m_refreshtablelist.push_back("ORA_C_COND_IOVSEQU_A0");
45  m_refreshtablelist.push_back("ORA_C_COND_IOVSEQU_A1");
46  // do not refesh tag table in production...
47  // m_refreshtablelist.push_back(cond::MetaDataNames::metadataTable());
48 }
49 
51  m_refreshtablelist.clear();
52 }
53 
54 namespace cond {
55 
56  unsigned int
58  unsigned int count=0;
59  std::string::size_type slashpos( 0 );
60  while( slashpos!=std::string::npos){
61  slashpos = input.find('/', slashpos );
62  if ( slashpos != std::string::npos ){
63  ++count;
64  // start next search after this word
65  slashpos += 1;
66  }
67  }
68  return count;
69  }
70 
73  const std::string& transactionId ) const {
74  std::string realConn = initialConnection;
75  // for testing
76  //std::string res = initialConnection;
77  std::string proto("frontier://");
78  std::string::size_type fpos=initialConnection.find(proto);
79  unsigned int nslash=countslash(initialConnection.substr(proto.size(),initialConnection.size()-fpos));
80  if(nslash==1){
81  edm::Service<edm::SiteLocalConfig> localconfservice;
82  if( !localconfservice.isAvailable() ){
83  throw cms::Exception("edm::SiteLocalConfigService is not available");
84  }
85  realConn=localconfservice->lookupCalibConnect(initialConnection);
86  //res=localconfservice->lookupCalibConnect(initialConnection);
87  }
88  if (!transactionId.empty()) {
89  size_t l = realConn.rfind('/');
90  realConn.insert(l,"(freshkey="+transactionId+')');
91  //size_t l = res.rfind('/');
92  //res.insert(l,"(freshkey="+transactionId+')');
93  }
94 
95  std::string refreshConnect;
96  std::string::size_type startRefresh = realConn.find("://");
97  if (startRefresh != std::string::npos){
98  startRefresh += 3;
99  }
100  std::string::size_type endRefresh=realConn.rfind("/", std::string::npos);
101  if (endRefresh == std::string::npos){
102  refreshConnect = realConn;
103  }else{
104  refreshConnect = realConn.substr(startRefresh, endRefresh-startRefresh);
105  if(refreshConnect.substr(0,1) != "("){
106  //if the connect string is not a complicated parenthesized string,
107  // an http:// needs to be at the beginning of it
108  refreshConnect.insert(0, "http://");
109  }
110  }
111  std::vector<std::string>::const_iterator ibeg=m_refreshtablelist.begin();
112  std::vector<std::string>::const_iterator iend=m_refreshtablelist.end();
113  for(std::vector<std::string>::const_iterator it=ibeg; it!=iend; ++it){
114  m_dbConnection->webCacheControl().refreshTable(refreshConnect,*it );
115  }
116 
117  //std::cout << "***** frontier connection string " << std::endl;
118  //std::cout << res << std::endl;
119  return realConn;
120  }
121 
122 }
123 
126  if( ! m_dbConnection ){
127  throwException("The Technology Proxy has not been initialized.","FrontierProxy::getRealConnectString");
128  }
129  return makeRealConnectString( userconnect, m_dbConnection->configuration().transactionId() );
130 }
131 
133 cond::FrontierProxy::getRealConnectString( const std::string&userconnect, const std::string& transId ) const{
134  if( ! m_dbConnection ){
135  throwException("The Technology Proxy has not been initialized.","FrontierProxy::getRealConnectString");
136  }
137  const std::string* tId = &transId;
138  if( transId.empty() ) tId = &m_dbConnection->configuration().transactionId();
139  return makeRealConnectString( userconnect, *tId );
140 }
141 
142 void
144  m_dbConnection = &connection;
145 }
146 
std::string getRealConnectString(const std::string &userconnect) const override
void initialize(const DbConnection &connection) override
std::string makeRealConnectString(const std::string &initialConnection, const std::string &transactionId) const
const DbConnection * m_dbConnection
virtual std::string const lookupCalibConnect(std::string const &input) const =0
uint16_t size_type
static std::string const input
Definition: EdmProvDump.cc:44
std::vector< std::string > m_refreshtablelist
bool isAvailable() const
Definition: Service.h:46
static std::string iovDataTableName()
Definition: IOVNames.h:13
unsigned int countslash(const std::string &input)
void throwException(std::string const &message, std::string const &methodName)
Definition: Exception.cc:17
static std::string iovTableName()
Definition: IOVNames.h:10
#define DEFINE_EDM_PLUGIN(factory, type, name)
bool isTransactional() const override