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");
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;
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");