#include <DBReplicaSvc.h>
|
virtual StatusCode | initialize () override |
|
void | sort (std::vector< const coral::IDatabaseServiceDescription * > &replicaSet) override |
|
|
Gaudi::Property< std::string > | m_configfile {this, "ConfigFile", "dbreplica.config"} |
|
Gaudi::Property< std::string > | m_testhost {this, "TestHost", ""} |
|
Gaudi::Property< std::string > | m_coolsqlitepattern {this, "COOLSQLiteVetoPattern", ""} |
|
Gaudi::Property< bool > | m_usecoolsqlite {this, "UseCOOLSQLite", true} |
|
Gaudi::Property< bool > | m_usecoolfrontier {this, "UseCOOLFrontier", true} |
|
Gaudi::Property< bool > | m_usegeomsqlite {this, "UseGeomSQLite", true} |
|
Gaudi::Property< bool > | m_nofailover {this, "DisableFailover", false} |
|
bool | m_frontiergen {false} |
|
std::string | m_hostname |
|
std::vector< ServerPair > | m_servermap |
|
Definition at line 16 of file DBReplicaSvc.h.
◆ ServerPair
◆ initialize()
StatusCode DBReplicaSvc::initialize |
( |
| ) |
|
|
overridevirtual |
Definition at line 16 of file DBReplicaSvc.cxx.
22 const char* chost=
getenv(
"ATLAS_CONDDB");
27 const char* chost=
getenv(
"HOSTNAME");
32 <<
" has no domain - try hostname --fqdn");
35 system(
"hostname --fqdn > hostnamelookup.tmp");
38 system(
"hostname > hostnamelookup.tmp");
41 infile.open(
"hostnamelookup.tmp");
51 const char* cfrontier=
getenv(
"FRONTIER_SERVER");
54 <<
" will be considered for COOL data");
61 ATH_MSG_INFO (
"COOL SQLite replicas will be excluded if matching pattern "
65 ATH_MSG_INFO (
"COOL Frontier replicas will be excluded");
67 ATH_MSG_INFO (
"Geometry SQLite replicas will be excluded");
69 ATH_MSG_INFO (
"Failover to secondary replicas disabled");
◆ readConfig()
StatusCode DBReplicaSvc::readConfig |
( |
| ) |
|
|
private |
Definition at line 74 of file DBReplicaSvc.cxx.
80 return StatusCode::FAILURE;
84 FILE* p_inp=fopen(
file.c_str(),
"r");
87 return StatusCode::FAILURE;
90 const unsigned int bufsize=999;
92 while (!feof(p_inp)) {
93 char* p_line=fgets(p_buf,bufsize,p_inp);
94 if (p_line!=NULL && p_line[0]!=
'#') {
95 std::string
buf=std::string(p_line);
96 std::string::size_type iofs1=0;
99 std::vector<std::string> domains;
100 std::vector<std::string> servers;
101 while (iofs1<
buf.size()) {
102 std::string::size_type iofs2=
buf.find(
' ',iofs1);
104 if (iofs2==std::string::npos) iofs2=
buf.size()-1;
105 std::string token=
buf.substr(iofs1,iofs2-iofs1);
107 if (token!=
"" && token!=
" ") {
110 }
else if (!sequal) {
112 domains.push_back(token);
115 if (!
m_nofailover || servers.size()==0 || token==
"atlas_dd")
116 servers.push_back(token);
124 unsigned int bestlen=0;
125 for (
const std::string&
d : domains) {
126 std::string::size_type len=
d.size();
127 std::string::size_type hlen=
m_hostname.size();
128 if (hlen>=len &&
d==
m_hostname.substr(hlen-len,len)) {
137 ATH_MSG_INFO (
"No specific match for domain found - use default fallback");
145 for (
unsigned int i=0;
i<servers.size();++
i) {
162 " servers found for host " <<
m_hostname <<
" [";
167 return StatusCode::SUCCESS;
◆ sort()
void DBReplicaSvc::sort |
( |
std::vector< const coral::IDatabaseServiceDescription * > & |
replicaSet | ) |
|
|
override |
Definition at line 170 of file DBReplicaSvc.cxx.
174 if (replicaSet.size()<=1)
return;
177 std::map<int,const coral::IDatabaseServiceDescription*> primap;
178 for (
const coral::IDatabaseServiceDescription* dbdescr : replicaSet) {
180 const std::string
conn=dbdescr->connectionString();
182 if (
conn.find(
"sqlite_file")!=std::string::npos) {
191 &&
conn.find(
"ALLP")!=std::string::npos)
195 &&
conn.find(
"geomDB")!=std::string::npos))) {
199 if (
conn.find(
"sqlite_file:/")!=std::string::npos ||
200 conn.find(
"DBRelease")!=std::string::npos) {
201 primap[-999]=dbdescr;
203 primap[-9999]=dbdescr;
210 if (
conn.find(
"frontier:")!=std::string::npos) {
220 std::string::size_type ipos1=
conn.find(
"://");
221 std::string::size_type ipos2=
conn.find(
'/',ipos1+3);
224 std::string::size_type ipos3=
conn.find(
'(',ipos1+3);
225 if (ipos3!=std::string::npos && ipos3<ipos2) ipos2=ipos3;
226 if (ipos1!=std::string::npos && ipos2!=std::string::npos && !
veto) {
227 const std::string
server=
conn.substr(ipos1+3,ipos2-ipos1-3);
232 primap[pri+spri]=dbdescr;
240 for (
const auto& [pri,
db] : primap) {
241 replicaSet.push_back(
db);
242 ATH_MSG_DEBUG (
"Allowed replica to try (priority " << pri <<
") : " <<
db->connectionString());
244 if (replicaSet.empty()) {
247 ATH_MSG_DEBUG (
"Retained total of " << replicaSet.size() <<
" replicas");
◆ m_configfile
Gaudi::Property<std::string> DBReplicaSvc::m_configfile {this, "ConfigFile", "dbreplica.config"} |
|
private |
◆ m_coolsqlitepattern
Gaudi::Property<std::string> DBReplicaSvc::m_coolsqlitepattern {this, "COOLSQLiteVetoPattern", ""} |
|
private |
◆ m_frontiergen
bool DBReplicaSvc::m_frontiergen {false} |
|
private |
◆ m_hostname
std::string DBReplicaSvc::m_hostname |
|
private |
◆ m_nofailover
Gaudi::Property<bool> DBReplicaSvc::m_nofailover {this, "DisableFailover", false} |
|
private |
◆ m_servermap
◆ m_testhost
Gaudi::Property<std::string> DBReplicaSvc::m_testhost {this, "TestHost", ""} |
|
private |
◆ m_usecoolfrontier
Gaudi::Property<bool> DBReplicaSvc::m_usecoolfrontier {this, "UseCOOLFrontier", true} |
|
private |
◆ m_usecoolsqlite
Gaudi::Property<bool> DBReplicaSvc::m_usecoolsqlite {this, "UseCOOLSQLite", true} |
|
private |
◆ m_usegeomsqlite
Gaudi::Property<bool> DBReplicaSvc::m_usegeomsqlite {this, "UseGeomSQLite", true} |
|
private |
The documentation for this class was generated from the following files: