mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Remove replication frontend implementation in favor of Chronicle Engine
This commit is contained in:
@@ -16,18 +16,10 @@
|
||||
|
||||
package net.openhft.chronicle.set;
|
||||
|
||||
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
import net.openhft.chronicle.hash.serialization.SizeMarshaller;
|
||||
import net.openhft.chronicle.map.ChronicleMap;
|
||||
import net.openhft.chronicle.map.ChronicleMapBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author Rob Austin.
|
||||
@@ -80,29 +72,4 @@ public class Builder {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T extends ChronicleMap<Integer, DummyValue>> T newMapDummyValue(
|
||||
final byte identifier,
|
||||
final int serverPort,
|
||||
final InetSocketAddress... endpoints) throws IOException {
|
||||
return (T) newTcpSocketShmBuilder(Integer.class, DummyValue.class,
|
||||
identifier, serverPort, endpoints)
|
||||
.valueReaderAndDataAccess(
|
||||
DummyValueMarshaller.INSTANCE, DummyValueMarshaller.INSTANCE)
|
||||
.valueSizeMarshaller(SizeMarshaller.constant(0))
|
||||
.create();
|
||||
}
|
||||
|
||||
public static <K, V> ChronicleMapBuilder<K, V> newTcpSocketShmBuilder(
|
||||
Class<K> kClass, Class<V> vClass,
|
||||
final byte identifier,
|
||||
final int serverPort,
|
||||
final InetSocketAddress... endpoints) throws IOException {
|
||||
TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig
|
||||
.of(serverPort, Arrays.asList(endpoints))
|
||||
.heartBeatInterval(1L, TimeUnit.SECONDS).autoReconnectedUponDroppedConnection(true);
|
||||
return ChronicleMapBuilder.of(kClass, vClass)
|
||||
.entries(SIZE)
|
||||
.replication(identifier, tcpConfig);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 higherfrequencytrading.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.openhft.chronicle.set;
|
||||
|
||||
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static net.openhft.chronicle.set.Builder.getPersistenceFile;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test Replicated Chronicle Set where the replication is over a TCP Socket
|
||||
*
|
||||
* @author Rob Austin.
|
||||
*/
|
||||
public class SetForTCPSocketReplication3wayTest {
|
||||
|
||||
private ChronicleSet<Integer> set1;
|
||||
private ChronicleSet<Integer> set2;
|
||||
private ChronicleSet<Integer> set3;
|
||||
|
||||
private static <T extends ChronicleSet<Integer>> T newTcpSocketIntSet(
|
||||
final byte identifier,
|
||||
final int serverPort,
|
||||
final InetSocketAddress... endpoints) throws IOException {
|
||||
return (T) ChronicleSet.of(Integer.class)
|
||||
.entries(10)
|
||||
.replication(identifier, TcpTransportAndNetworkConfig.of(serverPort, asList(endpoints))
|
||||
.heartBeatInterval(1L, SECONDS).autoReconnectedUponDroppedConnection(true))
|
||||
.createPersistedTo(getPersistenceFile());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() throws IOException {
|
||||
set1 = newTcpSocketIntSet((byte) 1, 18076, new InetSocketAddress("localhost", 18077),
|
||||
new InetSocketAddress("localhost", 18079));
|
||||
set2 = newTcpSocketIntSet((byte) 2, 18077, new InetSocketAddress("localhost", 18079));
|
||||
set3 = newTcpSocketIntSet((byte) 3, 18079);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws InterruptedException {
|
||||
|
||||
for (final Closeable closeable : new Closeable[]{set1, set2, set3}) {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
System.gc();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test3() throws IOException, InterruptedException {
|
||||
|
||||
set3.add(5);
|
||||
|
||||
// allow time for the recompilation to resolve
|
||||
waitTillEqual(15000);
|
||||
|
||||
assertEquals(set1, set2);
|
||||
assertEquals(set2, set2);
|
||||
assertTrue(!set1.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws IOException, InterruptedException {
|
||||
|
||||
set1.add(1);
|
||||
set1.add(2);
|
||||
set1.add(2);
|
||||
|
||||
set2.add(5);
|
||||
set2.add(6);
|
||||
|
||||
set1.remove(2);
|
||||
set2.remove(3);
|
||||
set1.remove(3);
|
||||
set2.add(5);
|
||||
|
||||
// allow time for the recompilation to resolve
|
||||
waitTillEqual(5000);
|
||||
|
||||
assertEquals(set1, set2);
|
||||
assertEquals(set2, set3);
|
||||
assertTrue(!set1.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClear() throws IOException, InterruptedException {
|
||||
|
||||
set1.add(1);
|
||||
set1.add(2);
|
||||
set1.add(2);
|
||||
|
||||
set2.add(5);
|
||||
set2.add(6);
|
||||
|
||||
set1.clear();
|
||||
|
||||
set2.add(5);
|
||||
|
||||
Thread.sleep(100);
|
||||
|
||||
// allow time for the recompilation to resolve
|
||||
waitTillEqual(15000);
|
||||
|
||||
assertEquals(set1, set2);
|
||||
assertEquals(set2, set3);
|
||||
assertTrue(!set1.isEmpty());
|
||||
}
|
||||
|
||||
private void waitTillEqual(final int timeOutMs) throws InterruptedException {
|
||||
int t = 0;
|
||||
for (; t < timeOutMs; t++) {
|
||||
if (set1.equals(set2) &&
|
||||
set1.equals(set3) &&
|
||||
set2.equals(set3))
|
||||
break;
|
||||
Thread.sleep(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,239 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 higherfrequencytrading.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.openhft.chronicle.set;
|
||||
|
||||
import net.openhft.chronicle.hash.replication.ReplicableEntry;
|
||||
import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig;
|
||||
import net.openhft.chronicle.map.ChannelReplicationTest;
|
||||
import net.openhft.chronicle.set.replication.SetRemoteOperations;
|
||||
import net.openhft.chronicle.set.replication.SetRemoteQueryContext;
|
||||
import net.openhft.chronicle.set.replication.SetReplicableEntry;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static net.openhft.chronicle.hash.replication.DefaultEventualConsistencyStrategy.AcceptanceDecision.ACCEPT;
|
||||
import static net.openhft.chronicle.hash.replication.DefaultEventualConsistencyStrategy.AcceptanceDecision.DISCARD;
|
||||
import static net.openhft.chronicle.hash.replication.DefaultEventualConsistencyStrategy.decideOnRemoteModification;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class SetRemoteOperationsTest {
|
||||
|
||||
static int s_port = 12050;
|
||||
private ChronicleSet<Integer> set1;
|
||||
private ChronicleSet<Integer> set2;
|
||||
private AtomicInteger set1PutCounter;
|
||||
private AtomicInteger set2PutCounter;
|
||||
private AtomicInteger set1RemoveCounter;
|
||||
private AtomicInteger set2RemoveCounter;
|
||||
|
||||
@Before
|
||||
public void setup() throws IOException {
|
||||
int port = s_port;
|
||||
set1PutCounter = new AtomicInteger();
|
||||
set1RemoveCounter = new AtomicInteger();
|
||||
ChronicleSetBuilder<Integer> set1Builder = ChronicleSet
|
||||
.of(Integer.class)
|
||||
.remoteOperations(new SetRemoteOperations<Integer, Void>() {
|
||||
@Override
|
||||
public void remove(SetRemoteQueryContext<Integer, Void> q) {
|
||||
SetReplicableEntry<Integer> entry = q.entry();
|
||||
if (entry != null) {
|
||||
if (decideOnRemoteModification(entry, q) == ACCEPT) {
|
||||
q.remove(entry);
|
||||
ReplicableEntry replicableAbsentEntry =
|
||||
(ReplicableEntry) q.absentEntry();
|
||||
replicableAbsentEntry
|
||||
.updateOrigin(q.remoteIdentifier(), q.remoteTimestamp());
|
||||
replicableAbsentEntry.dropChanged();
|
||||
set1RemoveCounter.addAndGet(1);
|
||||
}
|
||||
} else {
|
||||
SetAbsentEntry<Integer> absentEntry = q.absentEntry();
|
||||
ReplicableEntry replicableAbsentEntry;
|
||||
if (!(absentEntry instanceof ReplicableEntry)) {
|
||||
absentEntry.doInsert();
|
||||
q.entry().doRemove();
|
||||
replicableAbsentEntry = (ReplicableEntry) q.absentEntry();
|
||||
} else {
|
||||
replicableAbsentEntry = (ReplicableEntry) absentEntry;
|
||||
if (decideOnRemoteModification(replicableAbsentEntry, q) == DISCARD)
|
||||
return;
|
||||
}
|
||||
replicableAbsentEntry
|
||||
.updateOrigin(q.remoteIdentifier(), q.remoteTimestamp());
|
||||
replicableAbsentEntry.dropChanged();
|
||||
set1RemoveCounter.addAndGet(1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(SetRemoteQueryContext<Integer, Void> q) {
|
||||
SetReplicableEntry<Integer> entry = q.entry();
|
||||
if (entry != null) {
|
||||
if (decideOnRemoteModification(entry, q) == ACCEPT) {
|
||||
entry.updateOrigin(q.remoteIdentifier(), q.remoteTimestamp());
|
||||
entry.dropChanged();
|
||||
set1PutCounter.addAndGet(1);
|
||||
}
|
||||
} else {
|
||||
SetAbsentEntry<Integer> absentEntry = q.absentEntry();
|
||||
assert absentEntry != null;
|
||||
if (!(absentEntry instanceof ReplicableEntry) ||
|
||||
decideOnRemoteModification((ReplicableEntry) absentEntry, q) ==
|
||||
ACCEPT) {
|
||||
q.insert(absentEntry);
|
||||
entry = q.entry(); // q.entry() is not null after insert
|
||||
assert entry != null;
|
||||
entry.updateOrigin(q.remoteIdentifier(), q.remoteTimestamp());
|
||||
entry.dropChanged();
|
||||
set1PutCounter.addAndGet(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.replication((byte) 1, TcpTransportAndNetworkConfig
|
||||
.of(port, new InetSocketAddress("localhost", port + 1)));
|
||||
set1 = set1Builder.entries(Builder.SIZE).create();
|
||||
|
||||
set2PutCounter = new AtomicInteger();
|
||||
set2RemoveCounter = new AtomicInteger();
|
||||
ChronicleSetBuilder<Integer> set2Builder = ChronicleSet
|
||||
.of(Integer.class)
|
||||
.remoteOperations(new SetRemoteOperations<Integer, Void>() {
|
||||
@Override
|
||||
public void remove(SetRemoteQueryContext<Integer, Void> q) {
|
||||
SetReplicableEntry<Integer> entry = q.entry();
|
||||
if (entry != null) {
|
||||
if (decideOnRemoteModification(entry, q) == ACCEPT) {
|
||||
q.remove(entry);
|
||||
ReplicableEntry replicableAbsentEntry =
|
||||
(ReplicableEntry) q.absentEntry();
|
||||
replicableAbsentEntry
|
||||
.updateOrigin(q.remoteIdentifier(), q.remoteTimestamp());
|
||||
replicableAbsentEntry.dropChanged();
|
||||
set2RemoveCounter.addAndGet(1);
|
||||
}
|
||||
} else {
|
||||
SetAbsentEntry<Integer> absentEntry = q.absentEntry();
|
||||
ReplicableEntry replicableAbsentEntry;
|
||||
if (!(absentEntry instanceof ReplicableEntry)) {
|
||||
absentEntry.doInsert();
|
||||
q.entry().doRemove();
|
||||
replicableAbsentEntry = (ReplicableEntry) q.absentEntry();
|
||||
} else {
|
||||
replicableAbsentEntry = (ReplicableEntry) absentEntry;
|
||||
if (decideOnRemoteModification(replicableAbsentEntry, q) == DISCARD)
|
||||
return;
|
||||
}
|
||||
replicableAbsentEntry
|
||||
.updateOrigin(q.remoteIdentifier(), q.remoteTimestamp());
|
||||
replicableAbsentEntry.dropChanged();
|
||||
set2RemoveCounter.addAndGet(1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(SetRemoteQueryContext<Integer, Void> q) {
|
||||
SetReplicableEntry<Integer> entry = q.entry();
|
||||
if (entry != null) {
|
||||
if (decideOnRemoteModification(entry, q) == ACCEPT) {
|
||||
entry.updateOrigin(q.remoteIdentifier(), q.remoteTimestamp());
|
||||
entry.dropChanged();
|
||||
set2PutCounter.addAndGet(1);
|
||||
}
|
||||
} else {
|
||||
SetAbsentEntry<Integer> absentEntry = q.absentEntry();
|
||||
assert absentEntry != null;
|
||||
if (!(absentEntry instanceof ReplicableEntry) ||
|
||||
decideOnRemoteModification((ReplicableEntry) absentEntry, q) ==
|
||||
ACCEPT) {
|
||||
q.insert(absentEntry);
|
||||
entry = q.entry(); // q.entry() is not null after insert
|
||||
assert entry != null;
|
||||
entry.updateOrigin(q.remoteIdentifier(), q.remoteTimestamp());
|
||||
entry.dropChanged();
|
||||
set2PutCounter.addAndGet(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.replication((byte) 2, TcpTransportAndNetworkConfig.of(port + 1));
|
||||
set2 = set2Builder.entries(Builder.SIZE).create();
|
||||
s_port += 2;
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws InterruptedException {
|
||||
|
||||
for (final Closeable closeable : new Closeable[]{set1, set2}) {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
System.gc();
|
||||
}
|
||||
|
||||
Set<Thread> threads;
|
||||
|
||||
@Before
|
||||
public void sampleThreads() {
|
||||
threads = Thread.getAllStackTraces().keySet();
|
||||
}
|
||||
|
||||
@After
|
||||
public void checkThreadsShutdown() {
|
||||
ChannelReplicationTest.checkThreadsShutdown(threads);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setRemoteOperationsTest() throws InterruptedException {
|
||||
set1.add(1);
|
||||
set2.add(2);
|
||||
|
||||
waitTillEqual(5000);
|
||||
assertEquals(set1, set2);
|
||||
|
||||
set1.remove(2);
|
||||
set2.remove(1);
|
||||
|
||||
waitTillEqual(5000);
|
||||
assertEquals(set1, set2);
|
||||
|
||||
assertEquals(1, set1PutCounter.get());
|
||||
assertEquals(1, set2PutCounter.get());
|
||||
assertEquals(1, set1RemoveCounter.get());
|
||||
assertEquals(1, set2RemoveCounter.get());
|
||||
}
|
||||
|
||||
private void waitTillEqual(final int timeOutMs) throws InterruptedException {
|
||||
int t = 0;
|
||||
for (; t < timeOutMs; t++) {
|
||||
if (set1.equals(set2))
|
||||
break;
|
||||
Thread.sleep(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 higherfrequencytrading.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.openhft.chronicle.set;
|
||||
|
||||
import net.openhft.chronicle.map.ChannelReplicationTest;
|
||||
import net.openhft.chronicle.map.ChronicleMap;
|
||||
import net.openhft.chronicle.set.DummyValue;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.openhft.chronicle.set.DummyValue.DUMMY_VALUE;
|
||||
import static net.openhft.chronicle.set.Builder.newMapDummyValue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test ReplicatedChronicleMap where the Replicated is over a TCP Socket
|
||||
*
|
||||
* @author Rob Austin.
|
||||
*/
|
||||
public class TCPSocketReplication3VoidValueTest {
|
||||
|
||||
private ChronicleMap<Integer, DummyValue> map1;
|
||||
private ChronicleMap<Integer, DummyValue> map2;
|
||||
private ChronicleMap<Integer, DummyValue> map3;
|
||||
|
||||
@Before
|
||||
public void setup() throws IOException {
|
||||
map1 = newMapDummyValue((byte) 1, 8036, new InetSocketAddress("localhost", 8037),
|
||||
new InetSocketAddress("localhost", 8039));
|
||||
map2 = newMapDummyValue((byte) 2, 8037, new InetSocketAddress("localhost", 8039));
|
||||
map3 = newMapDummyValue((byte) 3, 8039);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws InterruptedException {
|
||||
for (final Closeable closeable : new Closeable[]{map1, map2, map3}) {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
System.gc();
|
||||
}
|
||||
|
||||
Set<Thread> threads;
|
||||
|
||||
@Before
|
||||
public void sampleThreads() {
|
||||
threads = Thread.getAllStackTraces().keySet();
|
||||
}
|
||||
|
||||
@After
|
||||
public void checkThreadsShutdown() {
|
||||
ChannelReplicationTest.checkThreadsShutdown(threads);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test3() throws IOException, InterruptedException {
|
||||
|
||||
assertEquals(null, map3.put(5, DUMMY_VALUE));
|
||||
|
||||
// allow time for the recompilation to resolve
|
||||
assertTrue(waitTillEqual(15000));
|
||||
|
||||
assertEquals(map3, map2);
|
||||
assertTrue(!map1.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws IOException, InterruptedException {
|
||||
|
||||
assertEquals(null, map1.put(1, DUMMY_VALUE));
|
||||
assertEquals(null, map1.put(2, DUMMY_VALUE));
|
||||
|
||||
assertEquals(null, map2.put(5, DUMMY_VALUE));
|
||||
assertEquals(null, map2.put(6, DUMMY_VALUE));
|
||||
|
||||
map1.remove(2);
|
||||
map2.remove(3);
|
||||
map1.remove(3);
|
||||
map2.put(5, DUMMY_VALUE);
|
||||
|
||||
// allow time for the recompilation to resolve
|
||||
waitTillEqual(5000);
|
||||
|
||||
assertEquals(map3, map3);
|
||||
assertTrue(!map1.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClear() throws IOException, InterruptedException {
|
||||
|
||||
assertEquals(null, map1.put(1, DUMMY_VALUE));
|
||||
assertEquals(null, map1.put(2, DUMMY_VALUE));
|
||||
|
||||
assertEquals(null, map2.put(5, DUMMY_VALUE));
|
||||
assertEquals(null, map2.put(6, DUMMY_VALUE));
|
||||
|
||||
map1.clear();
|
||||
|
||||
map2.put(5, DUMMY_VALUE);
|
||||
|
||||
// allow time for the recompilation to resolve
|
||||
assertTrue("test timed out", waitTillEqual(15000));
|
||||
|
||||
assertEquals(map3, map3);
|
||||
assertTrue(!map1.isEmpty());
|
||||
}
|
||||
|
||||
private boolean waitTillEqual(final int timeOutMs) throws InterruptedException {
|
||||
int t = 0;
|
||||
for (; t < timeOutMs; t++) {
|
||||
if (map1.equals(map2) &&
|
||||
map1.equals(map3) &&
|
||||
map2.equals(map3))
|
||||
return true;
|
||||
Thread.sleep(1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user