mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
reverted cff7c5bea8
This commit is contained in:
@@ -52,7 +52,7 @@ public class BigData {
|
||||
String chmPath = dir + "/testmap-" + Long.toString(System.nanoTime(), 36);
|
||||
new File(chmPath).deleteOnExit();
|
||||
try {
|
||||
theMap = builder.file(new File(chmPath)).create();
|
||||
theMap = builder.createPersistedTo(new File(chmPath));
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -29,7 +29,9 @@ import static org.junit.Assert.fail;
|
||||
public class AcquireGetUsingMain {
|
||||
public static void main(String[] args) throws Exception {
|
||||
File file = new File(System.getProperty("java.io.tmpdir") + "/test1");
|
||||
ChronicleMap<String, Data> theSharedMap = OffHeapUpdatableChronicleMapBuilder.of(String.class, Data.class).file(file).create();
|
||||
ChronicleMap<String, Data> theSharedMap =
|
||||
OffHeapUpdatableChronicleMapBuilder.of(String.class, Data.class)
|
||||
.createPersistedTo(file);
|
||||
Data data = DataValueClasses.newDirectReference(Data.class);
|
||||
String processType = "testkey";
|
||||
if (theSharedMap.getUsing(processType, data) == null) {
|
||||
|
||||
@@ -19,12 +19,13 @@
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
|
||||
import net.openhft.chronicle.hash.TcpReplicationConfig;
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@@ -71,10 +72,10 @@ public class Builder {
|
||||
final byte identifier,
|
||||
final int serverPort,
|
||||
final InetSocketAddress... endpoints) throws IOException {
|
||||
TcpReplicationConfig tcpConfig = TcpReplicationConfig.of(serverPort, endpoints)
|
||||
TcpConfig tcpConfig = TcpConfig.unknownTopology(serverPort, Arrays.asList(endpoints))
|
||||
.heartBeatInterval(1L, TimeUnit.SECONDS);
|
||||
return ChronicleMapBuilder.of(kClass, vClass)
|
||||
.replicators(identifier, tcpConfig);
|
||||
.replication(identifier, tcpConfig);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public class CHMLatencyTestMain {
|
||||
OffHeapUpdatableChronicleMapBuilder.of(LongValue.class, LongValue.class)
|
||||
.entries(KEYS)
|
||||
.entrySize(16)
|
||||
.createWithFile(file);
|
||||
.createPersistedTo(file);
|
||||
|
||||
// add keys
|
||||
LongValue key = DataValueClasses.newInstance(LongValue.class);
|
||||
|
||||
@@ -44,7 +44,8 @@ public class CHMTest5 {
|
||||
|
||||
String chmPath = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "CHMTest5";
|
||||
|
||||
ChronicleMap<String, CHMTest5Data> theSharedMap = builder.file(new File(chmPath)).create();
|
||||
ChronicleMap<String, CHMTest5Data> theSharedMap =
|
||||
builder.createPersistedTo(new File(chmPath));
|
||||
|
||||
//Now get the shared data object, auto-creating if it's not there
|
||||
CHMTest5Data data = DataValueClasses.newDirectReference(CHMTest5Data.class);
|
||||
|
||||
@@ -19,9 +19,8 @@
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
|
||||
import net.openhft.chronicle.hash.ChannelProvider;
|
||||
import net.openhft.chronicle.hash.ChannelProviderBuilder;
|
||||
import net.openhft.chronicle.hash.TcpReplicationConfig;
|
||||
import net.openhft.chronicle.hash.replication.ReplicationHub;
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
@@ -47,44 +46,44 @@ public class ChannelReplicationTest {
|
||||
private ChronicleMap<Integer, CharSequence> map1b;
|
||||
private ChronicleMap<Integer, CharSequence> map2b;
|
||||
|
||||
private ChannelProvider channelProviderA;
|
||||
private ChannelProvider channelProviderB;
|
||||
private ReplicationHub hubA;
|
||||
private ReplicationHub hubB;
|
||||
|
||||
|
||||
@Before
|
||||
|
||||
public void setup() throws IOException {
|
||||
{
|
||||
TcpReplicationConfig tcpConfig = TcpReplicationConfig
|
||||
.of(8086, new InetSocketAddress("localhost", 8087))
|
||||
TcpConfig tcpConfig = TcpConfig
|
||||
.forSendingNode(8086, new InetSocketAddress("localhost", 8087))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
|
||||
channelProviderA = new ChannelProviderBuilder()
|
||||
.replicators((byte) 1, tcpConfig)
|
||||
.create();
|
||||
hubA = ReplicationHub.builder()
|
||||
.tcpTransportAndNetwork(tcpConfig)
|
||||
.create((byte) 1);
|
||||
|
||||
map1a = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(channelProviderA.createChannel((short) 1)).create();
|
||||
.instance().replicatedViaChannel(hubA.createChannel((short) 1)).create();
|
||||
}
|
||||
|
||||
{
|
||||
TcpReplicationConfig tcpConfig =
|
||||
TcpReplicationConfig.of(8087).heartBeatInterval(1, SECONDS);
|
||||
TcpConfig tcpConfig =
|
||||
TcpConfig.forReceivingOnlyNode(8087).heartBeatInterval(1, SECONDS);
|
||||
|
||||
channelProviderB = new ChannelProviderBuilder().replicators((byte) 2, tcpConfig)
|
||||
.create();
|
||||
hubB = ReplicationHub.builder().tcpTransportAndNetwork(tcpConfig)
|
||||
.create((byte) 2);
|
||||
|
||||
map1b = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(channelProviderB.createChannel((short) 1)).create();
|
||||
.instance().replicatedViaChannel(hubB.createChannel((short) 1)).create();
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws InterruptedException {
|
||||
|
||||
for (final Closeable closeable : new Closeable[]{channelProviderA, channelProviderB}) {
|
||||
for (final Closeable closeable : new Closeable[]{map1a, map1b, map2a, map2b}) {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (IOException e) {
|
||||
@@ -99,12 +98,12 @@ public class ChannelReplicationTest {
|
||||
|
||||
map2b = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(channelProviderB.createChannel((short) 2)).create();
|
||||
.instance().replicatedViaChannel(hubB.createChannel((short) 2)).create();
|
||||
|
||||
|
||||
map2a = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(channelProviderA.createChannel((short) 2)).create();
|
||||
.instance().replicatedViaChannel(hubA.createChannel((short) 2)).create();
|
||||
|
||||
map2a.put(1, "EXAMPLE-2");
|
||||
map1a.put(1, "EXAMPLE-1");
|
||||
|
||||
@@ -529,6 +529,79 @@ public class ChronicleMapTest {
|
||||
map.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testLeanEntrySizeInt() throws IOException {
|
||||
File file = File.createTempFile("testLeanEntrySize-Int", ".deleteme");
|
||||
file.deleteOnExit();
|
||||
int entries = 1000000;
|
||||
int entrySize = 8;
|
||||
ChronicleMap<IntValue, IntValue> map = OffHeapUpdatableChronicleMapBuilder
|
||||
.of(IntValue.class, IntValue.class)
|
||||
.entrySize(entrySize)
|
||||
.entries(entries)
|
||||
.create();
|
||||
IntValue key = DataValueClasses.newInstance(IntValue.class);
|
||||
IntValue value = DataValueClasses.newDirectReference(IntValue.class);
|
||||
for (int i = 0; i < entries; i++) {
|
||||
key.setValue(i);
|
||||
try (WriteContext wc = map.acquireUsingLocked(key, value)) {
|
||||
value.setValue(i);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < entries; i++) {
|
||||
key.setValue(i);
|
||||
try (ReadContext rc = map.getUsingLocked(key, value)) {
|
||||
assertTrue(rc.present());
|
||||
assertEquals(i, value.getValue());
|
||||
}
|
||||
}
|
||||
map.close();
|
||||
|
||||
// check the extents of the map.
|
||||
int hashSize = 8; // assume short-short hashing
|
||||
int sizePerEntry = hashSize * 2 + entrySize * 5 / 4 /* + 25% */;
|
||||
long fileSizeExpected = entries * sizePerEntry;
|
||||
long length = file.length();
|
||||
assertTrue(length > fileSizeExpected);
|
||||
assertTrue(length < fileSizeExpected * 12 / 10);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testLeanEntrySizeLong() throws IOException {
|
||||
File file = File.createTempFile("testLeanEntrySize-Long", ".deleteme");
|
||||
file.deleteOnExit();
|
||||
int entries = 1000000;
|
||||
int entrySize = 16;
|
||||
ChronicleMap<LongValue, LongValue> map = OffHeapUpdatableChronicleMapBuilder
|
||||
.of(LongValue.class, LongValue.class)
|
||||
.entrySize(entrySize)
|
||||
.entries(entries)
|
||||
.create();
|
||||
LongValue key = DataValueClasses.newInstance(LongValue.class);
|
||||
LongValue value = DataValueClasses.newDirectReference(LongValue.class);
|
||||
for (long i = 0; i < entries; i++) {
|
||||
key.setValue(i);
|
||||
map.acquireUsing(key, value);
|
||||
value.setValue(i);
|
||||
}
|
||||
for (long i = 0; i < entries; i++) {
|
||||
key.setValue(i);
|
||||
assertNotNull(map.getUsing(key, value));
|
||||
assertEquals(i, value.getValue());
|
||||
}
|
||||
map.close();
|
||||
|
||||
// check the extents of the map.
|
||||
int hashSize = 8; // assume short-short hashing
|
||||
int sizePerEntry = hashSize * 2 + entrySize * 5 / 4 /* + 25% */;
|
||||
long fileSizeExpected = entries * sizePerEntry;
|
||||
long length = file.length();
|
||||
assertTrue(length > fileSizeExpected);
|
||||
assertTrue(length < fileSizeExpected * 12 / 10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcquireFromMultipleThreads() throws Exception {
|
||||
int entries = 1000 * 1000;
|
||||
@@ -578,19 +651,19 @@ public class ChronicleMapTest {
|
||||
int procs = Runtime.getRuntime().availableProcessors();
|
||||
int threads = procs * 2; // runs > 100 ? procs / 2 : procs;
|
||||
ExecutorService es = Executors.newFixedThreadPool(procs);
|
||||
for (int runs : new int[]{10, 50, 250, 500, 1000, 2500}) {
|
||||
for (int runs : new int[]{10, 25, 50, 250, 500, 1000, 2500}) {
|
||||
// JAVA 8 produces more garbage than previous versions for internal work.
|
||||
// System.gc();
|
||||
final long entries = runs * 1000 * 1000L;
|
||||
OffHeapUpdatableChronicleMapBuilder<CharSequence, LongValue> builder = OffHeapUpdatableChronicleMapBuilder
|
||||
.of(CharSequence.class, LongValue.class)
|
||||
OffHeapUpdatableChronicleMapBuilder<LongValue, LongValue> builder = OffHeapUpdatableChronicleMapBuilder
|
||||
.of(LongValue.class, LongValue.class)
|
||||
.entries(entries)
|
||||
.entryAndValueAlignment(OF_8_BYTES)
|
||||
.entrySize(24);
|
||||
.entrySize(16);
|
||||
|
||||
File tmpFile = File.createTempFile("testAcquirePerf", ".deleteme");
|
||||
tmpFile.deleteOnExit();
|
||||
final ChronicleMap<CharSequence, LongValue> map = builder.createWithFile(tmpFile);
|
||||
final ChronicleMap<LongValue, LongValue> map = builder.createPersistedTo(tmpFile);
|
||||
|
||||
int count = runs > 500 ? runs > 1200 ? 3 : 5 : 5;
|
||||
final int independence = Math.min(procs, runs > 500 ? 8 : 4);
|
||||
@@ -603,16 +676,14 @@ public class ChronicleMapTest {
|
||||
futures.add(es.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LongValue key = DataValueClasses.newDirectInstance(LongValue.class);
|
||||
LongValue value = nativeLongValue();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
long next = 50 * 1000 * 1000;
|
||||
// use a factor to give up to 10 digit numbers.
|
||||
int factor = Math.max(1, (int) ((10 * 1000 * 1000 * 1000L - 1) / entries));
|
||||
for (long j = t % independence; j < entries + independence - 1; j += independence) {
|
||||
sb.setLength(0);
|
||||
sb.append("us:");
|
||||
sb.append(j * factor);
|
||||
map.acquireUsing(sb, value);
|
||||
key.setValue(j * factor);
|
||||
map.acquireUsing(key, value);
|
||||
long n = value.addAtomicValue(1);
|
||||
assert n > 0 && n < 1000 : "Counter corrupted " + n;
|
||||
if (t == 0 && j >= next) {
|
||||
@@ -639,6 +710,7 @@ public class ChronicleMapTest {
|
||||
es.shutdown();
|
||||
es.awaitTermination(1, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testAcquireLockedPerf()
|
||||
@@ -660,7 +732,7 @@ public class ChronicleMapTest {
|
||||
|
||||
File tmpFile = File.createTempFile("testAcquirePerf", ".deleteme");
|
||||
tmpFile.deleteOnExit();
|
||||
final ChronicleMap<CharSequence, LongValue> map = builder.createWithFile(tmpFile);
|
||||
final ChronicleMap<CharSequence, LongValue> map = builder.createPersistedTo(tmpFile);
|
||||
|
||||
int count = runs > 500 ? runs > 1200 ? 3 : 5 : 5;
|
||||
final int independence = Math.min(procs, runs > 500 ? 8 : 4);
|
||||
@@ -683,7 +755,7 @@ public class ChronicleMapTest {
|
||||
sb.append("us:");
|
||||
sb.append(j * factor);
|
||||
long n;
|
||||
try(WriteContext wc = map.acquireUsingLocked(sb, value)) {
|
||||
try (WriteContext wc = map.acquireUsingLocked(sb, value)) {
|
||||
n = value.addValue(1);
|
||||
}
|
||||
assert n > 0 && n < 1000 : "Counter corrupted " + n;
|
||||
@@ -1229,10 +1301,9 @@ public class ChronicleMapTest {
|
||||
.entries(10)
|
||||
.minSegments(1)
|
||||
.entrySize(10);
|
||||
builder.file(getPersistenceFile());
|
||||
testOversizeEntriesPutRemoveReplace(
|
||||
(VanillaChronicleMap<CharSequence, ?, ?, CharSequence, ?, ?>)
|
||||
builder.create()
|
||||
builder.createPersistedTo(getPersistenceFile())
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1334,7 +1405,7 @@ public class ChronicleMapTest {
|
||||
.entrySize(16);
|
||||
File tmpFile = File.createTempFile("testAcquireUsingLocked", ".deleteme");
|
||||
tmpFile.deleteOnExit();
|
||||
final ChronicleMap<CharSequence, LongValue> map = builder.createWithFile(tmpFile);
|
||||
final ChronicleMap<CharSequence, LongValue> map = builder.createPersistedTo(tmpFile);
|
||||
|
||||
LongValue value = nativeLongValue();
|
||||
|
||||
@@ -1391,7 +1462,7 @@ public class ChronicleMapTest {
|
||||
.entrySize(40);
|
||||
File tmpFile = File.createTempFile("testAcquireUsingLocked", ".deleteme");
|
||||
tmpFile.deleteOnExit();
|
||||
final ChronicleMap<CharSequence, LongValue> map = builder.createWithFile(tmpFile);
|
||||
final ChronicleMap<CharSequence, LongValue> map = builder.createPersistedTo(tmpFile);
|
||||
|
||||
LongValue value = DataValueClasses.newInstance(LongValue.class);
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class DefaultValueTest {
|
||||
defaultValue.add(42);
|
||||
try (ChronicleMap<String, List<Integer>> map = ChronicleMapBuilder
|
||||
.of(String.class, (Class<List<Integer>>) ((Class) List.class))
|
||||
.defaultValue(defaultValue).file(file).create()) {
|
||||
.defaultValue(defaultValue).createPersistedTo(file)) {
|
||||
|
||||
assertEquals(defaultValue, map.acquireUsing("a", null));
|
||||
assertEquals(1, map.size());
|
||||
@@ -49,8 +49,8 @@ public class DefaultValueTest {
|
||||
}
|
||||
|
||||
try (ChronicleMap<String, List<Integer>> map = ChronicleMapBuilder
|
||||
.of(String.class, (Class<List<Integer>>) ((Class) List.class)).file(file).
|
||||
create()) {
|
||||
.of(String.class, (Class<List<Integer>>) ((Class) List.class))
|
||||
.createPersistedTo(file)) {
|
||||
assertEquals(defaultValue, map.acquireUsing("c", null));
|
||||
}
|
||||
} finally {
|
||||
|
||||
@@ -55,9 +55,8 @@ public class EntryCountMapTest {
|
||||
.entries(entries)
|
||||
.minSegments(segments)
|
||||
.entrySize(entrySize)
|
||||
.entryAndValueAlignment(alignment)
|
||||
.file(getPersistenceFile());
|
||||
return mapBuilder.create();
|
||||
.entryAndValueAlignment(alignment);
|
||||
return mapBuilder.createPersistedTo(getPersistenceFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -29,15 +29,17 @@ import java.util.Arrays;
|
||||
/**
|
||||
* This example shows that the OS resizes the usage of a CHM as needed. It is not as critical to worry about this.
|
||||
* <p>
|
||||
* System memory: 7.7 GB, Extents of map: 2199.0 GB, disk used: 13MB, addressRange: 7d380b7bd000-7f380c000000
|
||||
* System memory: 7.7 GB, Extents of map: 100000.0 GB, disk used: 104MB, addressRange: 24e02a7fc000-7fd33c000000
|
||||
* </p>
|
||||
*/
|
||||
public class OSResizesMain {
|
||||
public static void main(String[] args) throws IOException, InterruptedException {
|
||||
File file = File.createTempFile("over-sized", "deleteme");
|
||||
ChronicleMap<String, String> map = ChronicleMapBuilder.of(String.class, String.class)
|
||||
.entrySize(100 * 1024 * 1024)
|
||||
.entries(1000000).create();
|
||||
.entrySize(100 * 1000 * 1000)
|
||||
.entries(1000 * 1000)
|
||||
.actualSegments(1)
|
||||
.createPersistedTo(file);
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
char[] chars = new char[i];
|
||||
Arrays.fill(chars, '+');
|
||||
|
||||
@@ -19,9 +19,8 @@
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
|
||||
import net.openhft.chronicle.hash.ChannelProvider;
|
||||
import net.openhft.chronicle.hash.ChannelProviderBuilder;
|
||||
import net.openhft.chronicle.hash.TcpReplicationConfig;
|
||||
import net.openhft.chronicle.hash.replication.ReplicationHub;
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
@@ -48,8 +47,8 @@ public class PostChannelCreationTest {
|
||||
private ChronicleMap<Integer, CharSequence> map1b;
|
||||
private ChronicleMap<Integer, CharSequence> map2b;
|
||||
|
||||
private ChannelProvider channelProviderA;
|
||||
private ChannelProvider channelProviderB;
|
||||
private ReplicationHub hubA;
|
||||
private ReplicationHub hubB;
|
||||
|
||||
public static File getPersistenceFile() {
|
||||
String TMP = System.getProperty("java.io.tmpdir");
|
||||
@@ -64,40 +63,40 @@ public class PostChannelCreationTest {
|
||||
public void setup() throws IOException {
|
||||
|
||||
{
|
||||
final TcpReplicationConfig tcpConfig = TcpReplicationConfig
|
||||
.of(8086, new InetSocketAddress("localhost", 8087))
|
||||
final TcpConfig tcpConfig = TcpConfig
|
||||
.forSendingNode(8086, new InetSocketAddress("localhost", 8087))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
|
||||
channelProviderA = new ChannelProviderBuilder()
|
||||
.replicators((byte) 1, tcpConfig).create();
|
||||
hubA = ReplicationHub.builder().tcpTransportAndNetwork(tcpConfig)
|
||||
.create((byte) 1);
|
||||
|
||||
// this is how you add maps after the custer is created
|
||||
map1a = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(channelProviderA.createChannel((short) 1)).create();
|
||||
.instance().replicatedViaChannel(hubA.createChannel((short) 1)).create();
|
||||
|
||||
map2a = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(channelProviderA.createChannel((short) 2)).create();
|
||||
.instance().replicatedViaChannel(hubA.createChannel((short) 2)).create();
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
final TcpReplicationConfig tcpConfig = TcpReplicationConfig
|
||||
.of(8087, new InetSocketAddress("localhost", 8086))
|
||||
final TcpConfig tcpConfig = TcpConfig
|
||||
.forSendingNode(8087, new InetSocketAddress("localhost", 8086))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
|
||||
channelProviderB = new ChannelProviderBuilder()
|
||||
.replicators((byte) 2, tcpConfig).create();
|
||||
hubB = ReplicationHub.builder().tcpTransportAndNetwork(tcpConfig)
|
||||
.create((byte) 2);
|
||||
|
||||
// this is how you add maps after the custer is created
|
||||
map1b = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(channelProviderB.createChannel((short) 1)).create();
|
||||
.instance().replicatedViaChannel(hubB.createChannel((short) 1)).create();
|
||||
|
||||
map2b = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(channelProviderB.createChannel((short) 2)).create();
|
||||
.instance().replicatedViaChannel(hubB.createChannel((short) 2)).create();
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +105,7 @@ public class PostChannelCreationTest {
|
||||
@After
|
||||
public void tearDown() throws InterruptedException {
|
||||
|
||||
for (final Closeable closeable : new Closeable[]{channelProviderA, channelProviderB}) {
|
||||
for (final Closeable closeable : new Closeable[]{map1a, map1b, map2a, map2b}) {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -73,7 +73,7 @@ public class SerializerTest {
|
||||
ByteBufferBytes in = out.slice();
|
||||
|
||||
ChronicleMapBuilder builder = ChronicleMapBuilder.of(Integer.class, valueClass);
|
||||
builder.preMapConstruction();
|
||||
builder.preMapConstruction(false);
|
||||
|
||||
Serializer v = new Serializer(builder.valueBuilder);
|
||||
|
||||
@@ -96,7 +96,7 @@ public class SerializerTest {
|
||||
ByteBufferBytes in = out.slice();
|
||||
|
||||
ChronicleMapBuilder builder = ChronicleMapBuilder.of(clazz, Integer.class);
|
||||
builder.preMapConstruction();
|
||||
builder.preMapConstruction(false);
|
||||
{
|
||||
Serializer v = new Serializer(builder.keyBuilder);
|
||||
|
||||
|
||||
@@ -19,9 +19,8 @@
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
|
||||
import net.openhft.chronicle.hash.ChannelProvider;
|
||||
import net.openhft.chronicle.hash.ChannelProviderBuilder;
|
||||
import net.openhft.chronicle.hash.TcpReplicationConfig;
|
||||
import net.openhft.chronicle.hash.replication.ReplicationHub;
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
@@ -46,8 +45,8 @@ public class SingleMapChannelTest {
|
||||
|
||||
private ChronicleMap<Integer, CharSequence> map1b;
|
||||
|
||||
private ChannelProvider channelProviderA;
|
||||
private ChannelProvider channelProviderB;
|
||||
private ReplicationHub hubA;
|
||||
private ReplicationHub hubB;
|
||||
|
||||
public static File getPersistenceFile() {
|
||||
String TMP = System.getProperty("java.io.tmpdir");
|
||||
@@ -61,40 +60,41 @@ public class SingleMapChannelTest {
|
||||
public void setup() throws IOException {
|
||||
|
||||
{
|
||||
final TcpReplicationConfig tcpReplicationConfig = TcpReplicationConfig
|
||||
.of(8086, new InetSocketAddress("localhost", 8087))
|
||||
final TcpConfig tcpConfig = TcpConfig
|
||||
.forSendingNode(8086, new InetSocketAddress("localhost", 8087))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
int maxEntrySize = 1024;
|
||||
byte identifier= 1;
|
||||
channelProviderA = new ChannelProviderBuilder()
|
||||
hubA = ReplicationHub.builder()
|
||||
.maxEntrySize(maxEntrySize)
|
||||
.replicators(identifier, tcpReplicationConfig).create();
|
||||
.tcpTransportAndNetwork(tcpConfig)
|
||||
.create(identifier);
|
||||
// this is how you add maps after the custer is created
|
||||
map1a = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(channelProviderA.createChannel((short) 1)).create();
|
||||
.instance().replicatedViaChannel(hubA.createChannel((short) 1)).create();
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
final TcpReplicationConfig tcpReplicationConfig = TcpReplicationConfig
|
||||
.of(8087, new InetSocketAddress("localhost", 8086))
|
||||
final TcpConfig tcpConfig = TcpConfig
|
||||
.forSendingNode(8087, new InetSocketAddress("localhost", 8086))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
|
||||
channelProviderB = new ChannelProviderBuilder()
|
||||
.replicators((byte) 2, tcpReplicationConfig).create();
|
||||
hubB = ReplicationHub.builder().tcpTransportAndNetwork(tcpConfig).create((byte) 2);
|
||||
|
||||
// this is how you add maps after the custer is created
|
||||
map1b = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.channel(channelProviderB.createChannel((short) 1))
|
||||
.entries(1000).create();
|
||||
.entries(1000)
|
||||
.instance().replicatedViaChannel(hubB.createChannel((short) 1))
|
||||
.create();
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws InterruptedException {
|
||||
|
||||
for (final Closeable closeable : new Closeable[]{channelProviderA, channelProviderB}) {
|
||||
for (final Closeable closeable : new Closeable[]{map1a, map1b}) {
|
||||
try {
|
||||
closeable.close();
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.TcpReplicationConfig;
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -29,8 +29,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.openhft.chronicle.hash.StatelessBuilder.remoteAddress;
|
||||
|
||||
|
||||
/**
|
||||
* @author Rob Austin.
|
||||
@@ -41,7 +39,7 @@ public class StatelessClientTest {
|
||||
public static final int SIZE = 100000;
|
||||
|
||||
|
||||
@Test
|
||||
@Test(timeout = 5000)
|
||||
public void testBufferOverFlowPutAllAndEntrySet() throws IOException, InterruptedException {
|
||||
|
||||
final ChronicleMap<Integer, CharSequence> serverMap;
|
||||
@@ -52,13 +50,13 @@ public class StatelessClientTest {
|
||||
{
|
||||
statelessMap = ChronicleMapBuilder.of(Integer
|
||||
.class, CharSequence.class)
|
||||
.stateless(remoteAddress(new InetSocketAddress("localhost", 8086))).create();
|
||||
.statelessClient(new InetSocketAddress("localhost", 8086)).create();
|
||||
}
|
||||
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replicators((byte) 2, TcpReplicationConfig.of(8086)).create();
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086)).create();
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +82,7 @@ public class StatelessClientTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Test(timeout = 5000)
|
||||
public void testBufferOverFlowPutAllAndValues() throws IOException, InterruptedException {
|
||||
|
||||
final ChronicleMap<Integer, CharSequence> serverMap;
|
||||
@@ -95,13 +93,13 @@ public class StatelessClientTest {
|
||||
{
|
||||
statelessMap = ChronicleMapBuilder.of(Integer
|
||||
.class, CharSequence.class)
|
||||
.stateless(remoteAddress(new InetSocketAddress("localhost", 8086))).create();
|
||||
.statelessClient(new InetSocketAddress("localhost", 8086)).create();
|
||||
}
|
||||
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replicators((byte) 2, TcpReplicationConfig.of(8086)).create();
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086)).create();
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +123,7 @@ public class StatelessClientTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Test(timeout = 5000)
|
||||
public void testBufferOverFlowPutAllAndKeySet() throws IOException, InterruptedException {
|
||||
|
||||
final ChronicleMap<Integer, CharSequence> serverMap;
|
||||
@@ -136,13 +134,13 @@ public class StatelessClientTest {
|
||||
{
|
||||
statelessMap = ChronicleMapBuilder.of(Integer
|
||||
.class, CharSequence.class)
|
||||
.stateless(remoteAddress(new InetSocketAddress("localhost", 8086))).create();
|
||||
.statelessClient(new InetSocketAddress("localhost", 8086)).create();
|
||||
}
|
||||
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replicators((byte) 2, TcpReplicationConfig.of(8086)).create();
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086)).create();
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +164,7 @@ public class StatelessClientTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Test(timeout = 5000)
|
||||
public void test() throws IOException, InterruptedException {
|
||||
|
||||
final ChronicleMap<Integer, CharSequence> serverMap;
|
||||
@@ -175,7 +173,7 @@ public class StatelessClientTest {
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replicators((byte) 2, TcpReplicationConfig.of(8086)).create();
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086)).create();
|
||||
|
||||
serverMap.put(10, "EXAMPLE-10");
|
||||
}
|
||||
@@ -185,7 +183,7 @@ public class StatelessClientTest {
|
||||
{
|
||||
statelessMap = ChronicleMapBuilder.of(Integer
|
||||
.class, CharSequence.class)
|
||||
.stateless(remoteAddress(new InetSocketAddress("localhost", 8086))).create();
|
||||
.statelessClient(new InetSocketAddress("localhost", 8086)).create();
|
||||
|
||||
Assert.assertEquals("EXAMPLE-10", statelessMap.get(10));
|
||||
Assert.assertEquals(1, statelessMap.size());
|
||||
@@ -197,7 +195,7 @@ public class StatelessClientTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Test(timeout = 5000)
|
||||
public void testClientCreatedBeforeServer() throws IOException, InterruptedException {
|
||||
|
||||
final ChronicleMap<Integer, CharSequence> serverMap;
|
||||
@@ -208,13 +206,13 @@ public class StatelessClientTest {
|
||||
{
|
||||
statelessMap = ChronicleMapBuilder.of(Integer
|
||||
.class, CharSequence.class)
|
||||
.stateless(remoteAddress(new InetSocketAddress("localhost", 8086))).create();
|
||||
.statelessClient(new InetSocketAddress("localhost", 8086)).create();
|
||||
}
|
||||
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replicators((byte) 2, TcpReplicationConfig.of(8086)).create();
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086)).create();
|
||||
|
||||
serverMap.put(10, "EXAMPLE-10");
|
||||
}
|
||||
@@ -229,7 +227,7 @@ public class StatelessClientTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Test(timeout = 5000)
|
||||
public void testBufferOverFlowPutAll() throws IOException, InterruptedException {
|
||||
|
||||
final ChronicleMap<Integer, CharSequence> serverMap;
|
||||
@@ -240,13 +238,13 @@ public class StatelessClientTest {
|
||||
{
|
||||
statelessMap = ChronicleMapBuilder.of(Integer
|
||||
.class, CharSequence.class)
|
||||
.stateless(remoteAddress(new InetSocketAddress("localhost", 8086))).create();
|
||||
.statelessClient(new InetSocketAddress("localhost", 8086)).create();
|
||||
}
|
||||
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replicators((byte) 2, TcpReplicationConfig.of(8086)).create();
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086)).create();
|
||||
}
|
||||
|
||||
|
||||
@@ -270,7 +268,7 @@ public class StatelessClientTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Test(timeout = 5000)
|
||||
public void testBufferOverFlowPutAllWherePutReturnsNull() throws IOException,
|
||||
InterruptedException {
|
||||
|
||||
@@ -283,13 +281,13 @@ public class StatelessClientTest {
|
||||
statelessMap = ChronicleMapBuilder.of(Integer
|
||||
.class, CharSequence.class)
|
||||
.putReturnsNull(true)
|
||||
.stateless(remoteAddress(new InetSocketAddress("localhost", 8086))).create();
|
||||
.statelessClient(new InetSocketAddress("localhost", 8086)).create();
|
||||
}
|
||||
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replicators((byte) 2, TcpReplicationConfig.of(8086))
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086))
|
||||
.putReturnsNull(true)
|
||||
.create();
|
||||
}
|
||||
@@ -315,7 +313,7 @@ public class StatelessClientTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Test(timeout = 5000)
|
||||
public void testPutWherePutReturnsNull() throws IOException,
|
||||
InterruptedException {
|
||||
|
||||
@@ -329,13 +327,13 @@ public class StatelessClientTest {
|
||||
.class, CharSequence.class)
|
||||
.putReturnsNull(true)
|
||||
.removeReturnsNull(true)
|
||||
.stateless(remoteAddress(new InetSocketAddress("localhost", 8086))).create();
|
||||
.statelessClient(new InetSocketAddress("localhost", 8086)).create();
|
||||
}
|
||||
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replicators((byte) 2, TcpReplicationConfig.of(8086))
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086))
|
||||
.putReturnsNull(true)
|
||||
.removeReturnsNull(true)
|
||||
.create();
|
||||
@@ -355,7 +353,7 @@ public class StatelessClientTest {
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
@Test(timeout = 5000)
|
||||
public void testRemoveWhereRemoveReturnsNull() throws IOException,
|
||||
InterruptedException {
|
||||
|
||||
@@ -369,13 +367,13 @@ public class StatelessClientTest {
|
||||
.class, CharSequence.class)
|
||||
.putReturnsNull(true)
|
||||
.removeReturnsNull(true)
|
||||
.stateless(remoteAddress(new InetSocketAddress("localhost", 8086))).create();
|
||||
.statelessClient(new InetSocketAddress("localhost", 8086)).create();
|
||||
}
|
||||
|
||||
// server
|
||||
{
|
||||
serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replicators((byte) 2, TcpReplicationConfig.of(8086))
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086))
|
||||
.putReturnsNull(true)
|
||||
.removeReturnsNull(true)
|
||||
.create();
|
||||
@@ -397,7 +395,7 @@ public class StatelessClientTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(timeout = 5000)
|
||||
public void testEquals() throws IOException, InterruptedException {
|
||||
|
||||
final ChronicleMap<Integer, CharSequence> serverMap1;
|
||||
@@ -409,18 +407,18 @@ public class StatelessClientTest {
|
||||
{
|
||||
statelessMap1 = ChronicleMapBuilder.of(Integer
|
||||
.class, CharSequence.class)
|
||||
.stateless(remoteAddress(new InetSocketAddress("localhost", 8086))).create();
|
||||
.statelessClient(new InetSocketAddress("localhost", 8086)).create();
|
||||
statelessMap2 = ChronicleMapBuilder.of(Integer
|
||||
.class, CharSequence.class)
|
||||
.stateless(remoteAddress(new InetSocketAddress("localhost", 8077))).create();
|
||||
.statelessClient(new InetSocketAddress("localhost", 8077)).create();
|
||||
}
|
||||
|
||||
// server
|
||||
{
|
||||
serverMap1 = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replicators((byte) 2, TcpReplicationConfig.of(8086)).create();
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8086)).create();
|
||||
serverMap2 = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.replicators((byte) 2, TcpReplicationConfig.of(8077)).create();
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8077)).create();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -53,18 +53,6 @@ public class TCPSocketReplication4WayMapTest {
|
||||
}
|
||||
|
||||
|
||||
|
||||
static ChronicleMap<IntValue, CharSequence> newTcpSocketShmIntValueString(
|
||||
final byte identifier,
|
||||
final int serverPort,
|
||||
final InetSocketAddress... endpoints) throws IOException {
|
||||
return newTcpSocketShmBuilder(IntValue.class, CharSequence.class,
|
||||
identifier, serverPort, endpoints)
|
||||
.entries(20000L)
|
||||
.keyMarshaller(ByteableIntValueMarshaller.INSTANCE).create();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() throws IOException {
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class TCPSocketReplicationBootStrapTests {
|
||||
newTcpSocketShmBuilder(Integer.class, CharSequence.class,
|
||||
(byte) 2, 8076, new InetSocketAddress("localhost", 8079));
|
||||
final ChronicleMap<Integer, CharSequence> map2a =
|
||||
map2aBuilder.file(getPersistenceFile()).create();
|
||||
map2aBuilder.createPersistedTo(getPersistenceFile());
|
||||
map2a.put(10, "EXAMPLE-10"); // this will be the last time that map1 go an update from map2
|
||||
|
||||
long lastModificationTime;
|
||||
@@ -69,16 +69,14 @@ public class TCPSocketReplicationBootStrapTests {
|
||||
// restart map 2 but don't doConnect it to map one
|
||||
final ChronicleMap<Integer, CharSequence> map2b =
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.file(map2File)
|
||||
.create();
|
||||
.createPersistedTo(map2File);
|
||||
// add data into it
|
||||
map2b.put(11, "ADDED WHEN DISCONNECTED TO MAP1");
|
||||
map2b.close();
|
||||
}
|
||||
|
||||
// now restart map2a and doConnect it to map1, map1 should bootstrap the missing entry
|
||||
map2aBuilder.file(map2File);
|
||||
map2 = map2aBuilder.create();
|
||||
map2 = map2aBuilder.createPersistedTo(map2File);
|
||||
|
||||
// add data into it
|
||||
waitTillEqual(5000);
|
||||
@@ -96,7 +94,7 @@ public class TCPSocketReplicationBootStrapTests {
|
||||
|
||||
final ReplicatedChronicleMap<Integer, ?, ?, CharSequence, ?, ?> map2a =
|
||||
(ReplicatedChronicleMap<Integer, ?, ?, CharSequence, ?, ?>)
|
||||
map2aBuilder.file(getPersistenceFile()).create();
|
||||
map2aBuilder.createPersistedTo(getPersistenceFile());
|
||||
|
||||
map2a.put(10, "EXAMPLE-10"); // this will be the last time that map1 go an update from map2
|
||||
|
||||
@@ -113,18 +111,16 @@ public class TCPSocketReplicationBootStrapTests {
|
||||
|
||||
{
|
||||
// restart map 2 but don't doConnect it to map one
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class).file(map2File);
|
||||
final ChronicleMap<Integer, CharSequence> map2b =
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class).file(map2File).
|
||||
create();
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.createPersistedTo(map2File);
|
||||
// add data into it
|
||||
map2b.put(11, "ADDED WHEN DISCONNECTED TO MAP1");
|
||||
map2b.close();
|
||||
}
|
||||
|
||||
// now restart map2a and doConnect it to map1, map1 should bootstrap the missing entry
|
||||
map2aBuilder.file(map2File);
|
||||
map2 = map2aBuilder.create();
|
||||
map2 = map2aBuilder.createPersistedTo(map2File);
|
||||
|
||||
// add data into it
|
||||
waitTillEqual(20000);
|
||||
|
||||
@@ -34,7 +34,6 @@ import java.util.Random;
|
||||
|
||||
import static net.openhft.chronicle.map.Builder.getPersistenceFile;
|
||||
import static net.openhft.chronicle.map.Builder.newTcpSocketShmBuilder;
|
||||
import static net.openhft.chronicle.map.TCPSocketReplication4WayMapTest.newTcpSocketShmIntValueString;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -57,9 +56,14 @@ public class TCPSocketReplicationIntValueTest {
|
||||
((Byteable) value).bytes(new ByteBufferBytes(ByteBuffer.allocateDirect(4)), 0);
|
||||
map1Builder = newTcpSocketShmBuilder(IntValue.class, CharSequence.class,
|
||||
(byte) 1, 8076, new InetSocketAddress("localhost", 8077));
|
||||
map1Builder.keyMarshaller(ByteableIntValueMarshaller.INSTANCE).file(getPersistenceFile());
|
||||
map1 = map1Builder.keyMarshaller(ByteableIntValueMarshaller.INSTANCE).create();
|
||||
map2 = newTcpSocketShmIntValueString((byte) 2, 8077);
|
||||
map1Builder.keyMarshaller(ByteableIntValueMarshaller.INSTANCE);
|
||||
map1 = map1Builder.keyMarshaller(ByteableIntValueMarshaller.INSTANCE)
|
||||
.createPersistedTo(getPersistenceFile());
|
||||
map2 = newTcpSocketShmBuilder(IntValue.class, CharSequence.class,
|
||||
(byte) 2, 8077)
|
||||
.entries(20000L)
|
||||
.keyMarshaller(ByteableIntValueMarshaller.INSTANCE)
|
||||
.create();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -50,8 +50,7 @@ public class TCPSocketReplicationTest {
|
||||
ChronicleMapBuilder<Integer, CharSequence> map1Builder =
|
||||
newTcpSocketShmBuilder(Integer.class, CharSequence.class,
|
||||
(byte) 1, 8076, new InetSocketAddress("localhost", 8077));
|
||||
map1Builder.file(getPersistenceFile());
|
||||
map1 = map1Builder.create();
|
||||
map1 = map1Builder.createPersistedTo(getPersistenceFile());
|
||||
map2 = newTcpSocketShmIntString((byte) 2, 8077);
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -18,7 +18,7 @@
|
||||
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.TcpReplicationConfig;
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -26,6 +26,7 @@ import org.junit.Test;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -47,11 +48,11 @@ public class TCPSocketReplicationTest3wayPutReturnsNull {
|
||||
final byte identifier,
|
||||
final int serverPort,
|
||||
final InetSocketAddress... endpoints) throws IOException {
|
||||
TcpReplicationConfig tcpConfig = TcpReplicationConfig.of(serverPort, endpoints);
|
||||
TcpConfig tcpConfig = TcpConfig.unknownTopology(serverPort, Arrays.asList(endpoints));
|
||||
|
||||
return (T) ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.putReturnsNull(true)
|
||||
.replicators(identifier, tcpConfig).create();
|
||||
.replication(identifier, tcpConfig).create();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -79,9 +79,8 @@ public class TCPSocketReplicationTestPostConnection {
|
||||
ChronicleMapBuilder<Integer, CharSequence> map2aBuilder =
|
||||
newTcpSocketShmBuilder(Integer.class, CharSequence.class,
|
||||
(byte) 2, 8077, new InetSocketAddress("localhost", 8076));
|
||||
map2aBuilder.file(Builder.getPersistenceFile());
|
||||
final ChronicleMap<Integer, CharSequence> map2a =
|
||||
map2aBuilder.create();
|
||||
map2aBuilder.createPersistedTo(Builder.getPersistenceFile());
|
||||
map1 = TCPSocketReplication4WayMapTest.newTcpSocketShmIntString((byte) 1, 8076);
|
||||
|
||||
Thread.sleep(1);
|
||||
@@ -94,8 +93,7 @@ public class TCPSocketReplicationTestPostConnection {
|
||||
map1.put(6, "EXAMPLE-1");
|
||||
|
||||
// recreate map2 with new unique file
|
||||
map2aBuilder.file(Builder.getPersistenceFile());
|
||||
map2 = map2aBuilder.create();
|
||||
map2 = map2aBuilder.createPersistedTo(Builder.getPersistenceFile());
|
||||
|
||||
|
||||
// allow time for the recompilation to resolve
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.TimeProvider;
|
||||
import net.openhft.chronicle.hash.replication.TimeProvider;
|
||||
import net.openhft.chronicle.map.jrs166.JSR166TestCase;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
@@ -49,12 +49,10 @@ public class TimeBasedReplicationTests extends JSR166TestCase {
|
||||
public void testIgnoreALatePut() throws IOException {
|
||||
|
||||
final TimeProvider timeProvider = Mockito.mock(TimeProvider.class);
|
||||
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.entries(10).replicators((byte) 1);
|
||||
ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.replicators((byte) 1)
|
||||
.timeProvider(timeProvider).create();
|
||||
.entries(10)
|
||||
.timeProvider(timeProvider)
|
||||
.createReplicated((byte) 1);
|
||||
|
||||
current(timeProvider);
|
||||
|
||||
@@ -80,11 +78,10 @@ public class TimeBasedReplicationTests extends JSR166TestCase {
|
||||
public void testIgnoreALatePutIfAbsent() throws IOException {
|
||||
|
||||
final TimeProvider timeProvider = Mockito.mock(TimeProvider.class);
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.entries(10).replicators((byte) 1);
|
||||
ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.replicators((byte) 1)
|
||||
.timeProvider(timeProvider).create();
|
||||
.entries(10)
|
||||
.timeProvider(timeProvider)
|
||||
.createReplicated((byte) 1);
|
||||
|
||||
current(timeProvider);
|
||||
|
||||
@@ -111,11 +108,10 @@ public class TimeBasedReplicationTests extends JSR166TestCase {
|
||||
public void testIgnoreALateReplace() throws IOException {
|
||||
|
||||
final TimeProvider timeProvider = Mockito.mock(TimeProvider.class);
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.entries(10).replicators((byte) 1);
|
||||
ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.replicators((byte) 1)
|
||||
.timeProvider(timeProvider).create();
|
||||
.entries(10)
|
||||
.timeProvider(timeProvider)
|
||||
.createReplicated((byte) 1);
|
||||
|
||||
current(timeProvider);
|
||||
|
||||
@@ -145,14 +141,10 @@ public class TimeBasedReplicationTests extends JSR166TestCase {
|
||||
public void testIgnoreALateReplaceWithValue() throws IOException {
|
||||
|
||||
final TimeProvider timeProvider = Mockito.mock(TimeProvider.class);
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.entries(10).replicators((byte) 1);
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.replicators((byte) 1)
|
||||
.timeProvider(timeProvider).file(getPersistenceFile());
|
||||
ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.replicators((byte) 1)
|
||||
.timeProvider(timeProvider).create();
|
||||
.entries(10)
|
||||
.timeProvider(timeProvider)
|
||||
.createReplicated((byte) 1);
|
||||
|
||||
current(timeProvider);
|
||||
|
||||
@@ -179,13 +171,10 @@ public class TimeBasedReplicationTests extends JSR166TestCase {
|
||||
public void testIgnoreALateRemoveWithValue() throws IOException {
|
||||
|
||||
final TimeProvider timeProvider = Mockito.mock(TimeProvider.class);
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class).replicators((byte) 1);
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.replicators((byte) 1)
|
||||
.timeProvider(timeProvider).file(getPersistenceFile());
|
||||
ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.replicators((byte) 1)
|
||||
.timeProvider(timeProvider).create();
|
||||
.entries(10)
|
||||
.timeProvider(timeProvider)
|
||||
.createReplicated((byte) 1);
|
||||
|
||||
current(timeProvider);
|
||||
|
||||
@@ -211,13 +200,10 @@ public class TimeBasedReplicationTests extends JSR166TestCase {
|
||||
public void testIgnoreALateRemove() throws IOException {
|
||||
|
||||
final TimeProvider timeProvider = Mockito.mock(TimeProvider.class);
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class).replicators((byte) 1);
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.replicators((byte) 1)
|
||||
.timeProvider(timeProvider).file(getPersistenceFile());
|
||||
ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.replicators((byte) 1)
|
||||
.timeProvider(timeProvider).create();
|
||||
.entries(10)
|
||||
.timeProvider(timeProvider)
|
||||
.createReplicated((byte) 1);
|
||||
|
||||
current(timeProvider);
|
||||
|
||||
@@ -243,13 +229,10 @@ public class TimeBasedReplicationTests extends JSR166TestCase {
|
||||
public void testIgnoreWithRemoteRemove() throws IOException {
|
||||
|
||||
final TimeProvider timeProvider = Mockito.mock(TimeProvider.class);
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class).replicators((byte) 1);
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.replicators((byte) 1)
|
||||
.timeProvider(timeProvider).file(getPersistenceFile());
|
||||
ReplicatedChronicleMap map = (ReplicatedChronicleMap) ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.replicators((byte) 1)
|
||||
.timeProvider(timeProvider).create();
|
||||
.entries(10)
|
||||
.timeProvider(timeProvider)
|
||||
.createReplicated((byte) 1);
|
||||
|
||||
current(timeProvider);
|
||||
|
||||
@@ -276,13 +259,10 @@ public class TimeBasedReplicationTests extends JSR166TestCase {
|
||||
|
||||
|
||||
final TimeProvider timeProvider = Mockito.mock(TimeProvider.class);
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class).replicators((byte) 1);
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.replicators((byte) 1)
|
||||
.timeProvider(timeProvider).file(getPersistenceFile());
|
||||
ReplicatedChronicleMap map = (ReplicatedChronicleMap) ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.replicators((byte) 1)
|
||||
.timeProvider(timeProvider).create();
|
||||
.entries(10)
|
||||
.timeProvider(timeProvider)
|
||||
.createReplicated((byte) 1);
|
||||
|
||||
current(timeProvider);
|
||||
|
||||
@@ -309,16 +289,10 @@ public class TimeBasedReplicationTests extends JSR166TestCase {
|
||||
public void testRemoveFollowedByLatePut() throws IOException {
|
||||
|
||||
final TimeProvider timeProvider = Mockito.mock(TimeProvider.class);
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.entries(10)
|
||||
.replicators((byte) 1)
|
||||
.entries(10)
|
||||
.timeProvider(timeProvider).file(getPersistenceFile());
|
||||
ReplicatedChronicleMap map = (ReplicatedChronicleMap) ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.entries(10)
|
||||
.replicators((byte) 1)
|
||||
.entries(10)
|
||||
.timeProvider(timeProvider).create();
|
||||
.timeProvider(timeProvider)
|
||||
.createReplicated((byte) 1);
|
||||
|
||||
current(timeProvider);
|
||||
|
||||
@@ -343,16 +317,10 @@ public class TimeBasedReplicationTests extends JSR166TestCase {
|
||||
public void testPutRemovePut() throws IOException {
|
||||
|
||||
final TimeProvider timeProvider = Mockito.mock(TimeProvider.class);
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.entries(10).replicators((byte) 1);
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.entries(10)
|
||||
.entries(10)
|
||||
.timeProvider(timeProvider).file(getPersistenceFile());
|
||||
ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.entries(10)
|
||||
.entries(10)
|
||||
.timeProvider(timeProvider).create();
|
||||
.timeProvider(timeProvider)
|
||||
.createReplicated((byte) 1);
|
||||
|
||||
current(timeProvider);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.TcpReplicationConfig;
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -30,7 +30,6 @@ import java.net.InetSocketAddress;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static net.openhft.chronicle.map.Builder.getPersistenceFile;
|
||||
import static net.openhft.chronicle.hash.TcpReplicationConfig.of;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -46,19 +45,20 @@ public class TwoMapOnDifferentServers {
|
||||
@Before
|
||||
public void setup() throws IOException {
|
||||
|
||||
final TcpReplicationConfig tcpConfig =
|
||||
of(8076, new InetSocketAddress("localhost", 8077))
|
||||
final TcpConfig tcpConfig =
|
||||
TcpConfig.forSendingNode(8076, new InetSocketAddress("localhost", 8077))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
|
||||
|
||||
File persistenceFile = getPersistenceFile();
|
||||
map1 = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(20000)
|
||||
.replicators((byte) 1, tcpConfig).create();
|
||||
.replication((byte) 1, tcpConfig).create();
|
||||
|
||||
map2 = ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(20000)
|
||||
.replicators((byte) 2, of(8077).heartBeatInterval(1, SECONDS)).create();
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(8077)
|
||||
.heartBeatInterval(1, SECONDS)).create();
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.UdpReplicationConfig;
|
||||
import net.openhft.chronicle.hash.replication.SimpleReplication;
|
||||
import net.openhft.chronicle.hash.replication.UdpConfig;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
@@ -40,12 +41,13 @@ public class UDPSocketReplicationTest {
|
||||
final int identifier,
|
||||
final int udpPort) throws IOException {
|
||||
|
||||
UdpReplicationConfig udpConfig = UdpReplicationConfig
|
||||
UdpConfig udpConfig = UdpConfig
|
||||
.simple(Inet4Address.getByName("255.255.255.255"), udpPort);
|
||||
|
||||
return ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.replicators((byte) identifier, udpConfig).create();
|
||||
.replication(SimpleReplication.builder().udpTransport(udpConfig)
|
||||
.create((byte) identifier)).create();
|
||||
}
|
||||
|
||||
@Before
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package net.openhft.chronicle.map.example;
|
||||
|
||||
import net.openhft.chronicle.hash.ChannelProvider;
|
||||
import net.openhft.chronicle.hash.ChannelProviderBuilder;
|
||||
import net.openhft.chronicle.hash.TcpReplicationConfig;
|
||||
import net.openhft.chronicle.hash.replication.ReplicationHub;
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import net.openhft.chronicle.map.ChronicleMap;
|
||||
import net.openhft.chronicle.map.ChronicleMapBuilder;
|
||||
import org.junit.Assert;
|
||||
@@ -11,6 +10,7 @@ import org.junit.Test;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
@@ -54,8 +54,8 @@ public class ChannelExample {
|
||||
private ChronicleMap<CharSequence, CharSequence> favoriteColourServer1;
|
||||
|
||||
|
||||
private ChannelProvider channelProviderServer1;
|
||||
private ChannelProvider channelProviderServer2;
|
||||
private ReplicationHub hubOnServer1;
|
||||
private ReplicationHub hubOnServer2;
|
||||
|
||||
|
||||
@Test
|
||||
@@ -63,32 +63,34 @@ public class ChannelExample {
|
||||
|
||||
// server 1 with identifier = 1
|
||||
{
|
||||
ChronicleMapBuilder<CharSequence, CharSequence> smallStringToStringMapBuilder =
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.entries(1000);
|
||||
|
||||
byte identifier = (byte) 1;
|
||||
|
||||
TcpReplicationConfig tcpConfig = TcpReplicationConfig
|
||||
.of(8086, new InetSocketAddress("localhost", 8087))
|
||||
.heartBeatInterval(1, java.util.concurrent.TimeUnit.SECONDS);
|
||||
TcpConfig tcpConfig = TcpConfig
|
||||
.forSendingNode(8086, new InetSocketAddress("localhost", 8087))
|
||||
.heartBeatInterval(1, SECONDS);
|
||||
|
||||
|
||||
channelProviderServer1 = new ChannelProviderBuilder()
|
||||
.replicators(identifier, tcpConfig)
|
||||
.create();
|
||||
hubOnServer1 = ReplicationHub.builder()
|
||||
.tcpTransportAndNetwork(tcpConfig)
|
||||
.create(identifier);
|
||||
|
||||
// this demotes favoriteColour
|
||||
short channel1 = (short) 1;
|
||||
|
||||
favoriteColourServer1 = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(channelProviderServer1.createChannel(channel1)).create();
|
||||
favoriteColourServer1 = smallStringToStringMapBuilder.instance()
|
||||
.replicatedViaChannel(hubOnServer1.createChannel(channel1)).create();
|
||||
|
||||
favoriteColourServer1.put("peter", "green");
|
||||
|
||||
// this demotes favoriteComputer
|
||||
short channel2 = (short) 2;
|
||||
|
||||
favoriteComputerServer1 = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(channelProviderServer1.createChannel(channel2)).create();
|
||||
favoriteComputerServer1 = smallStringToStringMapBuilder.instance()
|
||||
.replicatedViaChannel(hubOnServer1.createChannel(channel2)).create();
|
||||
|
||||
favoriteComputerServer1.put("peter", "dell");
|
||||
|
||||
@@ -96,23 +98,25 @@ public class ChannelExample {
|
||||
|
||||
// server 2 with identifier = 2
|
||||
{
|
||||
ChronicleMapBuilder<CharSequence, CharSequence> smallStringToStringMapBuilder =
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.entries(1000);
|
||||
|
||||
byte identifier = (byte) 2;
|
||||
|
||||
TcpReplicationConfig tcpConfig =
|
||||
TcpReplicationConfig.of(8087).heartBeatInterval(1, java.util.concurrent.TimeUnit.SECONDS);
|
||||
TcpConfig tcpConfig =
|
||||
TcpConfig.forReceivingOnlyNode(8087).heartBeatInterval(1, SECONDS);
|
||||
|
||||
channelProviderServer2 = new ChannelProviderBuilder()
|
||||
.replicators(identifier, tcpConfig)
|
||||
.create();
|
||||
hubOnServer2 = ReplicationHub.builder()
|
||||
.tcpTransportAndNetwork(tcpConfig)
|
||||
.create(identifier);
|
||||
|
||||
|
||||
// this demotes favoriteColour
|
||||
short channel1 = (short) 1;
|
||||
|
||||
favoriteColourServer2 = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(channelProviderServer2.createChannel(channel1)).create();
|
||||
favoriteColourServer2 = smallStringToStringMapBuilder.instance()
|
||||
.replicatedViaChannel(hubOnServer2.createChannel(channel1)).create();
|
||||
|
||||
|
||||
favoriteColourServer2.put("rob", "blue");
|
||||
@@ -120,9 +124,8 @@ public class ChannelExample {
|
||||
// this demotes favoriteComputer
|
||||
short channel2 = (short) 2;
|
||||
|
||||
favoriteComputerServer2 = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.entries(1000)
|
||||
.channel(channelProviderServer2.createChannel(channel2)).create();
|
||||
favoriteComputerServer2 = smallStringToStringMapBuilder.instance()
|
||||
.replicatedViaChannel(hubOnServer2.createChannel(channel2)).create();
|
||||
|
||||
favoriteComputerServer2.put("rob", "mac");
|
||||
favoriteComputerServer2.put("daniel", "mac");
|
||||
|
||||
@@ -30,9 +30,6 @@ public class DistributedSequenceMain {
|
||||
|
||||
public static void main(String... ignored) throws IOException {
|
||||
Class<LongValue> longValueClass = DataValueClasses.directClassFor(LongValue.class);
|
||||
ChronicleMapBuilder.of(String.class, longValueClass)
|
||||
.entries(128)
|
||||
.actualSegments(1).file(new File("/tmp/counters"));
|
||||
ChronicleMap<String, LongValue> map =
|
||||
ChronicleMapBuilder.of(String.class, longValueClass)
|
||||
.entries(128)
|
||||
|
||||
@@ -59,8 +59,7 @@ public class OpenJDKAndHashMapExamplesTest {
|
||||
ChronicleMap<String, BondVOInterface> chm = OffHeapUpdatableChronicleMapBuilder
|
||||
.of(String.class, BondVOInterface.class)
|
||||
.keySize(10)
|
||||
.file(file)
|
||||
.create();
|
||||
.createPersistedTo(file);
|
||||
|
||||
|
||||
BondVOInterface bondVO = DataValueClasses.newDirectReference(BondVOInterface.class);
|
||||
@@ -80,8 +79,7 @@ public class OpenJDKAndHashMapExamplesTest {
|
||||
ChronicleMap<String, BondVOInterface> chmB = OffHeapUpdatableChronicleMapBuilder
|
||||
.of(String.class, BondVOInterface.class)
|
||||
.keySize(10)
|
||||
.file(file)
|
||||
.create();
|
||||
.createPersistedTo(file);
|
||||
|
||||
// ZERO Copy but creates a new off heap reference each time
|
||||
|
||||
|
||||
@@ -90,14 +90,7 @@ public class PingPongCASLeft {
|
||||
static ChronicleMap<String, BondVOInterface> acquireCHM() throws IOException {
|
||||
// ensure thread ids are globally unique.
|
||||
AffinitySupport.setThreadId();
|
||||
|
||||
String TMP = System.getProperty("java.io.tmpdir");
|
||||
ChronicleMapBuilder.of(String.class, BondVOInterface.class)
|
||||
|
||||
.entries(16)
|
||||
.entrySize(64).file(new File(TMP + "/BondPortfolioCHM"));
|
||||
return ChronicleMapBuilder.of(String.class, BondVOInterface.class)
|
||||
|
||||
.entries(16)
|
||||
.entrySize(64).create();
|
||||
}
|
||||
|
||||
@@ -40,12 +40,7 @@ public class StateMachineTutorial {
|
||||
|
||||
try {
|
||||
File dataFile = new File(System.getProperty("java.io.tmpdir"), "hft-state-machine");
|
||||
|
||||
ChronicleMapBuilder.of(Integer.class, StateMachineData.class)
|
||||
|
||||
.entries(8).file(dataFile);
|
||||
map = ChronicleMapBuilder.of(Integer.class, StateMachineData.class)
|
||||
|
||||
.entries(8).create();
|
||||
|
||||
if (args.length > 0) {
|
||||
|
||||
@@ -49,57 +49,33 @@ public class ChronicleMapTest extends JSR166TestCase {
|
||||
}
|
||||
|
||||
static ChronicleMap<Integer, CharSequence> newShmIntString(int size) throws IOException {
|
||||
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(size).file(getPersistenceFile());
|
||||
return ChronicleMapBuilder.of(Integer.class, CharSequence.class)
|
||||
.entries(size).create();
|
||||
|
||||
}
|
||||
|
||||
static ChronicleMap<ArrayList, CharSequence> newShmListBoolean(int size) throws IOException {
|
||||
|
||||
ChronicleMapBuilder.of(ArrayList.class, CharSequence.class)
|
||||
|
||||
.entries(size).file(getPersistenceFile());
|
||||
return ChronicleMapBuilder.of(ArrayList.class, CharSequence.class)
|
||||
|
||||
.entries(size).create();
|
||||
|
||||
}
|
||||
|
||||
|
||||
static ChronicleMap<ArrayList, CharSequence> newShmListBoolean() throws IOException {
|
||||
|
||||
ChronicleMapBuilder.of(ArrayList.class, CharSequence.class).file(getPersistenceFile());
|
||||
return ChronicleMapBuilder.of(ArrayList.class, CharSequence.class).create();
|
||||
|
||||
}
|
||||
|
||||
static ChronicleMap<CharSequence, CharSequence> newShmStringString(int size) throws IOException {
|
||||
|
||||
ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
|
||||
.entries(size).file(getPersistenceFile());
|
||||
return ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
|
||||
.entries(size).create();
|
||||
|
||||
}
|
||||
|
||||
|
||||
static ChronicleMap<Integer, CharSequence> newShmIntString() throws IOException {
|
||||
|
||||
ChronicleMapBuilder.of(Integer.class, CharSequence.class).file(getPersistenceFile());
|
||||
return ChronicleMapBuilder.of(Integer.class, CharSequence.class).create();
|
||||
|
||||
}
|
||||
|
||||
static ChronicleMap<BI, Boolean> newShmBiBoolean() throws IOException {
|
||||
|
||||
ChronicleMapBuilder.of(BI.class, Boolean.class).file(getPersistenceFile());
|
||||
return ChronicleMapBuilder.of(BI.class, Boolean.class).create();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -123,9 +123,6 @@ public class MapCheck {
|
||||
|
||||
static Map newMap() {
|
||||
try {
|
||||
|
||||
// return new ConcurrentHashMap();
|
||||
ChronicleMapBuilder.of(Object.class, Object.class).file(getPersistenceFile());
|
||||
return ChronicleMapBuilder.of(Object.class, Object.class).create();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package net.openhft.chronicle.map.jrs166.map;
|
||||
|
||||
import net.openhft.chronicle.hash.TcpReplicationConfig;
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import net.openhft.chronicle.map.ChronicleMap;
|
||||
import net.openhft.chronicle.map.ChronicleMapBuilder;
|
||||
import net.openhft.chronicle.map.ReadContext;
|
||||
@@ -33,7 +33,6 @@ import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.*;
|
||||
|
||||
import static net.openhft.chronicle.hash.StatelessBuilder.remoteAddress;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/*
|
||||
@@ -184,12 +183,13 @@ public class StatelessChronicleMapTest extends JSR166TestCase {
|
||||
|
||||
static ChronicleMap<Integer, String> newShmIntString(int port) throws IOException {
|
||||
|
||||
final ChronicleMap<Integer, String> serverMap = ChronicleMapBuilder.of(Integer.class, String.class)
|
||||
.replicators((byte) 1, TcpReplicationConfig.of(port)).create();
|
||||
final ChronicleMap<Integer, String> serverMap =
|
||||
ChronicleMapBuilder.of(Integer.class, String.class)
|
||||
.replication((byte) 1, TcpConfig.forReceivingOnlyNode(port)).create();
|
||||
|
||||
final ChronicleMap<Integer, String> statelessMap = ChronicleMapBuilder.of(Integer
|
||||
.class, String.class)
|
||||
.stateless(remoteAddress(new InetSocketAddress("localhost", port))).create();
|
||||
.statelessClient(new InetSocketAddress("localhost", port)).create();
|
||||
|
||||
return new SingleCloseMap(statelessMap, statelessMap, serverMap);
|
||||
|
||||
@@ -199,12 +199,12 @@ public class StatelessChronicleMapTest extends JSR166TestCase {
|
||||
IOException {
|
||||
|
||||
final ChronicleMap<CharSequence, CharSequence> serverMap = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class)
|
||||
.replicators((byte) 2, TcpReplicationConfig.of(port)).create();
|
||||
.replication((byte) 2, TcpConfig.forReceivingOnlyNode(port)).create();
|
||||
|
||||
|
||||
final ChronicleMap<CharSequence, CharSequence> statelessMap = ChronicleMapBuilder.of(CharSequence
|
||||
.class, CharSequence.class)
|
||||
.stateless(remoteAddress(new InetSocketAddress("localhost", port))).create();
|
||||
.statelessClient(new InetSocketAddress("localhost", port)).create();
|
||||
|
||||
return new SingleCloseMap(statelessMap, statelessMap, serverMap);
|
||||
}
|
||||
|
||||
@@ -138,8 +138,7 @@ public class ProcessInstanceLimiter implements Runnable {
|
||||
ChronicleMapBuilder.of(String.class, Data.class);
|
||||
builder.entries(1000);
|
||||
builder.entrySize(1024);
|
||||
builder.file(new File(sharedMapPath));
|
||||
this.theSharedMap = builder.create();
|
||||
this.theSharedMap = builder.createPersistedTo(new File(sharedMapPath));
|
||||
Thread t = new Thread(this, "ProcessInstanceLimiter updater");
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package net.openhft.chronicle.set;
|
||||
|
||||
import net.openhft.chronicle.hash.replication.TcpConfig;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -25,10 +26,11 @@ import org.junit.Test;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static net.openhft.chronicle.map.Builder.getPersistenceFile;
|
||||
import static net.openhft.chronicle.hash.TcpReplicationConfig.of;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -51,10 +53,9 @@ public class SetForTCPSocketReplicationTest3way {
|
||||
final int serverPort,
|
||||
final InetSocketAddress... endpoints) throws IOException {
|
||||
return (T) ChronicleSetBuilder.of(Integer.class)
|
||||
.file(getPersistenceFile())
|
||||
.replicators(identifier, of(serverPort, endpoints)
|
||||
.replication(identifier, TcpConfig.unknownTopology(serverPort, asList(endpoints))
|
||||
.heartBeatInterval(1L, SECONDS))
|
||||
.create();
|
||||
.createPersistedTo(getPersistenceFile());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user