Commit ab5f3a60 authored by Mohamed Alzayat's avatar Mohamed Alzayat
Browse files

determination of the next primary in case the current primary fails-- reported...

determination of the next primary in case the current primary fails-- reported by Nicolas and Samim (ds-ws18)
parent e06ff288
......@@ -266,9 +266,16 @@ config::heartbeater()
//find the node with the smallest id
m = me;
for (unsigned i = 0; i < mems.size(); i++) {
if (m > mems[i])
std::istringstream mist(m);
std::istringstream memsist(mems[i]);
unsigned long long mbuf;
unsigned long long memsbuf;
mist >> mbuf;
memsist >> memsbuf;
if (mbuf > memsbuf) {
m = mems[i];
}
}
if (m == me) {
//if i am the one with smallest id, ping the rest of the nodes
......
......@@ -345,9 +345,19 @@ rsm::set_primary()
}
assert(p.size() > 0);
std::vector<unsigned long long> memsi;
for (unsigned i = 0; i < p.size(); i++) {
if (isamember(p[i], c)) {
primary = p[i];
std::istringstream ist(p[i]);
unsigned long long mem;
ist >> mem;
memsi.push_back(mem);
}
std::sort(memsi.begin(), memsi.end());
for (unsigned i = 0; i < memsi.size(); i++) {
std::stringstream sst;
sst << memsi[i];
if (isamember(sst.str(), c)) {
primary = sst.str();
printf("set_primary: primary is %s\n", primary.c_str());
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment