for (PeerAddress r1 : listAdded) {
peerMap.peerFound(r1, null, null);
}
for (int i = 0; i < 100; i++) {
PeerAddress removed = listAdded.get(random.nextInt(i + 1));
if (peerMap.peerFailed(removed, new PeerException(AbortCause.SHUTDOWN, "shutdown"))) {
listRemoved.add(removed);
}
}
for (PeerAddress r1 : listAdded) {
peerMap.peerFound(r1, r1, null);
}
Assert.assertEquals(47, peerMap.size());
for (PeerAddress r1 : listRemoved) {
Assert.assertTrue(peerMap.isPeerRemovedTemporarly(r1));
}
//
for (PeerAddress r1 : listRemoved) {
listAdded.remove(r1);
}
for (int i = 0; i < 300; i++) {
PeerAddress removed = listAdded.get(random.nextInt(i + 1));
peerMap.peerFailed(removed, new PeerException(AbortCause.SHUTDOWN, "shutdown"));
}
for (PeerAddress r1 : listRemoved) {
Assert.assertTrue(peerMap.isPeerRemovedTemporarly(r1));
}
System.err.println("Time used: " + (System.currentTimeMillis() - start)