CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
cond::persistency::ConnectionPool Class Reference

#include <ConnectionPool.h>

Public Member Functions

void configure ()
 
 ConnectionPool ()
 
std::shared_ptr< coral::ISessionProxy > createCoralSession (const std::string &connectionString, bool writeCapable=false)
 
Session createReadOnlySession (const std::string &connectionString, const std::string &transactionId)
 
Session createSession (const std::string &connectionString, bool writeCapable=false)
 
bool isLoggingEnabled () const
 
void setAuthenticationPath (const std::string &p)
 
void setAuthenticationSystem (int authSysCode)
 
void setConnectionTimeout (int seconds)
 
void setFrontierSecurity (const std::string &signature)
 
void setLogDestination (Logger &logger)
 
void setLogging (bool flag)
 
void setMessageVerbosity (coral::MsgLevel level)
 
void setParameters (const edm::ParameterSet &connectionPset)
 
 ~ConnectionPool ()
 

Private Member Functions

void configure (coral::IConnectionServiceConfiguration &coralConfig)
 
std::shared_ptr< coral::ISessionProxy > createCoralSession (const std::string &connectionString, const std::string &transactionId, bool writeCapable=false)
 
Session createSession (const std::string &connectionString, const std::string &transactionId, bool writeCapable=false)
 

Private Attributes

std::string m_authenticationService = std::string("")
 
std::string m_authPath = std::string("")
 
int m_authSys = 0
 
int m_connectionTimeout = 0
 
std::string m_frontierSecurity = std::string("")
 
bool m_loggingEnabled = false
 
coral::MsgLevel m_messageLevel = coral::Error
 
CoralMsgReporterm_msgReporter = nullptr
 
cond::CoralServiceManagerm_pluginManager = nullptr
 

Detailed Description

Definition at line 35 of file ConnectionPool.h.

Constructor & Destructor Documentation

◆ ConnectionPool()

cond::persistency::ConnectionPool::ConnectionPool ( )

Definition at line 26 of file ConnectionPool.cc.

References configure(), m_msgReporter, and m_pluginManager.

26  {
28  m_msgReporter = new CoralMsgReporter;
29  coral::MessageStream::installMsgReporter(m_msgReporter);
30  configure();
31  }
cond::CoralServiceManager * m_pluginManager

◆ ~ConnectionPool()

cond::persistency::ConnectionPool::~ConnectionPool ( )

Definition at line 33 of file ConnectionPool.cc.

References m_pluginManager.

33 { delete m_pluginManager; }
cond::CoralServiceManager * m_pluginManager

Member Function Documentation

◆ configure() [1/2]

void cond::persistency::ConnectionPool::configure ( )

Definition at line 129 of file ConnectionPool.cc.

Referenced by BeamSpotRcdPrinter::BeamSpotRcdPrinter(), CondDBESSource::CondDBESSource(), l1t::DataManager::connect(), ConnectionPool(), popcon::L1RPCHwConfigSourceHandler::ConnectOnlineDB(), popcon::RPCEMapSourceHandler::ConnectOnlineDB(), FastSiPixelFEDChannelContainerFromQuality::FastSiPixelFEDChannelContainerFromQuality(), FillInfoPopConSourceHandler::getNewObjects(), LHCInfoPopConSourceHandler::getNewObjects(), DTLVStatusHandler::getNewObjects(), DTHVStatusHandler::getNewObjects(), DTUserKeyedConfigHandler::getNewObjects(), DTKeyedConfigHandler::getNewObjects(), LHCInfoPerLSPopConSourceHandler::getNewObjects(), LHCInfoPerFillPopConSourceHandler::getNewObjects(), popcon::PopCon::initialize(), SiStripCoralIface::initialize(), L1ConfigOnlineProdBase< L1HtMissScaleRcd, L1CaloEtScale >::L1ConfigOnlineProdBase(), L1ConfigOnlineProdBaseExt< L1TCaloParamsO2ORcd, l1t::CaloParams >::L1ConfigOnlineProdBaseExt(), popcon::PopConBTransitionSourceHandler< T >::PopConBTransitionSourceHandler(), popcon::PopConESTransitionSourceHandler< T >::PopConESTransitionSourceHandler(), RunInfoRead::readData(), RPCDCCLinkMapHandler::RPCDCCLinkMapHandler(), RPCLBLinkMapHandler::RPCLBLinkMapHandler(), SiStripDetVOffHandler::SiStripDetVOffHandler(), SiStripDetVOffPrinter::SiStripDetVOffPrinter(), SiStripDetVOffTkMapPlotter::SiStripDetVOffTkMapPlotter(), SiStripDetVOffTrendPlotter::SiStripDetVOffTrendPlotter(), SiStripPayloadHandler< SiStripPayload >::SiStripPayloadHandler(), and SiStripPayloadMapTableCreator::SiStripPayloadMapTableCreator().

