#include <ReplicaSorter.h>
◆ ServerMap
◆ ServerPair
◆ ReplicaSorter()
ReplicaSorter::ReplicaSorter |
( |
| ) |
|
◆ findFile()
FILE * ReplicaSorter::findFile |
( |
const std::string & |
filename, |
|
|
const std::string & |
pathvar |
|
) |
| |
|
private |
◆ readConfig()
bool ReplicaSorter::readConfig |
( |
| ) |
|
|
private |
Definition at line 66 of file Trigger/TrigConfiguration/TrigConfStorage/src/ReplicaSorter.cxx.
69 const char* chost=
getenv(
"ATLAS_CONDDB");
72 const char* chost=
getenv(
"HOSTNAME");
77 char cstr_host[HOST_NAME_MAX];
78 if (gethostname(cstr_host,
sizeof(cstr_host))==0) {
83 std::cout <<
"Using machine hostname " <<
m_hostname <<
" for DB replica resolution" << std::endl;
85 const char* cfrontier=
getenv(
"FRONTIER_SERVER");
86 if (cfrontier && strcmp(cfrontier,
"")!=0) {
87 std::cout <<
"Frontier server at " << cfrontier <<
" will be considered"
97 std::cout <<
"Cannot open/locate configuration file dbreplica.config"
102 unsigned int bufsize=999;
103 char* p_buf=
new char[bufsize];
104 while (!feof(p_inp)) {
105 char* p_line=fgets(p_buf,bufsize,p_inp);
106 if (p_line!=NULL && p_line[0]!=
'#') {
107 std::string
buf=std::string(p_line);
108 std::string::size_type iofs1=0;
111 std::vector<std::string> domains;
112 std::vector<std::string> servers;
114 while (iofs1<
buf.size()) {
115 std::string::size_type iofs2=
buf.find(
' ',iofs1);
117 if (iofs2==std::string::npos) iofs2=
buf.size()-1;
118 std::string token=
buf.substr(iofs1,iofs2-iofs1);
120 if (token!=
"" && token!=
" ") {
123 }
else if (!sequal) {
125 domains.push_back(token);
126 if(token==
"cern.ch") atCERN =
true;
130 if(atCERN && token==
"ATONR_CONF") atCERN =
false;
131 if (token!=
"ATLF" ||
m_frontiergen) servers.push_back(token);
139 unsigned int bestlen=0;
140 for (std::vector<std::string>::const_iterator itr=domains.begin();
141 itr!=domains.end();++itr) {
142 std::string::size_type len=(itr->size());
143 std::string::size_type hlen=
m_hostname.size();
144 if (hlen>=len && *itr==
m_hostname.substr(hlen-len,len)) {
155 "No specific match for domain found - use default fallback"
163 servers.push_back(
"ATONR_COOL");
164 servers.push_back(
"ATONR_CONF");
168 for (
unsigned int i=0;
i<servers.size();++
i) {
178 " servers found for host " <<
m_hostname << std::endl;
◆ sort()
void ReplicaSorter::sort |
( |
std::vector< const coral::IDatabaseServiceDescription * > & |
replicaSet | ) |
|
Definition at line 28 of file Trigger/TrigConfiguration/TrigConfStorage/src/ReplicaSorter.cxx.
30 std::map<int,const coral::IDatabaseServiceDescription*> primap;
31 for (std::vector<const coral::IDatabaseServiceDescription*>::const_iterator
32 itr=replicaSet.begin();itr!=replicaSet.end();++itr) {
33 const std::string
conn=(**itr).connectionString();
35 if (
conn.find(
"sqlite_file")==std::string::npos) {
38 std::string::size_type ipos0=
conn.find(
'&');
39 std::string::size_type ipos1=
conn.find(
"://",ipos0+1);
40 std::string::size_type ipos2=
conn.find(
'/',ipos1+3);
41 if (ipos1!=std::string::npos && ipos2!=std::string::npos) {
42 const std::string
server=
conn.substr(ipos1+3,ipos2-ipos1-3);
45 for (ServerMap::const_iterator sitr=
m_servermap.begin();
48 primap[sitr->second]=*itr;
55 for (std::map<int,const coral::IDatabaseServiceDescription*>::const_iterator
56 itr=primap.begin();itr!=primap.end();++itr) {
57 replicaSet.push_back(itr->second);
58 std::cout <<
"Allowed replica to try (priority " << itr->first
59 <<
") : " << (itr->second)->connectionString() << std::endl;
61 if (replicaSet.empty())
62 std::cout <<
"No matching replicas found" << std::endl;
◆ m_frontiergen
bool TrigConf::ReplicaSorter::m_frontiergen |
|
private |
◆ m_hostname
std::string TrigConf::ReplicaSorter::m_hostname |
|
private |
◆ m_servermap
ServerMap TrigConf::ReplicaSorter::m_servermap |
|
private |
The documentation for this class was generated from the following files: