diff --git a/Wc b/Wc index 7a48f640692644ffdf69ab771730c20c533e5b04..99667e09f487c4575b8ecff3da7bae6fb206eeae 100755 Binary files a/Wc and b/Wc differ diff --git a/Wr b/Wr index 87fe453185225e8a06c5e0b95729d6cb6cd80140..85320a8b25aae4005a2fb2d8e1076eda70482da6 100755 Binary files a/Wr and b/Wr differ diff --git a/src/Node.cpp b/src/Node.cpp index 5be4cbad9748ad0d45fe46707c7bbe2a580c24f9..0493f14d1019c439acdea0c9eb835f506ede0760 100644 --- a/src/Node.cpp +++ b/src/Node.cpp @@ -65,6 +65,7 @@ void Node::debugOutputRep(){ set<string> membersIP; string debug = "[DEBUGREP] ---------------------------\n"; vector<tuple<string,string,int>> toDel; + bool added = false; for (auto pos : hashRing->nodePositions) { members.insert(pos); membersIP.insert(hashRing->getValue(pos)); } for (auto &mapping : outputReplication){ for (auto &reps: mapping.second){ @@ -75,6 +76,7 @@ void Node::debugOutputRep(){ debug += ("FILE: " + mapping.first + " | (" + get<0>(reps.first) + "->"); debug += (to_string(get<1>(reps.first)) + ")" + " REPFACTOR: " + to_string(reps.second)); debug += "\n"; + added = true; } } } @@ -83,7 +85,7 @@ void Node::debugOutputRep(){ if (outputReplication[get<0>(item)].size() == 0) outputReplication.erase(get<0>(item)); } debug += "[DEBUGREP] ---------------------------\n"; - cout << debug << endl; + if (added) cout << debug << endl; } string Node::populateMembershipMessage() @@ -301,7 +303,7 @@ int Node::failureDetection(){ if (deletedNodePostion == get<1>(pairings.first)){ //failed as receiver int repTarget = hashRing->getRandomNode(tuple<int, int, int>(hashRingPosition, hashRingPosition, hashRingPosition)); - while (locations.count(repTarget) != 0) { + while (locations.count(repTarget) != 0 || (hashRing->getValue(repTarget).compare(leaderIP) == 0)) { repTarget = hashRing->getRandomNode(tuple<int, int, int>(hashRingPosition, hashRingPosition, hashRingPosition)); } outputReplication[mapping.first][make_tuple(get<0>(pairings.first),repTarget)] = pairings.second; @@ -1477,7 +1479,7 @@ void Node::handleTcpMessage() set<int> locations; for (auto &e: fileList[inMsg[1]]) locations.insert(e); repTarget = hashRing->getRandomNode(tuple<int, int, int>(hashRingPosition, hashRingPosition, hashRingPosition)); - while (locations.count(repTarget)!=0) { + while (locations.count(repTarget)!=0 || (hashRing->getValue(repTarget).compare(leaderIP) == 0)) { repTarget = hashRing->getRandomNode(tuple<int, int, int>(hashRingPosition, hashRingPosition, hashRingPosition)); } }