|  | ATLAS Offline Software
    | 
 
 
 
RDBAccessSvc is the implementation of IRDBAccessSvc interface.  
 More...
#include <RDBAccessSvc.h>
|  | 
|  | RDBAccessSvc (const std::string &name, ISvcLocator *svc) | 
|  | Standard Service Constructor.  More... 
 | 
|  | 
| StatusCode | initialize () override | 
|  | 
| StatusCode | finalize () override | 
|  | 
| bool | connect (const std::string &connName) override | 
|  | Connect to the relational DB.  More... 
 | 
|  | 
| bool | disconnect (const std::string &connName) override | 
|  | If the counnection counter==1 closes the connection.  More... 
 | 
|  | 
| bool | shutdown (const std::string &connName) override | 
|  | Closes the connection regardless of the counter value.  More... 
 | 
|  | 
| IRDBRecordset_ptr | getRecordsetPtr (const std::string &node, const std::string &tag, const std::string &tag2node="", const std::string &connName="ATLASDD") override | 
|  | Provides access to the Recordset object containing HVS-tagged data.  More... 
 | 
|  | 
| std::string | getChildTag (const std::string &childNode, const std::string &parentTag, const std::string &parentNode, const std::string &connName) override | 
|  | Gets the tag name for the node by giving its parent node tag.  More... 
 | 
|  | 
| std::string | getChildTag (const std::string &childNode, const std::string &parentTag, const std::string &parentNode, const std::string &connName, bool force) | 
|  | 
| std::unique_ptr< IRDBQuery > | getQuery (const std::string &node, const std::string &tag, const std::string &tag2node, const std::string &connName) override | 
|  | 
| void | getTagDetails (RDBTagDetails &tagDetails, const std::string &tag, const std::string &connName="ATLASDD") override | 
|  | 
| void | getAllLeafNodes (std::vector< std::string > &list, const std::string &connName="ATLASDD") | 
|  | 
| std::vector< std::string > | getLockedSupportedTags (const std::string &supportedFlag, const std::string &connName="ATLASDD") | 
|  | 
| coral::ISessionProxy * | getSession (const std::string &connName="ATLASDD") | 
|  | 
RDBAccessSvc is the implementation of IRDBAccessSvc interface. 
Definition at line 57 of file RDBAccessSvc.h.
◆ RDBAccessSvc()
      
        
          | RDBAccessSvc::RDBAccessSvc | ( | const std::string & | name, | 
        
          |  |  | ISvcLocator * | svc | 
        
          |  | ) |  |  | 
      
 
 
◆ connect()
  
  | 
        
          | bool RDBAccessSvc::connect | ( | const std::string & | connName | ) |  |  | override | 
 
Connect to the relational DB. 
If this method is called for already open connection the connection counter is incremented. 
- Returns
- success/failure 
Definition at line 41 of file RDBAccessSvc.cxx.
   46     ATH_MSG_DEBUG(
" Trying to open the connection " << connName << 
" for the first time");
 
   63   coral::ConnectionService conSvcH;
 
   64   coral::ISessionProxy *
proxy = 
nullptr;
 
   66     proxy = conSvcH.connect(connName,coral::ReadOnly);
 
   67     proxy->transaction().start(
true);
 
   68     ATH_MSG_DEBUG(
"Proxy for connection "  << connName << 
" obtained");
 
 
 
 
◆ disconnect()
  
  | 
        
          | bool RDBAccessSvc::disconnect | ( | const std::string & | connName | ) |  |  | override | 
 