129  {
130  coral::ConnectionService connServ;
131  configure(connServ.configuration());
132  }

◆ configure() [2/2]

void cond::persistency::ConnectionPool::configure ( coral::IConnectionServiceConfiguration &  coralConfig)
private

Definition at line 76 of file ConnectionPool.cc.

References lumi_dqm_sourceclient-live_cfg::authPath, cond::auth::COND_AUTH_PATH, cond::auth::COND_AUTH_PATH_PROPERTY, cond::auth::COND_AUTH_SYS, cond::persistency::CondDbKey, cond::persistency::CoralXMLFile, instance, m_authenticationService, m_authPath, m_authSys, m_connectionTimeout, m_messageLevel, m_msgReporter, m_pluginManager, cond::persistency::CoralMsgReporter::setOutputLevel(), and AlCaHLTBitMon_QueryRunRegistry::string.

76  {
77  coralConfig.disablePoolAutomaticCleanUp();
78  coralConfig.disableConnectionSharing();
79  coralConfig.setConnectionTimeOut(m_connectionTimeout);
80  // message streaming
81  coral::MessageStream::setMsgVerbosity(m_messageLevel);
83 
84  // authentication
85  m_authenticationService = std::string("CORAL/Services/EnvironmentAuthenticationService");
87  // authentication
88  if (authPath.empty()) {
89  // first try to check the env...
90  const char* authEnv = std::getenv(cond::auth::COND_AUTH_PATH);
91  if (authEnv) {
92  authPath += authEnv;
93  }
94  }
95  int authSys = m_authSys;
96  // first attempt, look at the env...
97  const char* authSysEnv = std::getenv(cond::auth::COND_AUTH_SYS);
98  if (authSysEnv) {
99  authSys = ::atoi(authSysEnv);
100  }
101  if (authSys != CondDbKey && authSys != CoralXMLFile) {
102  // take the default
103  authSys = CondDbKey;
104  }
105  std::string servName("");
106  if (authSys == CondDbKey) {
107  if (authPath.empty()) {
108  const char* authEnv = std::getenv("HOME");
109  if (authEnv) {
110  authPath += authEnv;
111  }
112  }
113  servName = "COND/Services/RelationalAuthenticationService";
114  } else if (authSys == CoralXMLFile) {
115  if (authPath.empty()) {
116  authPath = ".";
117  }
118  servName = "COND/Services/XMLAuthenticationService";
119  }
120  if (!authPath.empty()) {
121  m_authenticationService = servName;
122  coral::Context::instance().PropertyManager().property(cond::auth::COND_AUTH_PATH_PROPERTY)->set(authPath);
124  }
125 
126  coralConfig.setAuthenticationService(m_authenticationService);
127  }
static PFTauRenderPlugin instance
static constexpr const char *const COND_AUTH_PATH
Definition: Auth.h:11
static constexpr const char *const COND_AUTH_PATH_PROPERTY
Definition: Auth.h:50
void setOutputLevel(coral::MsgLevel lvl) override
Modify output level.
static constexpr const char *const COND_AUTH_SYS
Definition: Auth.h:12
cond::CoralServiceManager * m_pluginManager

◆ createCoralSession() [1/2]

std::shared_ptr< coral::ISessionProxy > cond::persistency::ConnectionPool::createCoralSession ( const std::string &  connectionString,
bool  writeCapable = false 
)

◆ createCoralSession() [2/2]

std::shared_ptr< coral::ISessionProxy > cond::persistency::ConnectionPool::createCoralSession ( const std::string &  connectionString,
const std::string &  transactionId,
bool  writeCapable = false 
)
private

Definition at line 134 of file ConnectionPool.cc.

References cond::auth::COND_READER_ROLE, cond::auth::COND_WRITER_ROLE, l1RCTOmdsFedVectorProducer_cfi::connectionString, cond::persistency::getConnectionParams(), m_frontierSecurity, cond::persistency::TAG::tname, cond::persistency::PAYLOAD::tname, and cond::persistency::IOV::tname.

