From ad5d3c5de9d7413eec75346b484a29d59abeb6c5 Mon Sep 17 00:00:00 2001 From: afederici <ajf5@illinois.edu> Date: Sun, 29 Nov 2020 06:18:56 -0600 Subject: [PATCH] new replication -> pt8 --- Wc | Bin 189120 -> 189120 bytes Wr | Bin 184720 -> 184720 bytes src/Node.cpp | 16 ++++++++-------- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Wc b/Wc index f72847e6467c730b16399f879f70fa0037ab2ac8..b6bceb0a54be988e6a693f24503be024ae36cd4f 100755 GIT binary patch delta 68 zcmV-K0K5Od#S6g23xKo%@OT1Uj<@o70nRo8UXHiIuK~KU4q`DkIbt&|ZvbCyVQFrc a5orQ4x4dEkEj$J^WnyJBGq>-a0?|Y5avMef delta 68 zcmV-K0K5Od#S6g23xKo%@OT10h_~{10nRo8K!~@(uK~KU4l-srW;10jZvbCyVQFrc a5orQ4x4dEkEj$J=HZ@{pWVi300?|X|0~<8} diff --git a/Wr b/Wr index 99040bdeffdbc456762b8d3ffc2c865e8d60b972..0eefbe6fb71904f4d44313d9ee0aaf0a0cc1b668 100755 GIT binary patch delta 68 zcmbQRn0vxv?uIRl9u-XSecQb%82t=Ej9Dugm#*crFg7qxOVP_`h|f*T%$xr152Mlc X`fw&2Gd9D-B#Y$a?FW0A&N~ADZ;=_N delta 68 zcmbQRn0vxv?uIRl9u-WE9oxMs82t=Ej9Dugm#*bAG&3<zGSbUuh|f*T%$xr152Mlc X`fw&2Gq%KJQ^T~h?FW0A&N~ADTAmp# diff --git a/src/Node.cpp b/src/Node.cpp index d474d58..42e187a 100644 --- a/src/Node.cpp +++ b/src/Node.cpp @@ -64,19 +64,19 @@ void Node::debugOutputRep(){ set<int> members; set<string> membersIP; set<int> locations; - string debug = "[DEBUGREP] ---------------------------\n"; + string debug = "[DEBUGREP] ---------------------------\n", randSenderIp; vector<tuple<string,string,int>> toDel; bool added = false; vector<int> randSender; tuple<string,int> minKey; - int minVal; + int minVal, repTarget; for (auto pos : hashRing->nodePositions) { members.insert(pos); membersIP.insert(hashRing->getValue(pos)); } for (auto &mapping : outputReplication){ minVal = 100; randSender.clear(); locations.clear(); - string randSenderIp = ""; - int repTarget = 0; + randSenderIp = ""; + repTarget = -1; for (auto &f: fileList[mapping.first]) locations.insert(f); for (auto &reps: mapping.second){ if (reps.second < minVal){ @@ -100,13 +100,13 @@ void Node::debugOutputRep(){ int index = 0; if (!randSender.size()) randSender.push_back(get<1>(minKey)); repTarget = hashRing->getRandomNode(tuple<int,int,int>(get<1>(minKey), get<1>(minKey), randSender[0])); - while (locations.count(repTarget) && index < 20){ + while (((repTarget == -1) || locations.count(repTarget)) && index < 20){ repTarget = hashRing->getRandomNode(tuple<int,int,int>(get<1>(minKey), repTarget, randSender[0])); index++; } } - if (randSenderIp.size() || repTarget){ - if (!repTarget) repTarget = get<1>(minKey); + if (randSenderIp.size() || (repTarget != -1)){ + if (repTarget == -1) repTarget = get<1>(minKey); if (!randSenderIp.size()) randSenderIp = get<0>(minKey); outputReplication[mapping.first][make_tuple(randSenderIp,repTarget)] = minVal; Messages outMsg(REP, randSenderIp + "::" + hashRing->getValue(repTarget)+"::"+to_string(minVal)+"::"+mapping.first+"::"+to_string(get<0>(fileSizes[mapping.first]))); @@ -1484,7 +1484,7 @@ void Node::handleTcpMessage() case REP: { //Messages outMsg(REP, randSenderIp + "::" + hashRing->getValue(repTarget)+"::"+to_string(minVal)+"::"+mapping.first+"::"+to_string(get<0>(fileSizes[mapping.first]))); if (inMsg[0].compare(nodeInformation.ip)){ - this->tcpServent->sendMessage(inMsg[0], TCPPORT, inMsg[1] + "::" + inMsg[2] + "::" + inMsg[3] + "::" + inMsg[4]); + this->tcpServent->sendMessage(inMsg[0], TCPPORT, inMsg[0] + "::" + inMsg[1] + "::" + inMsg[2] + "::" + inMsg[3] + "::" + inMsg[4]); } else{ string sendMsg = inMsg[1] + "::" + to_string(REPACK) + "::" + inMsg[3] + "::" + inMsg[2] + "::" + inMsg[3] + "," + inMsg[4] + "::"; -- GitLab