If the counnection counter==1 closes the connection. 
Decrements the connection counter value otherwise. 
- Returns
- success/failure 
Definition at line 81 of file RDBAccessSvc.cxx.
   90   if(connection->second>0) {
 
   93     ATH_MSG_DEBUG(
"Connection " << connName << 
" Sessions = " << connection->second);
 
   95     if(connection->second==0) {
 
   98     session->second->transaction().commit();
 
   99     delete session->second;
 
  100     session->second = 
nullptr;
 
 
 
 
◆ finalize()
  
  | 
        
          | StatusCode RDBAccessSvc::finalize | ( |  | ) |  |  | override | 
 
 
◆ getAllLeafNodes()
      
        
          | void RDBAccessSvc::getAllLeafNodes | ( | std::vector< std::string > & | list, | 
        
          |  |  | const std::string & | connName = "ATLASDD" | 
        
          |  | ) |  |  | 
      
 
Definition at line 414 of file RDBAccessSvc.cxx.
  423   coral::ISessionProxy* session = 
m_sessions[connName];
 
  425     coral::ITable& tableNode = session->nominalSchema().tableHandle(
"HVS_NODE");
 
  426     coral::IQuery *queryNode = tableNode.newQuery();
 
  427     queryNode->addToOutputList(
"NODE_NAME");
 
  428     queryNode->setMemoryCacheSize(1);
 
  430     queryNode->setCondition(
"BRANCH_FLAG=0", empty);
 
  431     queryNode->addToOrderList(
"NODE_NAME");
 
  433     coral::ICursor& cursorNode = queryNode->execute();
 
  434     while(cursorNode.next()) {
 
  435       list.push_back(cursorNode.currentRow()[
"NODE_NAME"].data<std::string>());
 
  440   catch(coral::SchemaException& 
se) {
 
 
 
 
◆ getChildTag() [1/2]
  
  | 
        
          | std::string RDBAccessSvc::getChildTag | ( | const std::string & | childNode, |  
          |  |  | const std::string & | parentTag, |  
          |  |  | const std::string & | parentNode, |  
          |  |  | const std::string & | connName |  
          |  | ) |  |  |  | override | 
 
Gets the tag name for the node by giving its parent node tag. 
- Parameters
- 
  
    | childNode | [IN] name of the child node |  | parentTag | [IN] name of the parent tag |  | parentNode | [IN] name of the parent node |  | fetchData | [IN] if true fetch the corresponding data this parameter has no sence if child is the branch node |  
 
Definition at line 270 of file RDBAccessSvc.cxx.
 
 
◆ getChildTag() [2/2]
      
        
          | std::string RDBAccessSvc::getChildTag | ( | const std::string & | childNode, | 
        
          |  |  | const std::string & | parentTag, | 
        
          |  |  | const std::string & | parentNode, | 
        
          |  |  | const std::string & | connName, | 
        
          |  |  | bool | force | 
        
          |  | ) |  |  | 
      
 
Definition at line 282 of file RDBAccessSvc.cxx.
  288   ATH_MSG_DEBUG(
"getChildTag for " << childNode << 
" " << parentTag << 
" " << parentNode);
 
  293   std::string lookupMapKey = parentTag + 
"::" + connName;
 
  294   GlobalTagLookupMap::const_iterator lookupmap = 
m_globalTagLookup.find(lookupMapKey);
 
  296     TagNameIdByNode::const_iterator childtagdet = lookupmap->second->find(childNode);
 
  297     if(childtagdet!=lookupmap->second->end()) {
 
  298       return childtagdet->second.first;
 
  302     return std::string(
"");
 
  308     ATH_MSG_ERROR(
"Unable to open connection " << connName << 
". Returning empty string");
 
  309     return std::string(
"");
 
  312   std::string childTag(
"");
 
  315     coral::ISessionProxy* session = 
m_sessions[connName];
 
  317     versionAccessor.getChildTagData();
 
  319     childTag = versionAccessor.getTagName();
 
  321   catch(coral::SchemaException& 
se) {
 
 
 
 
◆ getLockedSupportedTags()
      
        
          | std::vector< std::string > RDBAccessSvc::getLockedSupportedTags | ( | const std::string & | supportedFlag, | 
        
          |  |  | const std::string & | connName = "ATLASDD" | 
        
          |  | ) |  |  | 
      
 
Definition at line 453 of file RDBAccessSvc.cxx.
  456   std::vector<std::string> 
taglist;
 
  462       coral::ISessionProxy* session = 
m_sessions[connName];
 
  464       coral::ITable& tableTag2Node = session->nominalSchema().tableHandle(
"HVS_TAG2NODE");
 
  465       coral::IQuery* queryTag2Node = tableTag2Node.newQuery();
 
  466       queryTag2Node->addToOutputList(
"TAG_NAME");
 
  467       queryTag2Node->setMemoryCacheSize(1);
 
  469       std::string condString = std::string(
"NODE_ID=0 AND LOCKED=1 AND SUPPORTED>=")+supportedFlag;
 
  470       queryTag2Node->setCondition(condString,empty);
 
  471       queryTag2Node->addToOrderList(
"TAG_NAME");
 
  473       coral::ICursor& cursorTagName = queryTag2Node->execute();
 
  474       while(cursorTagName.next()) {
 
  476     taglist.push_back(
row[
"TAG_NAME"].data<std::string>());
 
  478       delete queryTag2Node;
 
  481     catch(coral::SchemaException& 
se) {
 
 
 
 
◆ getQuery()
  
  | 
        
          | std::unique_ptr< IRDBQuery > RDBAccessSvc::getQuery | ( | const std::string & | node, |  
          |  |  | const std::string & | tag, |  
          |  |  | const std::string & | tag2node, |  
          |  |  | const std::string & | connName |  
          |  | ) |  |  |  | override | 
 
Definition at line 214 of file RDBAccessSvc.cxx.
  223   std::unique_ptr<IRDBQuery> 
query;
 
  226     ATH_MSG_ERROR(
"Unable to open connection " << connName << 
". Returning nullptr to IRDBQuery");
 
  230   coral::ISessionProxy* session = 
m_sessions[connName];
 
  234     std::string childTagId(
"");
 
  235     std::string lookupMapKey = 
tag + 
"::" + connName;
 
  236     GlobalTagLookupMap::const_iterator lookupmap = 
m_globalTagLookup.find(lookupMapKey);
 
  238       TagNameIdByNode::const_iterator childtagdet = lookupmap->second->find(
node);
 
  239       if(childtagdet!=lookupmap->second->end()) {
 
  240     childTagId = childtagdet->second.second;
 
  245       versionAccessor.getChildTagData();
 
  246       childTagId = versionAccessor.getTagID();
 
  249     if(childTagId.empty()) {
 
  250       ATH_MSG_WARNING(
"Could not get the tag for " << 
node << 
" node. Returning 0 pointer to IRDBQuery");
 
  253       query = std::unique_ptr<IRDBQuery>(
new RDBQuery(dblock,
this,
node,childTagId,connName));
 
  256   catch(coral::SchemaException& 
se) {
 
 
 
 
◆ getRecordsetPtr()
Provides access to the Recordset object containing HVS-tagged data. 
- Parameters
- 
  
    | node | [IN] name of the leaf HVS node |  | tag | [IN] tag of the HVS node specified by node parameter if tag2node is omitted, tag of the HVS branch node specified by tag2node otherwise |  | tag2node | [IN] some parent of the HVS leaf node specified by node parameter |  
 
- Returns
- pointer to the recordset object 
Definition at line 149 of file RDBAccessSvc.cxx.
  156     key += (
"::" + tag2node);
 
  164   RecordsetPtrMap::const_iterator 
it = recordsets.find(
key);
 
  165   if(
it != recordsets.end()) {
 
  171     ATH_MSG_ERROR(
"Unable to open connection " << connName << 
". Returning empty recordset");
 
  177   coral::ISessionProxy* session = 
m_sessions[connName];
 
  181     std::string lookupMapKey = 
tag + 
"::" + connName;
 
  182     GlobalTagLookupMap::const_iterator lookupmap = 
m_globalTagLookup.find(lookupMapKey);
 
  184       TagNameIdByNode::const_iterator childtagdet = lookupmap->second->find(
node);
 
  185       if(childtagdet!=lookupmap->second->end()) {
 
  186     recConcrete->
getData(session,
node,childtagdet->second.first,childtagdet->second.second);
 
  190     ATH_MSG_DEBUG(
"Unable to find tag for the node " << 
node << 
" in the cache of global tag " << 
tag << 
". Returning empty recordset");
 
  195       versionAccessor.getChildTagData();
 
  196       recConcrete->
getData(session,versionAccessor.getNodeName(),versionAccessor.getTagName(),versionAccessor.getTagID());
 
  199   catch(coral::SchemaException& 
se) {
 
  209   recordsets.emplace(
key,rec);
 
 
 
 
◆ getSession()
      
        
          | coral::ISessionProxy * RDBAccessSvc::getSession | ( | const std::string & | connName = "ATLASDD" | ) |  | 
      
 
 
◆ getTagDetails()
  
  | 
        
          | void RDBAccessSvc::getTagDetails | ( | RDBTagDetails & | tagDetails, |  
          |  |  | const std::string & | tag, |  
          |  |  | const std::string & | connName = "ATLASDD" |  
          |  | ) |  |  |  | override | 
 
Definition at line 336 of file RDBAccessSvc.cxx.
  348   coral::ISessionProxy* session = 
m_sessions[connName];
 
  350     coral::ITable& tableTag2Node = session->nominalSchema().tableHandle(
"HVS_TAG2NODE");
 
  351     coral::IQuery *queryTag2Node = tableTag2Node.newQuery();
 
  352     queryTag2Node->addToOutputList(
"LOCKED");
 
  353     queryTag2Node->addToOutputList(
"SUPPORTED");
 
  354     queryTag2Node->setMemoryCacheSize(1);
 
  356     bindsTag2Node.extend<std::string>(
"tagN");
 
  357     queryTag2Node->setCondition(
"TAG_NAME=:tagN", bindsTag2Node);
 
  358     bindsTag2Node[0].data<std::string>() = 
tag;
 
  360     coral::ICursor& cursorTag2Node = queryTag2Node->execute();
 
  361     if(cursorTag2Node.next()) {
 
  362       tagDetails = cursorTag2Node.currentRow();
 
  365     delete queryTag2Node;
 
  368     std::string lookupMapKey = 
tag + 
"::" + connName;
 
  373       coral::ITable& tableRootTag2Child = session->nominalSchema().tableHandle(
"HVS_TAGCACHE");
 
  374       coral::IQuery* queryRootTag2Child = tableRootTag2Child.newQuery();
 
  375       queryRootTag2Child->addToOutputList(
"CHILDNODE");
 
  376       queryRootTag2Child->addToOutputList(
"CHILDTAG");
 
  377       queryRootTag2Child->addToOutputList(
"CHILDTAGID");
 
  378       queryRootTag2Child->setMemoryCacheSize(1);
 
  380       bindsRootTag2Child.extend<std::string>(
"tagN");
 
  381       queryRootTag2Child->setCondition(
"ROOTTAG=:tagN", bindsRootTag2Child);
 
  382       bindsRootTag2Child[0].data<std::string>() = 
tag;
 
  383       queryRootTag2Child->addToOrderList(
"CHILDNODE");
 
  385       coral::ICursor& cursorRootTag2Child = queryRootTag2Child->execute();
 
  386       while(cursorRootTag2Child.next()) {
 
  388     (*lookup)[
row[
"CHILDNODE"].data<std::string>()]=std::make_pair(
row[
"CHILDTAG"].data<std::string>(),
std::to_string(
row[
"CHILDTAGID"].data<long long>()));
 
  391       delete queryRootTag2Child;
 
  401   catch(coral::SchemaException& 
se) {
 
 
 
 
◆ initialize()
  
  | 
        
          | StatusCode RDBAccessSvc::initialize | ( |  | ) |  |  | override | 
 
 
◆ shutdown()
  
  | 
        
          | bool RDBAccessSvc::shutdown | ( | const std::string & | connName | ) |  |  | override | 
 
Closes the connection regardless of the counter value. 
- Returns
- success/failure 
Definition at line 109 of file RDBAccessSvc.cxx.
  111   if(connName==
"*Everything*") {
 
  114     ATH_MSG_INFO(
"Close everything: Connection: " << ii.first << 
" with reference count = " << ii.second << 
" will be closed.");
 
 
 
 
◆ shutdown_connection()
  
  | 
        
          | bool RDBAccessSvc::shutdown_connection | ( | const std::string & | connName | ) |  |  | private | 
 
Definition at line 126 of file RDBAccessSvc.cxx.
  130     ATH_MSG_ERROR(
"Wrong name for the connection: " << connName);
 
  134   connection->second = 0;
 
  138      && session->second) {
 
  139     session->second->transaction().commit();
 
  140     delete session->second;
 
  141     session->second = 
nullptr;
 
 
 
 
◆ m_globalTagLookup
◆ m_openConnections
  
  | 
        
          | std::map<std::string, unsigned int> RDBAccessSvc::m_openConnections |  | private | 
 
 
◆ m_recordsetMutex
  
  | 
        
          | std::mutex RDBAccessSvc::m_recordsetMutex |  | private | 
 
 
◆ m_recordsetptrs
◆ m_sessionMutex
  
  | 
        
          | std::mutex RDBAccessSvc::m_sessionMutex |  | private | 
 
 
◆ m_sessions
The documentation for this class was generated from the following files:
 
std::string getChildTag(const std::string &childNode, const std::string &parentTag, const std::string &parentNode, const std::string &connName) override
Gets the tag name for the node by giving its parent node tag.
RDBQuery is an implementation of IRDBQuery interface.
std::mutex m_recordsetMutex
const unsigned short lookup[2401]
std::map< std::string, IRDBRecordset_ptr > RecordsetPtrMap
bool connect(const std::string &connName) override
Connect to the relational DB.
std::string to_string(const SectorProjector proj)
std::map< std::string, TagNameId > TagNameIdByNode
RDBVersionAccessor is a helper class navigating HVS tree and getting child node tag by the tag of one...
GlobalTagLookupMap m_globalTagLookup
bool shutdown(const std::string &connName) override
Closes the connection regardless of the counter value.
std::mutex m_sessionMutex
AthROOTErrorHandlerSvc * svc
RecordsetPtrsByConn m_recordsetptrs
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
void getData(coral::ISessionProxy *session, const std::string &nodeName, const std::string &tagName, const std::string &tagId)
Constructs SQL query and retrieves the data from DB.
bool empty() const noexcept
#define ATH_MSG_WARNING(x)
void setNodeName(const std::string &nodeName)
bool shutdown_connection(const std::string &connName)
#define ATLAS_THREAD_SAFE
std::map< std::string, unsigned int > m_openConnections
bool disconnect(const std::string &connName) override
If the counnection counter==1 closes the connection.
RDBRecordset is an implementation of IRDBRecordset interface.