mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
updated the wait till equal on the TcpSocketReplicationTest
This commit is contained in:
@@ -25,6 +25,8 @@ import org.junit.Test;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -176,10 +178,27 @@ public class TCPSocketReplicationTest {
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
private void waitTillEqual(final int timeOutMs) throws InterruptedException {
|
||||
int t = 0;
|
||||
for (; t < timeOutMs; t++) {
|
||||
if (map1.equals(map2))
|
||||
break;
|
||||
|
||||
Map map1UnChanged = new HashMap();
|
||||
Map map2UnChanged = new HashMap();
|
||||
|
||||
int numberOfTimesTheSame = 0;
|
||||
for (int t = 0; t < timeOutMs + 100; t++) {
|
||||
if (map1.equals(map2)) {
|
||||
if (map1.equals(map1UnChanged) && map2.equals(map2UnChanged)) {
|
||||
numberOfTimesTheSame++;
|
||||
} else {
|
||||
numberOfTimesTheSame = 0;
|
||||
map1UnChanged = new HashMap(map1);
|
||||
map2UnChanged = new HashMap(map2);
|
||||
}
|
||||
Thread.sleep(1);
|
||||
if (numberOfTimesTheSame == 100) {
|
||||
System.out.println("same");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
Thread.sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user