modified leave method. all nodes are linked circularly.
This commit is contained in:
parent
64b1e0dc04
commit
6a2215a491
@ -100,31 +100,13 @@ public class Node {
|
||||
|
||||
try {
|
||||
if (neighbors.size() > 2) {
|
||||
if (i == 0) {
|
||||
|
||||
putAddrInBuf(buf, neighbors.get(1));
|
||||
channel.send(buf, neighbors.get(i));
|
||||
|
||||
putAddrInBuf(buf, neighbors.get(neighbors.size() - 1));
|
||||
channel.send(buf, neighbors.get(i));
|
||||
|
||||
} else if (i == neighbors.size() - 1) {
|
||||
|
||||
putAddrInBuf(buf, neighbors.get(0));
|
||||
channel.send(buf, neighbors.get(i));
|
||||
|
||||
putAddrInBuf(buf, neighbors.get(i - 1));
|
||||
channel.send(buf, neighbors.get(i));
|
||||
|
||||
} else {
|
||||
|
||||
putAddrInBuf(buf, neighbors.get(i - 1));
|
||||
channel.send(buf, neighbors.get(i));
|
||||
|
||||
putAddrInBuf(buf, neighbors.get(i + 1));
|
||||
channel.send(buf, neighbors.get(i));
|
||||
}
|
||||
int pred = ((i - 1) + neighbors.size()) % neighbors.size();
|
||||
int succ = (i + 1) % neighbors.size();
|
||||
|
||||
putAddrInBuf(buf, neighbors.get(succ));
|
||||
channel.send(buf, neighbors.get(i));
|
||||
putAddrInBuf(buf, neighbors.get(pred));
|
||||
channel.send(buf, neighbors.get(i));
|
||||
} else if (neighbors.size() == 2) {
|
||||
putAddrInBuf(buf, neighbors.get(Math.abs(i - 1)));
|
||||
channel.send(buf, neighbors.get(i));
|
||||
@ -261,4 +243,4 @@ public class Node {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user