diff --git a/src/main/java/net/openhft/chronicle/hash/FindByName.java b/src/main/java/net/openhft/chronicle/hash/FindByName.java new file mode 100644 index 000000000..e8f31fa2e --- /dev/null +++ b/src/main/java/net/openhft/chronicle/hash/FindByName.java @@ -0,0 +1,19 @@ +package net.openhft.chronicle.hash; + +import java.io.IOException; + +/** + * @author Rob Austin. + */ +public interface FindByName { + + /** + * @param name the name of the map or set + * @param + * @return a chronicle map or set + * @throws IllegalArgumentException if a map with this name can not be found + * @throws IOException if it not possible to create the map or set + */ + T create(String name) throws IllegalArgumentException, + IOException; +} diff --git a/src/main/java/net/openhft/chronicle/hash/replication/AbstractReplication.java b/src/main/java/net/openhft/chronicle/hash/replication/AbstractReplication.java index 4bf537ded..7a1e590f9 100644 --- a/src/main/java/net/openhft/chronicle/hash/replication/AbstractReplication.java +++ b/src/main/java/net/openhft/chronicle/hash/replication/AbstractReplication.java @@ -19,10 +19,12 @@ package net.openhft.chronicle.hash.replication; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.io.Serializable; + /** * Common configurations of {@link SingleChronicleHashReplication} and {@link ReplicationHub}. */ -public abstract class AbstractReplication { +public abstract class AbstractReplication implements Serializable{ private final byte localIdentifier; private final @Nullable TcpTransportAndNetworkConfig tcpConfig; private final @Nullable UdpTransportConfig udpConfig; diff --git a/src/main/java/net/openhft/chronicle/hash/replication/TcpTransportAndNetworkConfig.java b/src/main/java/net/openhft/chronicle/hash/replication/TcpTransportAndNetworkConfig.java index 89c04a680..1fd6de86b 100644 --- a/src/main/java/net/openhft/chronicle/hash/replication/TcpTransportAndNetworkConfig.java +++ b/src/main/java/net/openhft/chronicle/hash/replication/TcpTransportAndNetworkConfig.java @@ -18,6 +18,7 @@ package net.openhft.chronicle.hash.replication; +import java.io.Serializable; import java.net.InetSocketAddress; import java.util.*; import java.util.concurrent.TimeUnit; @@ -26,7 +27,7 @@ import static java.util.Collections.unmodifiableSet; import static java.util.concurrent.TimeUnit.SECONDS; -public final class TcpTransportAndNetworkConfig { +public final class TcpTransportAndNetworkConfig implements Serializable { private static final int DEFAULT_PACKET_SIZE = 1024 * 8; private static final long DEFAULT_HEART_BEAT_INTERVAL = 20; diff --git a/src/main/java/net/openhft/chronicle/hash/replication/ThrottlingConfig.java b/src/main/java/net/openhft/chronicle/hash/replication/ThrottlingConfig.java index 953727262..17543489c 100644 --- a/src/main/java/net/openhft/chronicle/hash/replication/ThrottlingConfig.java +++ b/src/main/java/net/openhft/chronicle/hash/replication/ThrottlingConfig.java @@ -19,11 +19,12 @@ package net.openhft.chronicle.hash.replication; +import java.io.Serializable; import java.util.concurrent.TimeUnit; import static java.util.concurrent.TimeUnit.MILLISECONDS; -public final class ThrottlingConfig { +public final class ThrottlingConfig implements Serializable { private static final long DEFAULT_BUCKET_INTERVAL = 100L; private static final TimeUnit DEFAULT_BUCKET_INTERVAL_UNIT = MILLISECONDS; diff --git a/src/main/java/net/openhft/chronicle/hash/replication/UdpTransportConfig.java b/src/main/java/net/openhft/chronicle/hash/replication/UdpTransportConfig.java index b86d564d5..9a0a74a39 100644 --- a/src/main/java/net/openhft/chronicle/hash/replication/UdpTransportConfig.java +++ b/src/main/java/net/openhft/chronicle/hash/replication/UdpTransportConfig.java @@ -49,6 +49,14 @@ public final class UdpTransportConfig { this.throttlingConfig = throttlingConfig; } + + public static UdpTransportConfig multiCast(@NotNull InetAddress address, int port, + @NotNull NetworkInterface networkInterface) { + if (!address.isMulticastAddress() || networkInterface == null) + throw new IllegalArgumentException(); + return create(address, port, networkInterface, ThrottlingConfig.noThrottling()); + } + public static UdpTransportConfig of(@NotNull InetAddress address, int port) { if (address.isMulticastAddress()) throw new IllegalArgumentException(); diff --git a/src/main/java/net/openhft/chronicle/map/AbstractChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/AbstractChronicleMapBuilder.java index f86fab3dc..1eec457db 100644 --- a/src/main/java/net/openhft/chronicle/map/AbstractChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/AbstractChronicleMapBuilder.java @@ -534,8 +534,9 @@ abstract class AbstractChronicleMapBuilder implements ChronicleMapBuilderI createReplicated(byte b) throws IOException { - return delegate.createReplicated(b); - } - @Override public ChronicleMap createPersistedTo(File file) throws IOException { - return delegate.createPersistedTo(file); + return delegate.createPersistedTo(file); } } diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilderI.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilderI.java index 9e89e8b89..dffbcec6c 100644 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilderI.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilderI.java @@ -200,7 +200,7 @@ interface ChronicleMapBuilderI extends Serializable { * @see ChronicleMapBuilder * @see #objectSerializer(ObjectSerializer) */ - ChronicleMapBuilderI valueMarshaller( + ChronicleMapBuilderI valueMarshaller( @NotNull BytesMarshaller valueMarshaller); @@ -292,12 +292,12 @@ interface ChronicleMapBuilderI extends Serializable { ChronicleMapBuilderI putReturnsNull(boolean b); - ChronicleMap createReplicated(byte b) throws IOException; - ChronicleMapBuilderI removeReturnsNull(boolean b); + ChronicleMapBuilderI name(String name); + + - ChronicleMapBuilderI name(String name); String name(); diff --git a/src/main/java/net/openhft/chronicle/map/FindMapByName.java b/src/main/java/net/openhft/chronicle/map/FindFindByName.java similarity index 93% rename from src/main/java/net/openhft/chronicle/map/FindMapByName.java rename to src/main/java/net/openhft/chronicle/map/FindFindByName.java index f9d6a1068..a4bc865fc 100644 --- a/src/main/java/net/openhft/chronicle/map/FindMapByName.java +++ b/src/main/java/net/openhft/chronicle/map/FindFindByName.java @@ -18,6 +18,7 @@ package net.openhft.chronicle.map; import net.openhft.chronicle.hash.ChronicleHash; import net.openhft.chronicle.hash.ChronicleHashInstanceConfig; +import net.openhft.chronicle.hash.FindByName; import net.openhft.chronicle.hash.replication.ReplicationHub; import java.io.File; @@ -30,7 +31,7 @@ import static net.openhft.chronicle.map.ChronicleMapBuilder.of; /** * @author Rob Austin. */ -class FindMapByName { +class FindFindByName implements FindByName { public static final int MAP_BY_NAME_CHANNEL = 1; private final ReplicationHub replicationHub; @@ -42,7 +43,7 @@ class FindMapByName { /** * @throws IOException */ - public FindMapByName(ReplicationHub replicationHub) throws IOException { + public FindFindByName(ReplicationHub replicationHub) throws IOException { this.replicationHub = replicationHub; this.map = (Map) of(CharSequence.class, ChronicleMapBuilder.class) .entrySize(300) @@ -54,7 +55,7 @@ class FindMapByName { ChronicleMapBuilder chronicleMapBuilder = map.get(name); if (chronicleMapBuilder == null) - throw new IllegalArgumentException("A map of this name can not be found name=" + name); + throw new IllegalArgumentException("A map name=" + name + " can not be found."); return chronicleMapBuilder; } diff --git a/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java b/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java index ea5b7f2e3..2bd8506b5 100644 --- a/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java +++ b/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java @@ -43,7 +43,6 @@ import java.util.concurrent.atomic.AtomicReference; import static java.nio.ByteBuffer.allocateDirect; import static java.util.concurrent.TimeUnit.SECONDS; -import static net.openhft.chronicle.hash.replication.UdpTransportConfig.of; import static net.openhft.chronicle.map.ConcurrentExpiryMap.getDefaultAddress; import static net.openhft.chronicle.map.DiscoveryNodeBytesMarshallable.ProposedNodes; import static net.openhft.chronicle.map.NodeDiscoveryBroadcaster.BOOTSTRAP_BYTES; @@ -56,22 +55,23 @@ import static net.openhft.chronicle.map.NodeDiscoveryBroadcaster.LOG; */ public class NodeDiscovery { - public static final int DEFAULT_UDP_BROADCAST_PORT = 8124; + public static final int DEFAULT_UDP_BROADCAST_PORT = 8129; public static final short DEFAULT_TCP_PORT = (short) 8123; public static final int SERIALIZED_ENTRY_SIZE = 1024; + private final AddressAndPort ourAddressAndPort; private final UdpTransportConfig udpConfig; - public static final InetAddress DEFAULT_UDP_MASK; + public static final InetAddress IP_MULIT_CAST_GROUP; static { InetAddress mask = null; try { - mask = Inet4Address.getByName("255.255.255.255"); + mask = Inet4Address.getByName("224.0.8.0"); } catch (Exception e) { mask = null; } - DEFAULT_UDP_MASK = mask; + IP_MULIT_CAST_GROUP = mask; } @@ -79,18 +79,21 @@ public class NodeDiscovery { private final DiscoveryNodeBytesMarshallable discoveryNodeBytesMarshallable; private final AtomicReference nodeDiscoveryEventListenerAtomicReference = new AtomicReference(); + + private KnownNodes knownNodes; public NodeDiscovery() throws IOException { - this((short) DEFAULT_UDP_BROADCAST_PORT, DEFAULT_TCP_PORT, getDefaultAddress(), DEFAULT_UDP_MASK); + this((short) DEFAULT_UDP_BROADCAST_PORT, DEFAULT_TCP_PORT, getDefaultAddress(), IP_MULIT_CAST_GROUP); } public NodeDiscovery(short udpBroadcastPort, short tcpPort, @NotNull InetAddress tcpAddress, - @NotNull InetAddress udpBroadcastAddress) throws IOException { + @NotNull InetAddress udpMultiCastGroup) throws IOException { this.ourAddressAndPort = new AddressAndPort(tcpAddress.getAddress(), tcpPort); - this.udpConfig = of(udpBroadcastAddress, udpBroadcastPort); + this.udpConfig = UdpTransportConfig.multiCast(udpMultiCastGroup, udpBroadcastPort, + ConcurrentExpiryMap.defaultNetworkInterface()); knownNodes = new KnownNodes(); discoveryNodeBytesMarshallable = new DiscoveryNodeBytesMarshallable @@ -103,7 +106,7 @@ public class NodeDiscovery { } - public synchronized FindMapByName discoverMap() throws + public synchronized FindFindByName mapByName() throws IOException, InterruptedException { final AtomicInteger ourProposedIdentifier = new AtomicInteger(); @@ -252,7 +255,7 @@ public class NodeDiscovery { .tcpTransportAndNetwork(tcpConfig) .createWithId(identifier); - return new FindMapByName(replicationHub); + return new FindFindByName(replicationHub); } diff --git a/src/main/java/net/openhft/chronicle/map/OffHeapUpdatableChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/OffHeapUpdatableChronicleMapBuilder.java index fa50e5db0..68b4391fa 100644 --- a/src/main/java/net/openhft/chronicle/map/OffHeapUpdatableChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/OffHeapUpdatableChronicleMapBuilder.java @@ -25,7 +25,7 @@ import net.openhft.lang.model.DataValueClasses; import org.jetbrains.annotations.NotNull; final class OffHeapUpdatableChronicleMapBuilder - extends AbstractChronicleMapBuilder> implements ChronicleMapBuilderI { + extends AbstractChronicleMapBuilder> { public static ChronicleMapBuilderI of( @NotNull Class keyClass, @NotNull Class valueClass) { diff --git a/src/main/java/net/openhft/chronicle/map/OnHeapUpdatableChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/OnHeapUpdatableChronicleMapBuilder.java index 803d4e292..285a80a33 100644 --- a/src/main/java/net/openhft/chronicle/map/OnHeapUpdatableChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/OnHeapUpdatableChronicleMapBuilder.java @@ -37,10 +37,9 @@ import java.io.Serializable; * non-{@link Byteable} values, which don't point to off-heap memory directly, including primitives ({@link * Long}, {@link Double}, etc.), {@link String}s and {@link CharSequence}s, values implementing {@link * BytesMarshallable}, {@link Externalizable} or {@link Serializable} interface, or any other values for which - * {@linkplain #valueMarshaller(BytesMarshaller) custom marshaller} is provided. - *

- *

Use static {@link #of(Class, Class) of(Key.class, Value.class)} method to obtain a {@code - * ChronicleMapOnHeapUpdatableBuilder} instance. + * {@linkplain #valueMarshaller(BytesMarshaller) custom marshaller} is provided.

Use static {@link + * #of(Class, Class) of(Key.class, Value.class)} method to obtain a {@code ChronicleMapOnHeapUpdatableBuilder} + * instance. * * @param key type of the maps, created by this builder * @param value type of the maps, created by this builder @@ -49,15 +48,13 @@ import java.io.Serializable; * @see ChronicleHashBuilder */ final class OnHeapUpdatableChronicleMapBuilder - extends AbstractChronicleMapBuilder> implements - ChronicleMapBuilderI { + extends AbstractChronicleMapBuilder> { /** * Returns a new {@code ChronicleMapOnHeapUpdatableBuilder} instance which is able to {@linkplain - * #create() create} maps with the specified key and value classes. - *

- *

{@code ChronicleMapOnHeapUpdatableBuilder} analyzes provided key and value classes and automatically - * chooses the most specific and effective serializer which it is aware about. Read

{@code + * ChronicleMapOnHeapUpdatableBuilder} analyzes provided key and value classes and automatically chooses + * the most specific and effective serializer which it is aware about. Read the section about serialization in * Chronicle Map manual for more information. * @@ -107,14 +104,11 @@ final class OnHeapUpdatableChronicleMapBuilder /** * Configures the optimal number of bytes, taken by serialized form of values, put into maps, created by * this builder. If value size is always the same, call {@link #constantValueSizeBySample(Object)} method - * instead of this one. - *

- *

If value is a boxed primitive type, i. e. if value size is known statically, it is automatically - * accounted and shouldn't be specified by user. - *

- *

If value size varies moderately, specify the size higher than average, but lower than the maximum - * possible, to minimize average memory overuse. If value size varies in a wide range, it's better to use - * {@linkplain #entrySize(int) entry size} in "chunk" mode and configure it directly. + * instead of this one.

If value is a boxed primitive type, i. e. if value size is known + * statically, it is automatically accounted and shouldn't be specified by user.

If value size + * varies moderately, specify the size higher than average, but lower than the maximum possible, to + * minimize average memory overuse. If value size varies in a wide range, it's better to use {@linkplain + * #entrySize(int) entry size} in "chunk" mode and configure it directly. * * @param valueSize number of bytes, taken by serialized form of values * @return this {@code ChronicleMapOnHeapUpdatableBuilder} back @@ -130,13 +124,10 @@ final class OnHeapUpdatableChronicleMapBuilder /** * Configures the constant number of bytes, taken by serialized form of values, put into maps, created by * this builder. This is done by providing the {@code sampleValue}, all values should take the same number - * of bytes in serialized form, as this sample object. - *

- *

If values are of boxed primitive type or {@link Byteable} subclass, i. e. if value size is known - * statically, it is automatically accounted and this method shouldn't be called. - *

- *

If value size varies, method {@link #valueSize(int)} or {@link #entrySize(int)} should be called - * instead of this one. + * of bytes in serialized form, as this sample object.

If values are of boxed primitive type or + * {@link Byteable} subclass, i. e. if value size is known statically, it is automatically accounted and + * this method shouldn't be called.

If value size varies, method {@link #valueSize(int)} or {@link + * #entrySize(int)} should be called instead of this one. * * @param sampleValue the sample value * @return this builder back @@ -151,8 +142,7 @@ final class OnHeapUpdatableChronicleMapBuilder } /** - * {@inheritDoc} - *

+ * {@inheritDoc}

*

Example:

{@code Map map =
      *     ChronicleMapBuilder.of(Key.class, Value.class)
      *     .entries(1_000_000)
@@ -160,9 +150,8 @@ final class OnHeapUpdatableChronicleMapBuilder
      *     // this class hasn't implemented yet, just for example
      *     .objectSerializer(new KryoObjectSerializer())
      *     .create();}
- *

- *

This serializer is used to serialize both keys and values, if they both require this: loosely typed, - * nullable, and custom {@linkplain #keyMarshaller(BytesMarshaller) key} and {@linkplain + *

This serializer is used to serialize both keys and values, if they both require this: loosely + * typed, nullable, and custom {@linkplain #keyMarshaller(BytesMarshaller) key} and {@linkplain * #valueMarshaller(BytesMarshaller) value} marshallers are not configured. */ @Override @@ -172,14 +161,12 @@ final class OnHeapUpdatableChronicleMapBuilder } /** - * {@inheritDoc} - *

- *

If {@linkplain #valueMarshaller(BytesMarshaller) custom value marshaller} is configured, this - * configuration is unused, because it is incapsulated in {@link BytesMarshaller#read(Bytes)} method - * (without provided instance to read the data into), i. e. it's is the user-side responsibility. Actually - * this is just a convenience method supporting value marshaller configurations, made initially during - * {@link #of(Class, Class)} call, if the value class is {@link BytesMarshallable} or {@link - * Externalizable} subclass. + * {@inheritDoc}

If {@linkplain #valueMarshaller(BytesMarshaller) custom value marshaller} is + * configured, this configuration is unused, because it is incapsulated in {@link + * BytesMarshaller#read(Bytes)} method (without provided instance to read the data into), i. e. it's is + * the user-side responsibility. Actually this is just a convenience method supporting value marshaller + * configurations, made initially during {@link #of(Class, Class)} call, if the value class is {@link + * BytesMarshallable} or {@link Externalizable} subclass. * * @throws IllegalStateException if custom value marshaller is specified or value class is not either * {@code BytesMarshallable} or {@code Externalizable} @@ -191,9 +178,7 @@ final class OnHeapUpdatableChronicleMapBuilder } /** - * {@inheritDoc} - *

- *

By default, the default value is set to {@code null}. + * {@inheritDoc}

By default, the default value is set to {@code null}. * * @see #defaultValueProvider(DefaultValueProvider) */ @@ -203,10 +188,8 @@ final class OnHeapUpdatableChronicleMapBuilder } /** - * {@inheritDoc} - *

- *

By default, default value provider is not specified, {@link #defaultValue(Object) default value} is - * specified instead. + * {@inheritDoc}

By default, default value provider is not specified, {@link #defaultValue(Object) + * default value} is specified instead. * * @see #defaultValue(Object) */ @@ -236,13 +219,11 @@ final class OnHeapUpdatableChronicleMapBuilder /** * Configures the marshallers, used to serialize/deserialize values to/from off-heap memory in maps, * created by this builder. See the - * section about serialization in ChronicleMap manual for more information. - *

- *

Configuring marshalling this way results to a little bit more compact in-memory layout of the map, - * comparing to a single interface configuration: {@link #valueMarshaller(BytesMarshaller)}. - *

- *

Passing {@link net.openhft.chronicle.hash.serialization.BytesInterop} instead of plain {@link - * BytesWriter} is, of cause, possible, but currently pointless for values. + * section about serialization in ChronicleMap manual for more information.

Configuring + * marshalling this way results to a little bit more compact in-memory layout of the map, comparing to a + * single interface configuration: {@link #valueMarshaller(BytesMarshaller)}.

Passing {@link + * net.openhft.chronicle.hash.serialization.BytesInterop} instead of plain {@link BytesWriter} is, of + * cause, possible, but currently pointless for values. * * @param valueWriter the new value object → {@link Bytes} writer (interop) strategy * @param valueReader the new {@link Bytes} → value object reader strategy @@ -258,15 +239,14 @@ final class OnHeapUpdatableChronicleMapBuilder /** * Configures the marshaller used to serialize actual value sizes to off-heap memory in maps, created by - * this builder. - *

- *

Default value size marshaller is so-called {@linkplain net.openhft.chronicle.hash.serialization.SizeMarshallers#stopBit() - * stop bit encoding marshalling}. If {@linkplain #constantValueSizeBySample(Object) constant value size} - * is configured, or defaulted if the value type is always constant and {@code ChronicleHashBuilder} - * implementation knows about it, this configuration takes no effect, because a special {@link - * SizeMarshaller} implementation, which doesn't actually do any marshalling, and just returns the known - * constant size on {@link SizeMarshaller#readSize(Bytes)} calls, is used instead of any {@code - * SizeMarshaller} configured using this method. + * this builder.

Default value size marshaller is so-called {@linkplain + * net.openhft.chronicle.hash.serialization.SizeMarshallers#stopBit() stop bit encoding marshalling}. If + * {@linkplain #constantValueSizeBySample(Object) constant value size} is configured, or defaulted if the + * value type is always constant and {@code ChronicleHashBuilder} implementation knows about it, this + * configuration takes no effect, because a special {@link SizeMarshaller} implementation, which doesn't + * actually do any marshalling, and just returns the known constant size on {@link + * SizeMarshaller#readSize(Bytes)} calls, is used instead of any {@code SizeMarshaller} configured using + * this method. * * @param valueSizeMarshaller the new marshaller, used to serialize actual value sizes to off-heap memory * @return this builder back @@ -280,9 +260,8 @@ final class OnHeapUpdatableChronicleMapBuilder /** * Configures the procedure which is called on the bytes, which later the returned value is pointing to, * if the key is absent, on {@link ChronicleMap#acquireUsing(Object, Object) acquireUsing()} call on maps, - * created by this builder. See {@link PrepareValueBytes} for more information. - *

- *

The default preparation callback zeroes out the value bytes. + * created by this builder. See {@link PrepareValueBytes} for more information.

The default + * preparation callback zeroes out the value bytes. * * @param prepareValueBytes what to do with the value bytes before assigning them into the {@link * Byteable} value to return from {@code acquireUsing()} call diff --git a/src/test/java/net/openhft/chronicle/map/MapByNameTest.java b/src/test/java/net/openhft/chronicle/map/MapByNameTest.java index c05827626..de0bd1572 100644 --- a/src/test/java/net/openhft/chronicle/map/MapByNameTest.java +++ b/src/test/java/net/openhft/chronicle/map/MapByNameTest.java @@ -20,6 +20,7 @@ import junit.framework.Assert; import net.openhft.chronicle.hash.replication.ReplicationHub; import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import java.io.IOException; @@ -30,16 +31,16 @@ import java.io.IOException; public class MapByNameTest { - private FindMapByName findMapByName; + private FindFindByName findMapByName; @Before public void setUp() throws IOException { final ReplicationHub replicationHub = ReplicationHub.builder() .maxEntrySize(10 * 1024) .tcpTransportAndNetwork(TcpTransportAndNetworkConfig.of(8243)) - .createWithId((byte)1); + .createWithId((byte) 1); - findMapByName = new FindMapByName(replicationHub); + findMapByName = new FindFindByName(replicationHub); } @Test @@ -48,6 +49,7 @@ public class MapByNameTest { final ChronicleMapBuilder builder = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .minSegments(2) .name("map1") + .replication((byte) 1, TcpTransportAndNetworkConfig.of(8244)) .removeReturnsNull(true); findMapByName.add(builder); @@ -65,4 +67,24 @@ public class MapByNameTest { } + // currently work in progress + @Test + @Ignore + public void testConnectByName() throws IOException, InterruptedException { + + NodeDiscovery nodeDiscovery = new NodeDiscovery(); + + ChronicleMapBuilder builder = ChronicleMapBuilder.of(CharSequence + .class, CharSequence.class) + .minSegments(2) + .name("myMap") + .removeReturnsNull(true); + + FindFindByName mapByName = nodeDiscovery.mapByName(); + mapByName.add(builder); + + ChronicleMap myMap2 = mapByName.create("myMap"); + + } + } diff --git a/src/test/java/net/openhft/chronicle/map/TimeBasedReplicationTest.java b/src/test/java/net/openhft/chronicle/map/TimeBasedReplicationTest.java index 639da0acd..b954de03d 100644 --- a/src/test/java/net/openhft/chronicle/map/TimeBasedReplicationTest.java +++ b/src/test/java/net/openhft/chronicle/map/TimeBasedReplicationTest.java @@ -52,7 +52,8 @@ public class TimeBasedReplicationTest extends JSR166TestCase { ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) - .createReplicated((byte) 1); + .replication((byte)1) + .create(); current(timeProvider); @@ -81,8 +82,8 @@ public class TimeBasedReplicationTest extends JSR166TestCase { ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) - .createReplicated((byte) 1); - + .replication((byte)1) + .create(); current(timeProvider); // we do a put at the current time @@ -111,7 +112,8 @@ public class TimeBasedReplicationTest extends JSR166TestCase { ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) - .createReplicated((byte) 1); + .replication((byte)1) + .create(); current(timeProvider); @@ -144,7 +146,8 @@ public class TimeBasedReplicationTest extends JSR166TestCase { ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) - .createReplicated((byte) 1); + .replication((byte) 1) + .create(); current(timeProvider); @@ -174,7 +177,8 @@ public class TimeBasedReplicationTest extends JSR166TestCase { ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) - .createReplicated((byte) 1); + .replication((byte) 1) + .create(); current(timeProvider); @@ -203,7 +207,8 @@ public class TimeBasedReplicationTest extends JSR166TestCase { ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) - .createReplicated((byte) 1); + .replication((byte) 1) + .create(); current(timeProvider); @@ -232,7 +237,8 @@ public class TimeBasedReplicationTest extends JSR166TestCase { ReplicatedChronicleMap map = (ReplicatedChronicleMap) ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) - .createReplicated((byte) 1); + .replication((byte) 1) + .create(); current(timeProvider); @@ -262,7 +268,8 @@ public class TimeBasedReplicationTest extends JSR166TestCase { ReplicatedChronicleMap map = (ReplicatedChronicleMap) ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) - .createReplicated((byte) 1); + .replication((byte) 1) + .create(); current(timeProvider); @@ -292,7 +299,8 @@ public class TimeBasedReplicationTest extends JSR166TestCase { ReplicatedChronicleMap map = (ReplicatedChronicleMap) ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) - .createReplicated((byte) 1); + .replication((byte)1) + .create(); current(timeProvider); @@ -320,8 +328,8 @@ public class TimeBasedReplicationTest extends JSR166TestCase { ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) - .createReplicated((byte) 1); - + .replication((byte)1) + .create(); current(timeProvider); // we do a put at the current time