136  {
137  coral::ConnectionService connServ;
138  //all sessions opened with this connection service will share the same frontier security option.
139  std::pair<std::string, std::string> fullConnectionPars =
141  if (!fullConnectionPars.second.empty()) {
142  //all sessions opened with this connection service will share the same TTL settings for TAG, IOV, and PAYLOAD tables.
143  connServ.webCacheControl().setTableTimeToLive(fullConnectionPars.second, TAG::tname, 1);
144  connServ.webCacheControl().setTableTimeToLive(fullConnectionPars.second, IOV::tname, 1);
145  connServ.webCacheControl().setTableTimeToLive(fullConnectionPars.second, PAYLOAD::tname, 3);
146  }
147 
148  return std::shared_ptr<coral::ISessionProxy>(
149  connServ.connect(fullConnectionPars.first,
151  writeCapable ? coral::Update : coral::ReadOnly));
152  }
static constexpr char const * tname
Definition: IOVSchema.h:73
static constexpr const char *const COND_READER_ROLE
Definition: Auth.h:18
static constexpr char const * tname
Definition: IOVSchema.h:13
std::pair< std::string, std::string > getConnectionParams(const std::string &connectionString, const std::string &transactionId, const std::string &signature)
static constexpr char const * tname
Definition: IOVSchema.h:110
static constexpr const char *const COND_WRITER_ROLE
Definition: Auth.h:17

◆ createReadOnlySession()

Session cond::persistency::ConnectionPool::createReadOnlySession ( const std::string &  connectionString,
const std::string &  transactionId 
)

Definition at line 178 of file ConnectionPool.cc.

References l1RCTOmdsFedVectorProducer_cfi::connectionString, and createSession().

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

179  {
180  return createSession(connectionString, transactionId);
181  }
Session createSession(const std::string &connectionString, bool writeCapable=false)

◆ createSession() [1/2]

Session cond::persistency::ConnectionPool::createSession ( const std::string &  connectionString,
bool  writeCapable = false 
)

◆ createSession() [2/2]

Session cond::persistency::ConnectionPool::createSession ( const std::string &  connectionString,
const std::string &  transactionId,
bool  writeCapable = false 
)
private

Definition at line 154 of file ConnectionPool.cc.

References l1RCTOmdsFedVectorProducer_cfi::connectionString, createCoralSession(), instance, m_authenticationService, cond::persistency::IDbAuthentication::principalName(), and AlCaHLTBitMon_QueryRunRegistry::string.

156  {
157  std::shared_ptr<coral::ISessionProxy> coralSession =
158  createCoralSession(connectionString, transactionId, writeCapable);
159 
160  std::string principalName("");
161  if (!m_authenticationService.empty()) {
162  // need to hard-code somewhere the target name...
163  if (m_authenticationService == "COND/Services/RelationalAuthenticationService") {
164  coral::IHandle<coral::IAuthenticationService> authSvc =
165  coral::Context::instance().query<coral::IAuthenticationService>(m_authenticationService);
166  IDbAuthentication* dbAuth = dynamic_cast<IDbAuthentication*>(authSvc.get());
167  principalName = dbAuth->principalName();
168  }
169  }
170 
171  return Session(std::make_shared<SessionImpl>(coralSession, connectionString, principalName));
172  }
static PFTauRenderPlugin instance
std::shared_ptr< coral::ISessionProxy > createCoralSession(const std::string &connectionString, bool writeCapable=false)

◆ isLoggingEnabled()

bool cond::persistency::ConnectionPool::isLoggingEnabled ( ) const

Definition at line 74 of file ConnectionPool.cc.

References m_loggingEnabled.

◆ setAuthenticationPath()

void cond::persistency::ConnectionPool::setAuthenticationPath ( const std::string &  p)

◆ setAuthenticationSystem()

void cond::persistency::ConnectionPool::setAuthenticationSystem ( int  authSysCode)

◆ setConnectionTimeout()

void cond::persistency::ConnectionPool::setConnectionTimeout ( int  seconds)

Definition at line 190 of file ConnectionPool.cc.

References m_connectionTimeout, and seconds().

Referenced by setParameters().

◆ setFrontierSecurity()

void cond::persistency::ConnectionPool::setFrontierSecurity ( const std::string &  signature)

Definition at line 39 of file ConnectionPool.cc.

References m_frontierSecurity, and signature.

Referenced by setParameters().

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

◆ setLogDestination()

void cond::persistency::ConnectionPool::setLogDestination ( Logger logger)

◆ setLogging()

void cond::persistency::ConnectionPool::setLogging ( bool  flag)

◆ setMessageVerbosity()

void cond::persistency::ConnectionPool::setMessageVerbosity ( coral::MsgLevel  level)

◆ setParameters()

void cond::persistency::ConnectionPool::setParameters ( const edm::ParameterSet connectionPset)

Definition at line 43 of file ConnectionPool.cc.

References Debug, edm::ParameterSet::getUntrackedParameter(), personalPlayback::level, m_authPath, m_authSys, m_connectionTimeout, m_frontierSecurity, m_loggingEnabled, m_messageLevel, beam_dqm_sourceclient-live_cfg::messageLevel, setAuthenticationPath(), setAuthenticationSystem(), setConnectionTimeout(), setFrontierSecurity(), setLogging(), setMessageVerbosity(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by BeamSpotRcdPrinter::BeamSpotRcdPrinter(), CondDBESSource::CondDBESSource(), FastSiPixelFEDChannelContainerFromQuality::FastSiPixelFEDChannelContainerFromQuality(), popcon::PopConBTransitionSourceHandler< T >::PopConBTransitionSourceHandler(), popcon::PopConESTransitionSourceHandler< T >::PopConESTransitionSourceHandler(), RunInfoRead::readData(), RPCDCCLinkMapHandler::RPCDCCLinkMapHandler(), RPCLBLinkMapHandler::RPCLBLinkMapHandler(), SiStripDetVOffHandler::SiStripDetVOffHandler(), SiStripDetVOffPrinter::SiStripDetVOffPrinter(), SiStripDetVOffTkMapPlotter::SiStripDetVOffTkMapPlotter(), SiStripDetVOffTrendPlotter::SiStripDetVOffTrendPlotter(), SiStripPayloadHandler< SiStripPayload >::SiStripPayloadHandler(), and SiStripPayloadMapTableCreator::SiStripPayloadMapTableCreator().

43  {
44  //set the connection parameters from a ParameterSet
45  //if a parameter is not defined, keep the values already set in the data members
46  //(i.e. default if no other setters called, or the ones currently available)
47  setAuthenticationPath(connectionPset.getUntrackedParameter<std::string>("authenticationPath", m_authPath));
48  setAuthenticationSystem(connectionPset.getUntrackedParameter<int>("authenticationSystem", m_authSys));
50  int messageLevel =
51  connectionPset.getUntrackedParameter<int>("messageLevel", 0); //0 corresponds to Error level, current default
52  coral::MsgLevel level = m_messageLevel;
53  switch (messageLevel) {
54  case 0:
56  break;
57  case 1:
58  level = coral::Warning;
59  break;
60  case 2:
61  level = coral::Info;
62  break;
63  case 3:
65  break;
66  default:
68  }
70  setConnectionTimeout(connectionPset.getUntrackedParameter<int>("connectionTimeout", m_connectionTimeout));
71  setLogging(connectionPset.getUntrackedParameter<bool>("logging", m_loggingEnabled));
72  }
edm::ErrorSummaryEntry Error
T getUntrackedParameter(std::string const &, T const &) const
void setAuthenticationSystem(int authSysCode)
void setMessageVerbosity(coral::MsgLevel level)
void setAuthenticationPath(const std::string &p)
const bool Debug
void setFrontierSecurity(const std::string &signature)

Member Data Documentation

◆ m_authenticationService

std::string cond::persistency::ConnectionPool::m_authenticationService = std::string("")
private

Definition at line 67 of file ConnectionPool.h.

Referenced by configure(), and createSession().

◆ m_authPath

std::string cond::persistency::ConnectionPool::m_authPath = std::string("")
private

Definition at line 65 of file ConnectionPool.h.

Referenced by configure(), setAuthenticationPath(), and setParameters().

◆ m_authSys

int cond::persistency::ConnectionPool::m_authSys = 0
private

Definition at line 66 of file ConnectionPool.h.

Referenced by configure(), setAuthenticationSystem(), and setParameters().

◆ m_connectionTimeout

int cond::persistency::ConnectionPool::m_connectionTimeout = 0
private

Definition at line 69 of file ConnectionPool.h.

Referenced by configure(), setConnectionTimeout(), and setParameters().

◆ m_frontierSecurity

std::string cond::persistency::ConnectionPool::m_frontierSecurity = std::string("")
private

Definition at line 74 of file ConnectionPool.h.

Referenced by createCoralSession(), setFrontierSecurity(), and setParameters().

◆ m_loggingEnabled

bool cond::persistency::ConnectionPool::m_loggingEnabled = false
private

Definition at line 71 of file ConnectionPool.h.

Referenced by isLoggingEnabled(), setLogging(), and setParameters().

◆ m_messageLevel

coral::MsgLevel cond::persistency::ConnectionPool::m_messageLevel = coral::Error
private

Definition at line 68 of file ConnectionPool.h.

Referenced by configure(), setMessageVerbosity(), and setParameters().

◆ m_msgReporter

CoralMsgReporter* cond::persistency::ConnectionPool::m_msgReporter = nullptr
private

Definition at line 70 of file ConnectionPool.h.

Referenced by configure(), ConnectionPool(), and setLogDestination().

◆ m_pluginManager

cond::CoralServiceManager* cond::persistency::ConnectionPool::m_pluginManager = nullptr
private

Definition at line 76 of file ConnectionPool.h.

Referenced by configure(), ConnectionPool(), and ~ConnectionPool().