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,8 +266,15 @@ config::heartbeater() ...@@ -266,8 +266,15 @@ config::heartbeater()
//find the node with the smallest id //find the node with the smallest id
m = me; m = me;
for (unsigned i = 0; i < mems.size(); i++) { for (unsigned i = 0; i < mems.size(); i++) {
if (m > mems[i]) std::istringstream mist(m);
m = mems[i]; 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 (m == me) {
......
...@@ -345,9 +345,19 @@ rsm::set_primary() ...@@ -345,9 +345,19 @@ rsm::set_primary()
} }
assert(p.size() > 0); assert(p.size() > 0);
std::vector<unsigned long long> memsi;
for (unsigned i = 0; i < p.size(); i++) { for (unsigned i = 0; i < p.size(); i++) {
if (isamember(p[i], c)) { std::istringstream ist(p[i]);
primary = 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()); printf("set_primary: primary is %s\n", primary.c_str());
return; 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