mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-167 now using the builder to create the Stateless client
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.testng.Assert;
|
||||
|
||||
@@ -8,6 +7,7 @@ import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static net.openhft.chronicle.StatelessBuilder.remoteAddress;
|
||||
import static net.openhft.chronicle.map.Builder.getPersistenceFile;
|
||||
import static net.openhft.chronicle.map.TcpReplicationConfig.of;
|
||||
|
||||
@@ -18,26 +18,38 @@ public class StatelessClientTest {
|
||||
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void test() throws IOException, InterruptedException {
|
||||
|
||||
ChronicleMapBuilder<Integer, CharSequence> builder =
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(20000L)
|
||||
.replicators((byte) 2, of(8076).heartBeatInterval(1L, SECONDS));
|
||||
final ChronicleMap<Integer, CharSequence> serverMap;
|
||||
final ChronicleMap<Integer, CharSequence> statelessMap;
|
||||
|
||||
// server
|
||||
{
|
||||
final ChronicleMap<Integer, CharSequence> map2a =
|
||||
builder.create(getPersistenceFile());
|
||||
map2a.put(10, "EXAMPLE-10"); // this will be the last time that map1 go an update from map2
|
||||
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(20000L)
|
||||
.replicators((byte) 2, of(8076).heartBeatInterval(1L, SECONDS))
|
||||
.create(getPersistenceFile());
|
||||
|
||||
serverMap.put(10, "EXAMPLE-10");
|
||||
}
|
||||
|
||||
KeyValueSerializer keyValueSerializer = new KeyValueSerializer(builder.keyBuilder, builder.valueBuilder);
|
||||
|
||||
InetSocketAddress remote = new InetSocketAddress("localhost", 8076);
|
||||
StatelessMapClient<Integer, String> map = new StatelessMapClient<Integer, String>(keyValueSerializer, remote);
|
||||
// stateless client
|
||||
{
|
||||
statelessMap = ChronicleMapBuilder.of(Integer
|
||||
.class, CharSequence.class)
|
||||
.stateless(remoteAddress(new InetSocketAddress("localhost", 8076))).create();
|
||||
|
||||
Assert.assertEquals("EXAMPLE-10", statelessMap.get(10));
|
||||
Assert.assertEquals(1, statelessMap.size());
|
||||
}
|
||||
|
||||
serverMap.close();
|
||||
statelessMap.close();
|
||||
|
||||
Assert.assertEquals("EXAMPLE-10", map.get(10));
|
||||
Assert.assertEquals(1, map.size());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user