#include <ReplicaSorter.h>
◆ ServerMap [1/2]
◆ ServerMap [2/2]
◆ ServerPair [1/2]
◆ ServerPair [2/2]
◆ ReplicaSorter() [1/2]
ReplicaSorter::ReplicaSorter |
( |
| ) |
|
◆ ReplicaSorter() [2/2]
ReplicaSorter::ReplicaSorter |
( |
| ) |
|
◆ findFile() [1/2]
FILE * ReplicaSorter::findFile |
( |
const std::string & |
filename, |
|
|
const std::string & |
pathvar |
|
) |
| |
|
staticprivate |
◆ findFile() [2/2]
FILE* ReplicaSorter::findFile |
( |
const std::string & |
filename, |
|
|
const std::string & |
pathvar |
|
) |
| |
|
private |
◆ readConfig() [1/2]
bool ReplicaSorter::readConfig |
( |
| ) |
|
|
private |
◆ readConfig() [2/2]
bool ReplicaSorter::readConfig |
( |
| ) |
|
|
private |
Definition at line 57 of file Database/CoolConvUtilities/src/ReplicaSorter.cxx.
60 const char* chost=
getenv(
"ATLAS_CONDDB");
63 const char* chost=
getenv(
"HOSTNAME");
68 system(
"hostname --fqdn > hostnamelookup.tmp");
70 infile.open(
"hostnamelookup.tmp");
78 std::cout <<
"Using machine hostname " <<
m_hostname <<
79 " for DB replica resolution" << std::endl;
81 const char* cfrontier=
getenv(
"FRONTIER_SERVER");
82 if (cfrontier && strcmp(cfrontier,
"")!=0) {
83 std::cout <<
"Frontier server at " << cfrontier <<
" will be considered"
93 std::cout <<
"Cannot open/locate configuration file dbreplica.config"
98 unsigned int bufsize=999;
99 char* p_buf=
new char[bufsize];
100 while (!feof(p_inp)) {
101 char* p_line=fgets(p_buf,bufsize,p_inp);
102 if (p_line!=
nullptr && p_line[0]!=
'#') {
103 std::string
buf=std::string(p_line);
104 std::string::size_type iofs1=0;
107 std::vector<std::string> domains;
108 std::vector<std::string> servers;
109 while (iofs1<
buf.size()) {
110 std::string::size_type iofs2=
buf.find(
' ',iofs1);
112 if (iofs2==std::string::npos) iofs2=
buf.size()-1;
113 std::string token=
buf.substr(iofs1,iofs2-iofs1);
115 if (!token.empty() && token!=
" ") {
118 }
else if (!sequal) {
120 domains.push_back(token);
124 if (token!=
"ATLF" ||
m_frontiergen) servers.push_back(token);
132 unsigned int bestlen=0;
133 for (std::vector<std::string>::const_iterator itr=domains.begin();
134 itr!=domains.end();++itr) {
135 std::string::size_type len=(itr->size());
136 std::string::size_type hlen=
m_hostname.size();
137 if (hlen>=len && *itr==
m_hostname.substr(hlen-len,len)) {
147 "No specific match for domain found - use default fallback"
156 for (
unsigned int i=0;
i<servers.size();++
i) {
166 " servers found for host " <<
m_hostname << std::endl;
◆ sort() [1/2]
void ReplicaSorter::sort |
( |
std::vector< const coral::IDatabaseServiceDescription * > & |
replicaSet | ) |
|
◆ sort() [2/2]
void ReplicaSorter::sort |
( |
std::vector< const coral::IDatabaseServiceDescription * > & |
replicaSet | ) |
|
Definition at line 21 of file Database/CoolConvUtilities/src/ReplicaSorter.cxx.
24 std::map<int,const coral::IDatabaseServiceDescription*> primap;
25 for (std::vector<const coral::IDatabaseServiceDescription*>::const_iterator
26 itr=replicaSet.begin();itr!=replicaSet.end();++itr) {
27 const std::string
conn=(**itr).connectionString();
29 if (
conn.find(
"sqlite_file")==std::string::npos) {
31 std::string::size_type ipos1=
conn.find(
"://");
32 std::string::size_type ipos2=
conn.find(
'/',ipos1+3);
33 if (ipos1!=std::string::npos && ipos2!=std::string::npos) {
34 const std::string_view
server=std::string_view(
conn).substr(ipos1+3,ipos2-ipos1-3);
37 for (ServerMap::const_iterator sitr=
m_servermap.begin();
40 primap[sitr->second]=*itr;
47 for (std::map<int,const coral::IDatabaseServiceDescription*>::const_iterator
48 itr=primap.begin();itr!=primap.end();++itr) {
49 replicaSet.push_back(itr->second);
50 std::cout <<
"Allowed replica to try (priority " << itr->first
51 <<
") : " << (itr->second)->connectionString() << std::endl;
53 if (replicaSet.empty())
54 std::cout <<
"No matching replicas found" << std::endl;
◆ m_frontiergen
bool ReplicaSorter::m_frontiergen |
|
private |
◆ m_hostname
std::string ReplicaSorter::m_hostname |
|
private |
◆ m_servermap
The documentation for this class was generated from the following files: