From 49fc12375573acb16475762c34ce448b81d8b0cf Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Sat, 15 Nov 2014 09:05:26 +0000 Subject: [PATCH] HCOLL-81 made publicly a single ChronicleMapBuilder, that delegates onto internal implementations --- .../map/AbstractChronicleMapBuilder.java | 10 +- .../openhft/chronicle/map/ChronicleMap.java | 4 +- .../chronicle/map/ChronicleMapBuilder.java | 488 +++++++++++++++--- .../chronicle/map/ChronicleMapBuilderI.java | 299 +++++++++++ .../ChronicleMapOnHeapUpdatableBuilder.java | 284 ---------- .../openhft/chronicle/map/NodeDiscovery.java | 4 +- .../OffHeapUpdatableChronicleMapBuilder.java | 172 ++++++ .../OnHeapUpdatableChronicleMapBuilder.java | 311 +++++++++++ .../chronicle/map/StatelessChronicleMap.java | 7 +- .../chronicle/set/ChronicleSetBuilder.java | 6 +- .../net/openhft/chronicle/set/DummyValue.java | 2 +- src/test/java/eg/BigData.java | 7 +- .../net/openhft/chronicle/map/Builder.java | 7 +- .../chronicle/map/CHMMetaDataTest.java | 2 +- .../net/openhft/chronicle/map/CHMTest5.java | 2 +- .../chronicle/map/CHMTestIterator1.java | 2 +- .../chronicle/map/ChannelReplicationTest.java | 8 +- .../chronicle/map/ChronicleMapTest.java | 30 +- .../chronicle/map/ConcurrentMap8Test.java | 4 +- .../map/ConstantSizeBySampleTest.java | 8 +- .../chronicle/map/DefaultValueTest.java | 4 +- .../chronicle/map/EntryCountMapTest.java | 3 +- ...tListenerTestWithTCPSocketReplication.java | 16 +- .../net/openhft/chronicle/map/GuavaTest.java | 4 +- .../chronicle/map/IntValueMapTest.java | 2 +- .../openhft/chronicle/map/Issue42Test.java | 2 +- .../openhft/chronicle/map/KeySizesTest.java | 2 +- .../openhft/chronicle/map/OSResizesMain.java | 2 +- .../map/PostChannelCreationTest.java | 8 +- .../map/ProcessInstanceLimiterMain.java | 4 +- .../map/RecursiveRefereneChMapTest.java | 2 +- .../map/ReplicatedChronicleMapTest.java | 4 +- .../openhft/chronicle/map/SerializerTest.java | 13 +- .../chronicle/map/SingleMapChannelTest.java | 4 +- .../chronicle/map/StatelessClientTest.java | 52 +- ...cketReplication3wayPutReturnsNullTest.java | 2 +- .../TCPSocketReplicationBootStrapTest.java | 4 +- .../map/TCPSocketReplicationIntValueTest.java | 2 +- ...CPSocketReplicationPostConnectionTest.java | 2 +- .../map/TCPSocketReplicationTest.java | 2 +- .../chronicle/map/TestBooleanValues.java | 2 +- .../map/TimeBasedReplicationTest.java | 20 +- .../map/TwoMapOnDifferentServersTest.java | 4 +- .../map/UDPSocketReplicationTest.java | 2 +- .../chronicle/map/example/ChannelExample.java | 11 +- .../map/example/DistributedSequenceMain.java | 4 +- .../chronicle/map/example/ServersMapMain.java | 8 +- .../chronicle/map/example/StringsMapMain.java | 9 +- .../pingpong_latency/PingPongCASLeft.java | 4 +- .../map/ipc/StateMachineTutorial.java | 4 +- .../map/jrs166/map/ChronicleMapTest.java | 14 +- .../chronicle/map/jrs166/map/MapCheck.java | 4 +- .../jrs166/map/StatelessChronicleMapTest.java | 14 +- .../map/utility/ProcessInstanceLimiter.java | 6 +- 54 files changed, 1373 insertions(+), 524 deletions(-) create mode 100644 src/main/java/net/openhft/chronicle/map/ChronicleMapBuilderI.java delete mode 100644 src/main/java/net/openhft/chronicle/map/ChronicleMapOnHeapUpdatableBuilder.java create mode 100644 src/main/java/net/openhft/chronicle/map/OffHeapUpdatableChronicleMapBuilder.java create mode 100644 src/main/java/net/openhft/chronicle/map/OnHeapUpdatableChronicleMapBuilder.java diff --git a/src/main/java/net/openhft/chronicle/map/AbstractChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/AbstractChronicleMapBuilder.java index c7cfe7fac..7aaed90a9 100644 --- a/src/main/java/net/openhft/chronicle/map/AbstractChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/AbstractChronicleMapBuilder.java @@ -57,7 +57,7 @@ import static net.openhft.chronicle.map.Objects.builderEquals; /** * {@code AbstractChronicleMapBuilder} manages most of {@link ChronicleMap} configurations; has two concrete - * subclasses: {@link ChronicleMapOnHeapUpdatableBuilder} should be used to create maps with ordinary values, {@link + * subclasses: {@link OnHeapUpdatableChronicleMapBuilder} should be used to create maps with ordinary values, {@link * ChronicleMapBuilder} -- maps with {@link Byteable} values, which point directly to off-heap * memory; could be used as a classic builder and/or factory. This means * that in addition to the standard builder usage pattern:
{@code
@@ -66,7 +66,7 @@ import static net.openhft.chronicle.map.Objects.builderEquals;
  *     .entries(100500)
  *     // ... other configurations
  *     .create();}
- * one of concrete {@code AbstractChronicleMapBuilder} subclasses, {@link ChronicleMapOnHeapUpdatableBuilder} or {@link + * one of concrete {@code AbstractChronicleMapBuilder} subclasses, {@link OnHeapUpdatableChronicleMapBuilder} or {@link * ChronicleMapBuilder}, could be prepared and used to create many similar * maps:
{@code
  * ChronicleMapBuilder builder = ChronicleMapBuilder
@@ -227,7 +227,7 @@ public abstract class AbstractChronicleMapBuilderFor example, if your keys are Git commit hashes:
{@code
      * Map gitCommitMessagesByHash =
-     *     ChronicleMapOnHeapUpdatableBuilder.of(byte[].class, String.class)
+     *     ChronicleMapBuilder.of(byte[].class, String.class)
      *     .constantKeySizeBySample(new byte[20])
      *     .create();}
* @@ -839,12 +839,10 @@ public abstract class AbstractChronicleMapBuilder createReplicated(byte identifier) throws IOException { + public ChronicleMap createReplicated(byte identifier) throws IOException { preMapConstruction(true); VanillaChronicleMap map = new ReplicatedChronicleMap, diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ChronicleMap.java index 0a0066f03..4bc5d71ed 100644 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMap.java @@ -93,7 +93,7 @@ public interface ChronicleMap extends ConcurrentMap, ChronicleHash { * for the key * @see #get(Object) * @see #acquireUsing(Object, Object) - * @see ChronicleMapOnHeapUpdatableBuilder#valueMarshaller(BytesMarshaller) + * @see OnHeapUpdatableChronicleMapBuilder#valueMarshaller(BytesMarshaller) */ V getUsing(K key, V usingValue); @@ -134,7 +134,7 @@ public interface ChronicleMap extends ConcurrentMap, ChronicleHash { * no mapping for the key * @see #get(Object) * @see #getUsing(Object, Object) - * @see ChronicleMapOnHeapUpdatableBuilder#valueMarshaller(BytesMarshaller) + * @see OnHeapUpdatableChronicleMapBuilder#valueMarshaller(BytesMarshaller) */ @NotNull ReadContext getUsingLocked(@NotNull K key, @NotNull V usingValue); diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java index 8d28b4966..6f3c4d73a 100644 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java @@ -1,80 +1,109 @@ -/* - * Copyright 2014 Higher Frequency Trading http://www.higherfrequencytrading.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - package net.openhft.chronicle.map; +import net.openhft.chronicle.hash.ChronicleHashErrorListener; +import net.openhft.chronicle.hash.ChronicleHashInstanceConfig; +import net.openhft.chronicle.hash.StatelessClientConfig; +import net.openhft.chronicle.hash.replication.SingleChronicleHashReplication; +import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig; +import net.openhft.chronicle.hash.replication.TimeProvider; +import net.openhft.chronicle.hash.serialization.BytesReader; +import net.openhft.chronicle.hash.serialization.BytesWriter; +import net.openhft.chronicle.hash.serialization.SizeMarshaller; +import net.openhft.lang.io.serialization.BytesMarshaller; +import net.openhft.lang.io.serialization.BytesMarshallerFactory; +import net.openhft.lang.io.serialization.ObjectFactory; +import net.openhft.lang.io.serialization.ObjectSerializer; import net.openhft.lang.model.Byteable; import net.openhft.lang.model.DataValueClasses; import org.jetbrains.annotations.NotNull; -public final class ChronicleMapBuilder - extends AbstractChronicleMapBuilder> { +import java.io.File; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.util.concurrent.TimeUnit; +/** + * {@code ChronicleMapBuilder} is intended to be used to create {@link ChronicleMap}s + * + * @param key type of the maps, created by this builder + * @param value type of the maps, created by this builder + * @see AbstractChronicleMapBuilder + * @see net.openhft.chronicle.hash.ChronicleHashBuilder + */ +public final class ChronicleMapBuilder implements ChronicleMapBuilderI { + + final ChronicleMapBuilderI delegate; + + /** + * Returns a new {@code ChronicleMapBuilder} instance which is able to {@linkplain #create() create} maps + * with the specified key and value classes. + * + *

{@code ChronicleMapBuilder} analyzes provided key and value classes and automatically chooses the + * most specific internal builder. + * + * @param keyClass class object used to infer key type and discover it's properties via reflection + * @param valueClass class object used to infer value type and discover it's properties via reflection + * @param key type of the maps, created by the returned builder + * @param value type of the maps, created by the returned builder + * @return a new builder for the given key and value classes + */ public static ChronicleMapBuilder of( @NotNull Class keyClass, @NotNull Class valueClass) { + + if (valueClass.isEnum()) + return new ChronicleMapBuilder(OnHeapUpdatableChronicleMapBuilder.of(keyClass, valueClass)); + if (keyClass.isInterface() && keyClass != CharSequence.class) { keyClass = DataValueClasses.directClassFor(keyClass); } - if (valueClass.isInterface()) { + + if ((valueClass.isInterface() && valueClass != CharSequence.class)) { valueClass = DataValueClasses.directClassFor(valueClass); } else if (!offHeapReference(valueClass)) { - throw new IllegalArgumentException( - "Value class should be either Byteable subclass or interface," + - "allowing direct Byteable implementation generation"); + return new ChronicleMapBuilder(OnHeapUpdatableChronicleMapBuilder.of(keyClass, valueClass)); } - return new ChronicleMapBuilder(keyClass, valueClass); + OffHeapUpdatableChronicleMapBuilder kvOffHeapUpdatableChronicleMapBuilder = new + OffHeapUpdatableChronicleMapBuilder(keyClass, valueClass); + return new ChronicleMapBuilder(kvOffHeapUpdatableChronicleMapBuilder); } - ChronicleMapBuilder(Class keyClass, Class valueClass) { - super(keyClass, valueClass); - prepareValueBytesOnAcquire(new ZeroOutValueBytes(valueSize())); + ChronicleMapBuilder(ChronicleMapBuilderI delegate) { + this.delegate = delegate; } - @Override - ChronicleMapBuilder self() { - return this; + + private static boolean offHeapReference(Class valueClass) { + return Byteable.class.isAssignableFrom(valueClass); } + /** * {@inheritDoc} With respect to {@linkplain #entryAndValueAlignment(Alignment) alignment}. * *

Note that the actual entrySize will be aligned to 4 (default {@linkplain - * #entryAndValueAlignment(Alignment) entry alignment}). I. e. if you set entry size to 30, - * and entry alignment is set to {@link Alignment#OF_4_BYTES}, the actual entry size will be 32 - * (30 aligned to 4 bytes). + * #entryAndValueAlignment(Alignment) entry alignment}). I. e. if you set entry size to 30, and entry + * alignment is set to {@link Alignment#OF_4_BYTES}, the actual entry size will be 32 (30 aligned to 4 + * bytes). * - * @see #entryAndValueAlignment(Alignment) - * @see #entries(long) + * @see #entryAndValueAlignment(Alignment) // * @see #entries(long) */ @Override public ChronicleMapBuilder entrySize(int entrySize) { - return super.entrySize(entrySize); + delegate.entrySize(entrySize); + return this; } /** - * Configures alignment strategy of address in memory of entries and independently of address in - * memory of values within entries in ChronicleMaps, created by this builder. + * Configures alignment strategy of address in memory of entries and independently of address in memory of + * values within entries in ChronicleMaps, created by this builder. * - *

Useful when values of the map are updated intensively, particularly fields with volatile - * access, because it doesn't work well if the value crosses cache lines. Also, on some - * (nowadays rare) architectures any misaligned memory access is more expensive than aligned. + *

Useful when values of the map are updated intensively, particularly fields with volatile access, + * because it doesn't work well if the value crosses cache lines. Also, on some (nowadays rare) + * architectures any misaligned memory access is more expensive than aligned. * - *

Note that {@linkplain #entrySize(int) entry size} will be aligned according to this - * alignment. I. e. if you set {@code entrySize(20)} and {@link Alignment#OF_8_BYTES}, actual - * entry size will be 24 (20 aligned to 8 bytes). + *

Note that {@linkplain #entrySize(int) entry size} will be aligned according to this alignment. I. e. + * if you set {@code entrySize(20)} and {@link Alignment#OF_8_BYTES}, actual entry size will be 24 (20 + * aligned to 8 bytes). * *

Default is {@link Alignment#OF_4_BYTES} for Byteable values. * @@ -83,58 +112,369 @@ public final class ChronicleMapBuilder */ @Override public ChronicleMapBuilder entryAndValueAlignment(Alignment alignment) { - return super.entryAndValueAlignment(alignment); + delegate.entryAndValueAlignment(alignment); + return this; } /** - * {@inheritDoc} Also, it overrides any previous {@link #prepareValueBytesOnAcquire} - * configuration to this {@code ChronicleMapBuilder}. + * {@inheritDoc} Also, it overrides any previous {@link #prepareValueBytesOnAcquire} configuration to this + * {@code ChronicleMapBuilder}. * - *

By default, the default value is not specified, default {@linkplain - * #prepareValueBytesOnAcquire prepare value bytes routine} is specified instead. + *

By default, the default value is not specified, default {@linkplain #prepareValueBytesOnAcquire + * prepare value bytes routine} is specified instead. * * @see #defaultValueProvider(DefaultValueProvider) * @see #prepareValueBytesOnAcquire(PrepareValueBytes) */ @Override public ChronicleMapBuilder defaultValue(V defaultValue) { - return super.defaultValue(defaultValue); + delegate.defaultValue(defaultValue); + return this; } /** - * {@inheritDoc} Also, it overrides any previous {@link #prepareValueBytesOnAcquire} - * configuration to this {@code ChronicleMapBuilder}. - * - *

By default, the default value provider is not specified, default {@linkplain - * #prepareValueBytesOnAcquire prepare value bytes routine} is specified instead. - * - * @see #defaultValue(Object) - * @see #prepareValueBytesOnAcquire(PrepareValueBytes) - */ - @Override - public ChronicleMapBuilder defaultValueProvider( - @NotNull DefaultValueProvider defaultValueProvider) { - return super.defaultValueProvider(defaultValueProvider); - } - - /** - * 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. + * 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. * - * @param prepareValueBytes what to do with the value bytes before assigning them into the - * {@link Byteable} value to return from {@code acquireUsing()} call + * @param prepareValueBytes what to do with the value bytes before assigning them into the {@link + * net.openhft.lang.model.Byteable} value to return from {@code acquireUsing()} + * call * @return this builder back * @see PrepareValueBytes * @see #defaultValue(Object) * @see #defaultValueProvider(DefaultValueProvider) */ @Override - public ChronicleMapBuilder prepareValueBytesOnAcquire( - @NotNull PrepareValueBytes prepareValueBytes) { - return super.prepareValueBytesOnAcquire(prepareValueBytes); + public ChronicleMapBuilder prepareValueBytesOnAcquire(@NotNull PrepareValueBytes prepareValueBytes) { + delegate.prepareValueBytesOnAcquire(prepareValueBytes); + return this; } + + + @Override + public ChronicleMapBuilder keySize(int keySize) { + delegate.keySize(keySize); + return this; + } + + + @Override + public ChronicleMapBuilder constantKeySizeBySample(K sampleKey) { + delegate.constantKeySizeBySample(sampleKey); + return this; + } + + /** + * 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. + * + * @param valueSize number of bytes, taken by serialized form of values + * @return this {@code ChronicleMapOnHeapUpdatableBuilder} back + * @see #constantValueSizeBySample(Object) + * @see #keySize(int) + * @see #entrySize(int) + */ + @Override + public ChronicleMapBuilder valueSize(int valueSize) { + delegate.valueSize(valueSize); + return this; + } + + /** + * 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 net.openhft.lang.model.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 + * @see #valueSize(int) + * @see #constantKeySizeBySample(Object) + */ + @Override + public ChronicleMapBuilder constantValueSizeBySample(@NotNull V sampleValue) { + delegate.constantValueSizeBySample(sampleValue); + return this; + } + + /** + * {@inheritDoc} + * + *

Example:

{@code Map map =
+     *     ChronicleMapBuilder.of(Key.class, Value.class)
+     *     .entries(1_000_000)
+     *     .keySize(50).valueSize(200)
+     *     // this class hasn't implemented yet, just for example
+     *     .objectSerializer(new KryoObjectSerializer())
+     *     .create();}
+ */ + @Override + public ChronicleMapBuilder objectSerializer(@NotNull ObjectSerializer objectSerializer) { + delegate.objectSerializer(objectSerializer); + return this; + } + + + /** + * {@inheritDoc} + * + * @throws IllegalStateException if custom value marshaller is specified or value class is not either + * {@code BytesMarshallable} or {@code Externalizable} + */ + + @Override + public ChronicleMapBuilder valueDeserializationFactory(@NotNull ObjectFactory valueDeserializationFactory) { + delegate.valueDeserializationFactory(valueDeserializationFactory); + return this; + } + + /** + * {@inheritDoc} + * + *

By default, default value provider is not specified, {@link #defaultValue(Object) default value} is + * specified instead. + * + * @see #defaultValue(Object) + */ + @Override + public ChronicleMapBuilder defaultValueProvider(@NotNull DefaultValueProvider defaultValueProvider) { + delegate.defaultValueProvider(defaultValueProvider); + return this; + } + + /** + * Configures the {@code BytesMarshaller} 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. + * + * @param valueMarshaller the marshaller used to serialize values + * @return this builder back + * @see #valueMarshallers(net.openhft.chronicle.hash.serialization.BytesWriter, + * net.openhft.chronicle.hash.serialization.BytesReader) + * @see ChronicleMapBuilder + * @see #objectSerializer(ObjectSerializer) + */ + @Override + public ChronicleMapBuilder valueMarshaller( + @NotNull BytesMarshaller valueMarshaller) { + delegate.valueMarshaller(valueMarshaller); + return this; + } + + /** + * 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 + * net.openhft.chronicle.hash.serialization.BytesWriter} is, of cause, possible, but currently pointless + * for values. + * + * @param valueWriter the new value object → {@link net.openhft.lang.io.Bytes} writer (interop) + * strategy + * @param valueReader the new {@link net.openhft.lang.io.Bytes} → value object reader strategy + * @return this builder back + * @see #valueMarshaller(BytesMarshaller) + */ + @Override + public ChronicleMapBuilder valueMarshallers(@NotNull BytesWriter valueWriter, @NotNull BytesReader valueReader) { + delegate.valueMarshallers(valueWriter, valueReader); + return this; + } + + + /** + * 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 + * net.openhft.chronicle.hash.serialization.SizeMarshaller} implementation, which doesn't actually do any + * marshalling, and just returns the known constant size on {@link net.openhft.chronicle.hash.serialization.SizeMarshaller#readSize( + *net.openhft.lang.io.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 + */ + @Override + public ChronicleMapBuilder valueSizeMarshaller(@NotNull SizeMarshaller valueSizeMarshaller) { + delegate.valueSizeMarshaller(valueSizeMarshaller); + return this; + } + + @Override + public ChronicleMapBuilder entries(long l) { + delegate.entries(l); + return this; + } + + @Override + public ChronicleMapBuilder replication(SingleChronicleHashReplication withId) { + delegate.replication(withId); + return this; + + } + + @Override + public ChronicleMap create() throws IOException { + return delegate.create(); + } + + @Override + public ChronicleMapBuilder actualSegments(int actualSegments) { + delegate.actualSegments(actualSegments); + return this; + } + + @Override + public ChronicleMapBuilder minSegments(int minSegments) { + delegate.minSegments(minSegments); + return this; + } + + @Override + public ChronicleMapBuilder actualEntriesPerSegment(long actualEntriesPerSegment) { + delegate.actualEntriesPerSegment(actualEntriesPerSegment); + return this; + } + + @Override + public ChronicleMapBuilder lockTimeOut(long lockTimeOut, TimeUnit unit) { + delegate.lockTimeOut(lockTimeOut, unit); + return this; + } + + @Override + public ChronicleMapBuilder errorListener(ChronicleHashErrorListener errorListener) { + delegate.errorListener(errorListener); + return this; + } + + @Override + public ChronicleMapBuilder metaDataBytes(int metaDataBytes) { + delegate.metaDataBytes(metaDataBytes); + return this; + } + + @Override + public ChronicleMapBuilder timeProvider(TimeProvider timeProvider) { + delegate.timeProvider(timeProvider); + return this; + } + + @Override + public ChronicleMapBuilder bytesMarshallerFactory(BytesMarshallerFactory bytesMarshallerFactory) { + delegate.bytesMarshallerFactory(bytesMarshallerFactory); + return this; + } + + @Override + public ChronicleMapBuilder keyMarshaller(BytesMarshaller keyMarshaller) { + delegate.keyMarshaller(keyMarshaller); + return this; + } + + @Override + public ChronicleMapBuilder keyMarshallers(BytesWriter keyWriter, BytesReader keyReader) { + delegate.keyMarshallers(keyWriter, keyReader); + return this; + } + + @Override + public ChronicleMapBuilder keySizeMarshaller(SizeMarshaller keySizeMarshaller) { + delegate.keySizeMarshaller(keySizeMarshaller); + return this; + } + + @Override + public ChronicleMapBuilder keyDeserializationFactory(ObjectFactory keyDeserializationFactory) { + delegate.keyDeserializationFactory(keyDeserializationFactory); + return this; + } + + @Override + public ChronicleMapBuilder immutableKeys() { + delegate.immutableKeys(); + return this; + } + + + @Override + public StatelessClientConfig> statelessClient(InetSocketAddress remoteAddress) { + return delegate.statelessClient(remoteAddress); + } + + @Override + public ChronicleHashInstanceConfig> instance() { + return delegate.instance(); + } + + @Override + public ChronicleMapBuilder replication(byte identifier) { + delegate.replication(identifier); + return this; + } + + @Override + public ChronicleMapBuilder replication(byte identifier, TcpTransportAndNetworkConfig tcpTransportAndNetwork) { + delegate.replication(identifier, tcpTransportAndNetwork); + return this; + } + + @Override + public ChronicleMapBuilder clone() { + delegate.clone(); + return this; + } + + @Override + public ChronicleMapBuilder putReturnsNull(boolean b) { + delegate.putReturnsNull(b); + return this; + } + + @Override + public ChronicleMapBuilder removeReturnsNull(boolean b) { + delegate.removeReturnsNull(b); + return this; + } + + @Override + public ChronicleMapBuilder eventListener(MapEventListener> eventListener) { + delegate.eventListener(eventListener); + return this; + } + + @Override + public ChronicleMap createReplicated(byte b) throws IOException { + return delegate.createReplicated(b); + } + + @Override + public ChronicleMap createPersistedTo(File file) throws IOException { + 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 new file mode 100644 index 000000000..f121b6c7e --- /dev/null +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilderI.java @@ -0,0 +1,299 @@ +package net.openhft.chronicle.map; + +import net.openhft.chronicle.hash.ChronicleHashErrorListener; +import net.openhft.chronicle.hash.ChronicleHashInstanceConfig; +import net.openhft.chronicle.hash.StatelessClientConfig; +import net.openhft.chronicle.hash.replication.SingleChronicleHashReplication; +import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig; +import net.openhft.chronicle.hash.replication.TimeProvider; +import net.openhft.chronicle.hash.serialization.BytesReader; +import net.openhft.chronicle.hash.serialization.BytesWriter; +import net.openhft.chronicle.hash.serialization.SizeMarshaller; +import net.openhft.lang.io.serialization.BytesMarshaller; +import net.openhft.lang.io.serialization.BytesMarshallerFactory; +import net.openhft.lang.io.serialization.ObjectFactory; +import net.openhft.lang.io.serialization.ObjectSerializer; +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.util.concurrent.TimeUnit; + +/** + * @author Rob Austin. + */ +interface ChronicleMapBuilderI { + + + /** + * {@inheritDoc} With respect to {@linkplain #entryAndValueAlignment(Alignment) alignment}. + * + *

Note that the actual entrySize will be aligned to 4 (default {@linkplain + * #entryAndValueAlignment(Alignment) entry alignment}). I. e. if you set entry size to 30, and entry + * alignment is set to {@link Alignment#OF_4_BYTES}, the actual entry size will be 32 (30 aligned to 4 + * bytes). + * + * @see #entryAndValueAlignment(Alignment) // * @see #entries(long) + */ + ChronicleMapBuilderI entrySize(int entrySize); + + /** + * Configures alignment strategy of address in memory of entries and independently of address in memory of + * values within entries in ChronicleMaps, created by this builder. + * + *

Useful when values of the map are updated intensively, particularly fields with volatile access, + * because it doesn't work well if the value crosses cache lines. Also, on some (nowadays rare) + * architectures any misaligned memory access is more expensive than aligned. + * + *

Note that {@linkplain #entrySize(int) entry size} will be aligned according to this alignment. I. e. + * if you set {@code entrySize(20)} and {@link Alignment#OF_8_BYTES}, actual entry size will be 24 (20 + * aligned to 8 bytes). + * + *

Default is {@link Alignment#OF_4_BYTES} for Byteable values. + * + * @param alignment the new alignment of the maps constructed by this builder + * @return this {@code ChronicleMapOnHeapUpdatableBuilder} back + */ + ChronicleMapBuilderI entryAndValueAlignment(Alignment alignment); + + + /** + * {@inheritDoc} Also, it overrides any previous {@link #prepareValueBytesOnAcquire} configuration to this + * {@code ChronicleMapBuilder}. + * + *

By default, the default value is not specified, default {@linkplain #prepareValueBytesOnAcquire + * prepare value bytes routine} is specified instead. + * + * @see #defaultValueProvider(DefaultValueProvider) + * @see #prepareValueBytesOnAcquire(PrepareValueBytes) + */ + ChronicleMapBuilderI defaultValue(V defaultValue); + + + /** + * 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. + * + * @param prepareValueBytes what to do with the value bytes before assigning them into the {@link + * net.openhft.lang.model.Byteable} value to return from {@code acquireUsing()} + * call + * @return this builder back + * @see PrepareValueBytes + * @see #defaultValue(Object) + * @see #defaultValueProvider(DefaultValueProvider) + */ + ChronicleMapBuilderI prepareValueBytesOnAcquire( + @NotNull PrepareValueBytes prepareValueBytes); + + + /** + * {@inheritDoc} + * + * @see #constantKeySizeBySample(Object) + * @see #valueSize(int) + * @see #entrySize(int) + */ + ChronicleMapBuilderI keySize(int keySize); + + /** + * {@inheritDoc} + * + * @see #keySize(int) + * @see #constantValueSizeBySample(Object) + */ + + ChronicleMapBuilderI constantKeySizeBySample(K sampleKey); + + /** + * 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. + * + * @param valueSize number of bytes, taken by serialized form of values + * @return this {@code ChronicleMapOnHeapUpdatableBuilder} back + * @see #constantValueSizeBySample(Object) + * @see #keySize(int) + * @see #entrySize(int) + */ + + ChronicleMapBuilderI valueSize(int valueSize); + + /** + * 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 net.openhft.lang.model.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 + * @see #valueSize(int) + * @see #constantKeySizeBySample(Object) + */ + + + ChronicleMapBuilderI constantValueSizeBySample( + @NotNull V sampleValue); + + /** + * {@inheritDoc} + * + *

Example:

{@code Map map =
+     *     ChronicleMapBuilder.of(Key.class, Value.class)
+     *     .entries(1_000_000)
+     *     .keySize(50).valueSize(200)
+     *     // this class hasn't implemented yet, just for example
+     *     .objectSerializer(new KryoObjectSerializer())
+     *     .create();}
+ */ + + ChronicleMapBuilderI objectSerializer( + @NotNull ObjectSerializer objectSerializer); + + /** + * {@inheritDoc} + * + * @throws IllegalStateException if custom value marshaller is specified or value class is not either + * {@code BytesMarshallable} or {@code Externalizable} + */ + + ChronicleMapBuilderI valueDeserializationFactory( + @NotNull ObjectFactory valueDeserializationFactory); + + /** + * {@inheritDoc} + * + *

By default, default value provider is not specified, {@link #defaultValue(Object) default value} is + * specified instead. + * + * @see #defaultValue(Object) + */ + + ChronicleMapBuilderI defaultValueProvider( + @NotNull DefaultValueProvider defaultValueProvider); + + /** + * Configures the {@code BytesMarshaller} 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. + * + * @param valueMarshaller the marshaller used to serialize values + * @return this builder back + * @see #valueMarshallers(net.openhft.chronicle.hash.serialization.BytesWriter, + * net.openhft.chronicle.hash.serialization.BytesReader) + * @see ChronicleMapBuilder + * @see #objectSerializer(ObjectSerializer) + */ + ChronicleMapBuilderI valueMarshaller( + @NotNull BytesMarshaller valueMarshaller); + + + /** + * 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 + * net.openhft.chronicle.hash.serialization.BytesWriter} is, of cause, possible, but currently pointless + * for values. + * + * @param valueWriter the new value object → {@link net.openhft.lang.io.Bytes} writer (interop) + * strategy + * @param valueReader the new {@link net.openhft.lang.io.Bytes} → value object reader strategy + * @return this builder back + * @see #valueMarshaller(BytesMarshaller) + */ + ChronicleMapBuilderI valueMarshallers( + @NotNull BytesWriter valueWriter, @NotNull BytesReader valueReader); + + /** + * 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 + * net.openhft.chronicle.hash.serialization.SizeMarshaller} implementation, which doesn't actually do any + * marshalling, and just returns the known constant size on {@link net.openhft.chronicle.hash.serialization.SizeMarshaller#readSize( + *net.openhft.lang.io.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 + */ + ChronicleMapBuilderI valueSizeMarshaller( + @NotNull SizeMarshaller valueSizeMarshaller); + + ChronicleMapBuilderI entries(long l); + + ChronicleMapBuilderI replication(SingleChronicleHashReplication withId); + + ChronicleMap create() throws IOException; + + ChronicleMapBuilderI actualSegments(int actualSegments); + + ChronicleMapBuilderI minSegments(int minSegments); + + ChronicleMapBuilderI actualEntriesPerSegment(long actualEntriesPerSegment); + + ChronicleMapBuilderI lockTimeOut(long lockTimeOut, TimeUnit unit); + + ChronicleMapBuilderI errorListener(ChronicleHashErrorListener errorListener); + + ChronicleMapBuilderI metaDataBytes(int metaDataBytes); + + ChronicleMapBuilderI timeProvider(TimeProvider timeProvider); + + ChronicleMapBuilderI bytesMarshallerFactory(BytesMarshallerFactory bytesMarshallerFactory); + + ChronicleMapBuilderI keyMarshaller(BytesMarshaller keyMarshaller); + + ChronicleMapBuilderI keyMarshallers(BytesWriter keyWriter, BytesReader keyReader); + + ChronicleMapBuilderI keySizeMarshaller(SizeMarshaller keySizeMarshaller); + + ChronicleMapBuilderI keyDeserializationFactory(ObjectFactory keyDeserializationFactory); + + ChronicleMapBuilderI immutableKeys(); + + ChronicleMap createPersistedTo(File file) throws IOException; + + StatelessClientConfig> statelessClient(InetSocketAddress remoteAddress); + + ChronicleHashInstanceConfig> instance(); + + ChronicleMapBuilderI replication(byte identifier); + + ChronicleMapBuilderI replication(byte identifier, TcpTransportAndNetworkConfig tcpTransportAndNetwork); + + ChronicleMapBuilderI clone(); + + ChronicleMapBuilderI eventListener(MapEventListener> eventListener); + + ChronicleMapBuilderI putReturnsNull(boolean b); + + ChronicleMap createReplicated(byte b) throws IOException; + + ChronicleMapBuilderI removeReturnsNull(boolean b); + + +} diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapOnHeapUpdatableBuilder.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapOnHeapUpdatableBuilder.java deleted file mode 100644 index 8b9e98ee6..000000000 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMapOnHeapUpdatableBuilder.java +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright 2014 Higher Frequency Trading http://www.higherfrequencytrading.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.openhft.chronicle.map; - -import net.openhft.chronicle.hash.ChronicleHashBuilder; -import net.openhft.chronicle.hash.serialization.*; -import net.openhft.lang.io.Bytes; -import net.openhft.lang.io.serialization.BytesMarshallable; -import net.openhft.lang.io.serialization.BytesMarshaller; -import net.openhft.lang.io.serialization.ObjectFactory; -import net.openhft.lang.io.serialization.ObjectSerializer; -import net.openhft.lang.model.Byteable; -import org.jetbrains.annotations.NotNull; - -import java.io.Externalizable; -import java.io.Serializable; - - -/** - * {@code ChronicleMapOnHeapUpdatableBuilder} is intended to be used to configure {@link ChronicleMap}s with - * 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. - * - * @param key type of the maps, created by this builder - * @param value type of the maps, created by this builder - * @see ChronicleMapBuilder - * @see AbstractChronicleMapBuilder - * @see ChronicleHashBuilder - */ -public final class ChronicleMapOnHeapUpdatableBuilder - 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 - * the section about - * serialization in Chronicle Map manual for more information. - * - * @param keyClass class object used to infer key type and discover it's properties - * via reflection - * @param valueClass class object used to infer value type and discover it's properties - * via reflection - * @param key type of the maps, created by the returned builder - * @param value type of the maps, created by the returned builder - * @return a new builder for the given key and value classes - */ - public static ChronicleMapOnHeapUpdatableBuilder of( - @NotNull Class keyClass, @NotNull Class valueClass) { - return new ChronicleMapOnHeapUpdatableBuilder(keyClass, valueClass); - } - - ChronicleMapOnHeapUpdatableBuilder(Class keyClass, Class valueClass) { - super(keyClass, valueClass); - } - - @Override - ChronicleMapOnHeapUpdatableBuilder self() { - return this; - } - - /** - * {@inheritDoc} - * - * @see #constantKeySizeBySample(Object) - * @see #valueSize(int) - * @see #entrySize(int) - */ - @Override - public ChronicleMapOnHeapUpdatableBuilder keySize(int keySize) { - return super.keySize(keySize); - } - - /** - * {@inheritDoc} - * - * @see #keySize(int) - * @see #constantValueSizeBySample(Object) - */ - @Override - public ChronicleMapOnHeapUpdatableBuilder constantKeySizeBySample(K sampleKey) { - return super.constantKeySizeBySample(sampleKey); - } - - /** - * 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. - * - * @param valueSize number of bytes, taken by serialized form of values - * @return this {@code ChronicleMapOnHeapUpdatableBuilder} back - * @see #constantValueSizeBySample(Object) - * @see #keySize(int) - * @see #entrySize(int) - */ - @Override - public ChronicleMapOnHeapUpdatableBuilder valueSize(int valueSize) { - return super.valueSize(valueSize); - } - - /** - * 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. - * - * @param sampleValue the sample value - * @return this builder back - * @see #valueSize(int) - * @see #constantKeySizeBySample(Object) - */ - - @Override - public ChronicleMapOnHeapUpdatableBuilder constantValueSizeBySample( - @NotNull V sampleValue) { - return super.constantValueSizeBySample(sampleValue); - } - - /** - * {@inheritDoc} - * - *

Example:

{@code Map map =
-     *     ChronicleMapOnHeapUpdatableBuilder.of(Key.class, Value.class)
-     *     .entries(1_000_000)
-     *     .keySize(50).valueSize(200)
-     *     // 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 #valueMarshaller(BytesMarshaller) value} marshallers are not configured. - */ - @Override - public ChronicleMapOnHeapUpdatableBuilder objectSerializer( - @NotNull ObjectSerializer objectSerializer) { - return super.objectSerializer(objectSerializer); - } - - /** - * {@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} - */ - @Override - public ChronicleMapOnHeapUpdatableBuilder valueDeserializationFactory( - @NotNull ObjectFactory valueDeserializationFactory) { - return super.valueDeserializationFactory(valueDeserializationFactory); - } - - /** - * {@inheritDoc} - * - *

By default, the default value is set to {@code null}. - * - * @see #defaultValueProvider(DefaultValueProvider) - */ - @Override - public ChronicleMapOnHeapUpdatableBuilder defaultValue(V defaultValue) { - return super.defaultValue(defaultValue); - } - - /** - * {@inheritDoc} - * - *

By default, default value provider is not specified, {@link #defaultValue(Object) default - * value} is specified instead. - * - * @see #defaultValue(Object) - */ - @Override - public ChronicleMapOnHeapUpdatableBuilder defaultValueProvider( - @NotNull DefaultValueProvider defaultValueProvider) { - return super.defaultValueProvider(defaultValueProvider); - } - - /** - * Configures the {@code BytesMarshaller} 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. - * - * @param valueMarshaller the marshaller used to serialize values - * @return this builder back - * @see #valueMarshallers(BytesWriter, BytesReader) - * @see ChronicleMapBuilder - * @see #objectSerializer(ObjectSerializer) - */ - public ChronicleMapOnHeapUpdatableBuilder valueMarshaller( - @NotNull BytesMarshaller valueMarshaller) { - valueBuilder.marshaller(valueMarshaller); - return this; - } - - /** - * 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 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 - * @return this builder back - * @see #valueMarshaller(BytesMarshaller) - */ - public ChronicleMapOnHeapUpdatableBuilder valueMarshallers( - @NotNull BytesWriter valueWriter, @NotNull BytesReader valueReader) { - valueBuilder.writer(valueWriter); - valueBuilder.reader(valueReader); - return this; - } - - /** - * 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 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 - */ - public ChronicleMapOnHeapUpdatableBuilder valueSizeMarshaller( - @NotNull SizeMarshaller valueSizeMarshaller) { - valueBuilder.sizeMarshaller(valueSizeMarshaller); - return this; - } -} diff --git a/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java b/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java index 877b69312..be5755ed2 100644 --- a/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java +++ b/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java @@ -124,8 +124,6 @@ public class NodeDiscovery { if (proposedIdentifier == ourProposedIdentifier.get()) useAnotherIdentifier.set(true); - - } } countDownLatch.get().countDown(); @@ -231,7 +229,7 @@ public class NodeDiscovery { LOG.info("Using Remote identifier=" + identifier); nodeDiscoveryEventListenerAtomicReference.set(null); - return ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, + return ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(20000L) .replication(SingleChronicleHashReplication.builder() diff --git a/src/main/java/net/openhft/chronicle/map/OffHeapUpdatableChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/OffHeapUpdatableChronicleMapBuilder.java new file mode 100644 index 000000000..fa50e5db0 --- /dev/null +++ b/src/main/java/net/openhft/chronicle/map/OffHeapUpdatableChronicleMapBuilder.java @@ -0,0 +1,172 @@ +/* + * Copyright 2014 Higher Frequency Trading http://www.higherfrequencytrading.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.openhft.chronicle.map; + +import net.openhft.chronicle.hash.serialization.BytesReader; +import net.openhft.chronicle.hash.serialization.BytesWriter; +import net.openhft.chronicle.hash.serialization.SizeMarshaller; +import net.openhft.lang.io.serialization.BytesMarshaller; +import net.openhft.lang.model.Byteable; +import net.openhft.lang.model.DataValueClasses; +import org.jetbrains.annotations.NotNull; + +final class OffHeapUpdatableChronicleMapBuilder + extends AbstractChronicleMapBuilder> implements ChronicleMapBuilderI { + + public static ChronicleMapBuilderI of( + @NotNull Class keyClass, @NotNull Class valueClass) { + + if (valueClass.isEnum()) + return OnHeapUpdatableChronicleMapBuilder.of(keyClass, valueClass); + + if (keyClass.isInterface() && keyClass != CharSequence.class) { + keyClass = DataValueClasses.directClassFor(keyClass); + } + + if ((valueClass.isInterface() && valueClass != CharSequence.class)) { + valueClass = DataValueClasses.directClassFor(valueClass); + } else if (!offHeapReference(valueClass)) { + return OnHeapUpdatableChronicleMapBuilder.of(keyClass, valueClass); + } + return new OffHeapUpdatableChronicleMapBuilder(keyClass, valueClass); + } + + OffHeapUpdatableChronicleMapBuilder(Class keyClass, Class valueClass) { + super(keyClass, valueClass); + prepareValueBytesOnAcquire(new ZeroOutValueBytes(valueSize())); + } + + @Override + OffHeapUpdatableChronicleMapBuilder self() { + return this; + } + + @Override + public OffHeapUpdatableChronicleMapBuilder valueSize(int valueSize) { + throw new UnsupportedOperationException(); + } + + /** + * {@inheritDoc} With respect to {@linkplain #entryAndValueAlignment(Alignment) alignment}. + * + *

Note that the actual entrySize will be aligned to 4 (default {@linkplain + * #entryAndValueAlignment(Alignment) entry alignment}). I. e. if you set entry size to 30, and entry + * alignment is set to {@link Alignment#OF_4_BYTES}, the actual entry size will be 32 (30 aligned to 4 + * bytes). + * + * @see #entryAndValueAlignment(Alignment) + * @see #entries(long) + */ + @Override + public OffHeapUpdatableChronicleMapBuilder entrySize(int entrySize) { + return super.entrySize(entrySize); + } + + /** + * Configures alignment strategy of address in memory of entries and independently of address in memory of + * values within entries in ChronicleMaps, created by this builder. + * + *

Useful when values of the map are updated intensively, particularly fields with volatile access, + * because it doesn't work well if the value crosses cache lines. Also, on some (nowadays rare) + * architectures any misaligned memory access is more expensive than aligned. + * + *

Note that {@linkplain #entrySize(int) entry size} will be aligned according to this alignment. I. e. + * if you set {@code entrySize(20)} and {@link Alignment#OF_8_BYTES}, actual entry size will be 24 (20 + * aligned to 8 bytes). + * + *

Default is {@link Alignment#OF_4_BYTES} for Byteable values. + * + * @param alignment the new alignment of the maps constructed by this builder + * @return this {@code ChronicleMapOnHeapUpdatableBuilder} back + */ + @Override + public OffHeapUpdatableChronicleMapBuilder entryAndValueAlignment(Alignment alignment) { + return super.entryAndValueAlignment(alignment); + } + + /** + * {@inheritDoc} Also, it overrides any previous {@link #prepareValueBytesOnAcquire} configuration to this + * {@code ChronicleMapBuilder}. + * + *

By default, the default value is not specified, default {@linkplain #prepareValueBytesOnAcquire + * prepare value bytes routine} is specified instead. + * + * @see #defaultValueProvider(DefaultValueProvider) + * @see #prepareValueBytesOnAcquire(PrepareValueBytes) + */ + @Override + public OffHeapUpdatableChronicleMapBuilder defaultValue(V defaultValue) { + return super.defaultValue(defaultValue); + } + + /** + * {@inheritDoc} Also, it overrides any previous {@link #prepareValueBytesOnAcquire} configuration to this + * {@code ChronicleMapBuilder}. + * + *

By default, the default value provider is not specified, default {@linkplain + * #prepareValueBytesOnAcquire prepare value bytes routine} is specified instead. + * + * @see #defaultValue(Object) + * @see #prepareValueBytesOnAcquire(PrepareValueBytes) + */ + @Override + public OffHeapUpdatableChronicleMapBuilder defaultValueProvider( + @NotNull DefaultValueProvider defaultValueProvider) { + return super.defaultValueProvider(defaultValueProvider); + } + + /** + * 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. + * + * @param prepareValueBytes what to do with the value bytes before assigning them into the {@link + * Byteable} value to return from {@code acquireUsing()} call + * @return this builder back + * @see PrepareValueBytes + * @see #defaultValue(Object) + * @see #defaultValueProvider(DefaultValueProvider) + */ + @Override + public OffHeapUpdatableChronicleMapBuilder prepareValueBytesOnAcquire( + @NotNull PrepareValueBytes prepareValueBytes) { + return super.prepareValueBytesOnAcquire(prepareValueBytes); + } + + public ChronicleMapBuilderI valueMarshaller(@NotNull BytesMarshaller valueMarshaller) { + throw new UnsupportedOperationException("not supported for this combination of key/value type"); + } + + + public ChronicleMapBuilderI valueMarshallers(@NotNull BytesWriter valueWriter, @NotNull BytesReader valueReader) { + throw new UnsupportedOperationException("not supported for this combination of key/value type"); + } + + + public ChronicleMapBuilderI valueSizeMarshaller(@NotNull SizeMarshaller valueSizeMarshaller) { + throw new UnsupportedOperationException("not supported for this combination of key/value type"); + } + + @Override + public OffHeapUpdatableChronicleMapBuilder constantValueSizeBySample(V sampleValue) { + throw new UnsupportedOperationException("not supported for this combination of key/value type"); + } + + +} diff --git a/src/main/java/net/openhft/chronicle/map/OnHeapUpdatableChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/OnHeapUpdatableChronicleMapBuilder.java new file mode 100644 index 000000000..485099233 --- /dev/null +++ b/src/main/java/net/openhft/chronicle/map/OnHeapUpdatableChronicleMapBuilder.java @@ -0,0 +1,311 @@ +/* + * Copyright 2014 Higher Frequency Trading http://www.higherfrequencytrading.com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.openhft.chronicle.map; + +import net.openhft.chronicle.hash.ChronicleHashBuilder; +import net.openhft.chronicle.hash.serialization.BytesReader; +import net.openhft.chronicle.hash.serialization.BytesWriter; +import net.openhft.chronicle.hash.serialization.SizeMarshaller; +import net.openhft.lang.io.Bytes; +import net.openhft.lang.io.serialization.BytesMarshallable; +import net.openhft.lang.io.serialization.BytesMarshaller; +import net.openhft.lang.io.serialization.ObjectFactory; +import net.openhft.lang.io.serialization.ObjectSerializer; +import net.openhft.lang.model.Byteable; +import org.jetbrains.annotations.NotNull; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.Serializable; + + +/** + * {@code ChronicleMapOnHeapUpdatableBuilder} is intended to be used to configure {@link ChronicleMap}s with + * 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. + * + * @param key type of the maps, created by this builder + * @param value type of the maps, created by this builder + * @see ChronicleMapBuilder + * @see AbstractChronicleMapBuilder + * @see ChronicleHashBuilder + */ +final class OnHeapUpdatableChronicleMapBuilder + extends AbstractChronicleMapBuilder> implements + ChronicleMapBuilderI { + + /** + * 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 the section about serialization in + * Chronicle Map manual for more information. + * + * @param keyClass class object used to infer key type and discover it's properties via reflection + * @param valueClass class object used to infer value type and discover it's properties via reflection + * @param key type of the maps, created by the returned builder + * @param value type of the maps, created by the returned builder + * @return a new builder for the given key and value classes + */ + public static ChronicleMapBuilderI of( + @NotNull Class keyClass, @NotNull Class valueClass) { + return new OnHeapUpdatableChronicleMapBuilder(keyClass, valueClass); + } + + OnHeapUpdatableChronicleMapBuilder(Class keyClass, Class valueClass) { + super(keyClass, valueClass); + } + + @Override + OnHeapUpdatableChronicleMapBuilder self() { + return this; + } + + public ChronicleMap create() throws IOException { + return super.create(); + } + + /** + * {@inheritDoc} + * + * @see #constantKeySizeBySample(Object) + * @see #valueSize(int) + * @see #entrySize(int) + */ + @Override + public OnHeapUpdatableChronicleMapBuilder keySize(int keySize) { + return super.keySize(keySize); + } + + /** + * {@inheritDoc} + * + * @see #keySize(int) + * @see #constantValueSizeBySample(Object) + */ + @Override + public OnHeapUpdatableChronicleMapBuilder constantKeySizeBySample(K sampleKey) { + return super.constantKeySizeBySample(sampleKey); + } + + /** + * 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. + * + * @param valueSize number of bytes, taken by serialized form of values + * @return this {@code ChronicleMapOnHeapUpdatableBuilder} back + * @see #constantValueSizeBySample(Object) + * @see #keySize(int) + * @see #entrySize(int) + */ + @Override + public OnHeapUpdatableChronicleMapBuilder valueSize(int valueSize) { + return super.valueSize(valueSize); + } + + /** + * 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. + * + * @param sampleValue the sample value + * @return this builder back + * @see #valueSize(int) + * @see #constantKeySizeBySample(Object) + */ + + @Override + public OnHeapUpdatableChronicleMapBuilder constantValueSizeBySample( + @NotNull V sampleValue) { + return super.constantValueSizeBySample(sampleValue); + } + + /** + * {@inheritDoc} + * + *

Example:

{@code Map map =
+     *     ChronicleMapBuilder.of(Key.class, Value.class)
+     *     .entries(1_000_000)
+     *     .keySize(50).valueSize(200)
+     *     // 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 + * #valueMarshaller(BytesMarshaller) value} marshallers are not configured. + */ + @Override + public OnHeapUpdatableChronicleMapBuilder objectSerializer( + @NotNull ObjectSerializer objectSerializer) { + return super.objectSerializer(objectSerializer); + } + + /** + * {@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} + */ + @Override + public OnHeapUpdatableChronicleMapBuilder valueDeserializationFactory( + @NotNull ObjectFactory valueDeserializationFactory) { + return super.valueDeserializationFactory(valueDeserializationFactory); + } + + /** + * {@inheritDoc} + * + *

By default, the default value is set to {@code null}. + * + * @see #defaultValueProvider(DefaultValueProvider) + */ + @Override + public OnHeapUpdatableChronicleMapBuilder defaultValue(V defaultValue) { + return super.defaultValue(defaultValue); + } + + /** + * {@inheritDoc} + * + *

By default, default value provider is not specified, {@link #defaultValue(Object) default value} is + * specified instead. + * + * @see #defaultValue(Object) + */ + @Override + public OnHeapUpdatableChronicleMapBuilder defaultValueProvider( + @NotNull DefaultValueProvider defaultValueProvider) { + return super.defaultValueProvider(defaultValueProvider); + } + + /** + * Configures the {@code BytesMarshaller} 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. + * + * @param valueMarshaller the marshaller used to serialize values + * @return this builder back + * @see #valueMarshallers(BytesWriter, BytesReader) + * @see ChronicleMapBuilder + * @see #objectSerializer(ObjectSerializer) + */ + public OnHeapUpdatableChronicleMapBuilder valueMarshaller( + @NotNull BytesMarshaller valueMarshaller) { + valueBuilder.marshaller(valueMarshaller); + return this; + } + + /** + * 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. + * + * @param valueWriter the new value object → {@link Bytes} writer (interop) strategy + * @param valueReader the new {@link Bytes} → value object reader strategy + * @return this builder back + * @see #valueMarshaller(BytesMarshaller) + */ + public OnHeapUpdatableChronicleMapBuilder valueMarshallers( + @NotNull BytesWriter valueWriter, @NotNull BytesReader valueReader) { + valueBuilder.writer(valueWriter); + valueBuilder.reader(valueReader); + return this; + } + + /** + * 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. + * + * @param valueSizeMarshaller the new marshaller, used to serialize actual value sizes to off-heap memory + * @return this builder back + */ + public OnHeapUpdatableChronicleMapBuilder valueSizeMarshaller( + @NotNull SizeMarshaller valueSizeMarshaller) { + valueBuilder.sizeMarshaller(valueSizeMarshaller); + return this; + } + + /** + * 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. + * + * @param prepareValueBytes what to do with the value bytes before assigning them into the {@link + * Byteable} value to return from {@code acquireUsing()} call + * @return this builder back + * @see PrepareValueBytes + * @see #defaultValue(Object) + * @see #defaultValueProvider(DefaultValueProvider) + */ + @Override + public OnHeapUpdatableChronicleMapBuilder prepareValueBytesOnAcquire( + @NotNull PrepareValueBytes prepareValueBytes) { + throw new UnsupportedOperationException("not supported for this combination of key/value type"); + } + + + public OnHeapUpdatableChronicleMapBuilder entryAndValueAlignment(Alignment a) { + throw new UnsupportedOperationException("not supported for this combination of key/value type"); + } + + +} diff --git a/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java b/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java index 667d0a6ae..1c1303cac 100644 --- a/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/StatelessChronicleMap.java @@ -138,7 +138,7 @@ class StatelessChronicleMap implements ChronicleMap, Closeable { result = AbstractChannelReplicator.openSocketChannel(closeables); result.connect(builder.remoteAddress()); result.socket().setTcpNoDelay(true); - result.socket().setReuseAddress(true); + doHandShaking(result); break; @@ -240,6 +240,11 @@ class StatelessChronicleMap implements ChronicleMap, Closeable { if (closeables != null) closeables.closeQuietly(); closeables = null; + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // + } } diff --git a/src/main/java/net/openhft/chronicle/set/ChronicleSetBuilder.java b/src/main/java/net/openhft/chronicle/set/ChronicleSetBuilder.java index a31e08960..afd9b463f 100644 --- a/src/main/java/net/openhft/chronicle/set/ChronicleSetBuilder.java +++ b/src/main/java/net/openhft/chronicle/set/ChronicleSetBuilder.java @@ -29,7 +29,7 @@ import net.openhft.chronicle.hash.serialization.BytesReader; import net.openhft.chronicle.hash.serialization.BytesWriter; import net.openhft.chronicle.hash.serialization.SizeMarshaller; import net.openhft.chronicle.map.ChronicleMap; -import net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder; +import net.openhft.chronicle.map.ChronicleMapBuilder; import net.openhft.lang.io.serialization.BytesMarshaller; import net.openhft.lang.io.serialization.BytesMarshallerFactory; import net.openhft.lang.io.serialization.ObjectFactory; @@ -55,10 +55,10 @@ import java.util.concurrent.TimeUnit; public class ChronicleSetBuilder implements ChronicleHashBuilder, ChronicleSetBuilder> { - private ChronicleMapOnHeapUpdatableBuilder chronicleMapBuilderOnHeap; + private ChronicleMapBuilder chronicleMapBuilderOnHeap; ChronicleSetBuilder(Class keyClass) { - chronicleMapBuilderOnHeap = ChronicleMapOnHeapUpdatableBuilder.of(keyClass, DummyValue.class) + chronicleMapBuilderOnHeap = ChronicleMapBuilder.of(keyClass, DummyValue.class) .valueMarshallers(DummyValueMarshaller.INSTANCE, DummyValueMarshaller.INSTANCE) .valueSizeMarshaller(DummyValueMarshaller.INSTANCE); } diff --git a/src/main/java/net/openhft/chronicle/set/DummyValue.java b/src/main/java/net/openhft/chronicle/set/DummyValue.java index 5145f9239..a7e4fb305 100644 --- a/src/main/java/net/openhft/chronicle/set/DummyValue.java +++ b/src/main/java/net/openhft/chronicle/set/DummyValue.java @@ -18,6 +18,6 @@ package net.openhft.chronicle.set; -enum DummyValue { + enum DummyValue { DUMMY_VALUE } diff --git a/src/test/java/eg/BigData.java b/src/test/java/eg/BigData.java index 90588218e..8c8fe917f 100644 --- a/src/test/java/eg/BigData.java +++ b/src/test/java/eg/BigData.java @@ -19,7 +19,8 @@ package eg; import net.openhft.affinity.AffinitySupport; -import net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder; +import net.openhft.chronicle.map.ChronicleMapBuilder; +import net.openhft.chronicle.map.ChronicleMapBuilder; import net.openhft.lang.io.Bytes; import java.io.*; @@ -40,8 +41,8 @@ public class BigData { //run 1st test with no map, and Highwatermark set to 0 //then switch to Highwatermark set to MAXSIZE for subsequent test repeats static AtomicInteger Highwatermark = new AtomicInteger((int) MAXSIZE); - static final ChronicleMapOnHeapUpdatableBuilder builder = - ChronicleMapOnHeapUpdatableBuilder.of(Long.class, BigDataStuff.class); + static final ChronicleMapBuilder builder = + ChronicleMapBuilder.of(Long.class, BigDataStuff.class); // static AtomicInteger Highwatermark = new AtomicInteger(0); static { diff --git a/src/test/java/net/openhft/chronicle/map/Builder.java b/src/test/java/net/openhft/chronicle/map/Builder.java index c64ec78bc..dd0773d38 100644 --- a/src/test/java/net/openhft/chronicle/map/Builder.java +++ b/src/test/java/net/openhft/chronicle/map/Builder.java @@ -67,17 +67,16 @@ public class Builder { identifier, serverPort, endpoints).create(); } - public static ChronicleMapOnHeapUpdatableBuilder newTcpSocketShmBuilder( + public static ChronicleMapBuilder newTcpSocketShmBuilder( Class kClass, Class vClass, final byte identifier, final int serverPort, final InetSocketAddress... endpoints) throws IOException { TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(serverPort, Arrays.asList(endpoints)) .heartBeatInterval(1L, TimeUnit.SECONDS); - return ChronicleMapOnHeapUpdatableBuilder.of(kClass, vClass) - .replication(identifier, tcpConfig); + return ChronicleMapBuilder.of(kClass, vClass) + .replication(identifier, tcpConfig); } - } diff --git a/src/test/java/net/openhft/chronicle/map/CHMMetaDataTest.java b/src/test/java/net/openhft/chronicle/map/CHMMetaDataTest.java index 79706aa7d..65f699a45 100644 --- a/src/test/java/net/openhft/chronicle/map/CHMMetaDataTest.java +++ b/src/test/java/net/openhft/chronicle/map/CHMMetaDataTest.java @@ -35,7 +35,7 @@ public class CHMMetaDataTest { File file = new File(TMP, "testAccessTimes"); MapEventListener> listener = new StringStringMapEventListener(new AtomicLong(1)); - ChronicleMap map = ChronicleMapOnHeapUpdatableBuilder.of(String.class, String.class) + ChronicleMap map = ChronicleMapBuilder.of(String.class, String.class) .metaDataBytes(8) .eventListener(listener).create(); diff --git a/src/test/java/net/openhft/chronicle/map/CHMTest5.java b/src/test/java/net/openhft/chronicle/map/CHMTest5.java index 046e30845..b6fd2b907 100644 --- a/src/test/java/net/openhft/chronicle/map/CHMTest5.java +++ b/src/test/java/net/openhft/chronicle/map/CHMTest5.java @@ -39,7 +39,7 @@ public class CHMTest5 { .entries(1000); //// don't include this, just to check it is as expected. - assertEquals(8, builder.minSegments()); + assertEquals(8, ((AbstractChronicleMapBuilder) builder.delegate).minSegments()); //// end of test String chmPath = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + "CHMTest5"; diff --git a/src/test/java/net/openhft/chronicle/map/CHMTestIterator1.java b/src/test/java/net/openhft/chronicle/map/CHMTestIterator1.java index b2baa5de7..e4b9c1e56 100644 --- a/src/test/java/net/openhft/chronicle/map/CHMTestIterator1.java +++ b/src/test/java/net/openhft/chronicle/map/CHMTestIterator1.java @@ -30,7 +30,7 @@ public class CHMTestIterator1 { AtomicLong alValue = new AtomicLong(); AtomicLong alKey = new AtomicLong(); int runs = 3000000; - ChronicleMapOnHeapUpdatableBuilder builder = ChronicleMapOnHeapUpdatableBuilder.of(String.class, Long.class) + ChronicleMapBuilder builder = ChronicleMapBuilder.of(String.class, Long.class) .entries(runs); ChronicleMap chm = builder.create(); diff --git a/src/test/java/net/openhft/chronicle/map/ChannelReplicationTest.java b/src/test/java/net/openhft/chronicle/map/ChannelReplicationTest.java index 2fdaafe2d..717e943d4 100644 --- a/src/test/java/net/openhft/chronicle/map/ChannelReplicationTest.java +++ b/src/test/java/net/openhft/chronicle/map/ChannelReplicationTest.java @@ -61,7 +61,7 @@ public class ChannelReplicationTest { .tcpTransportAndNetwork(tcpConfig) .createWithId((byte) 1); - map1a = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + map1a = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(1000) .instance().replicatedViaChannel(hubA.createChannel((short) 1)).create(); } @@ -73,7 +73,7 @@ public class ChannelReplicationTest { hubB = ReplicationHub.builder().tcpTransportAndNetwork(tcpConfig) .createWithId((byte) 2); - map1b = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + map1b = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(1000) .instance().replicatedViaChannel(hubB.createChannel((short) 1)).create(); } @@ -95,12 +95,12 @@ public class ChannelReplicationTest { @Test public void test() throws IOException, InterruptedException { - map2b = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + map2b = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(1000) .instance().replicatedViaChannel(hubB.createChannel((short) 2)).create(); - map2a = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + map2a = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(1000) .instance().replicatedViaChannel(hubA.createChannel((short) 2)).create(); diff --git a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java index 4bec46de5..e3bb59119 100755 --- a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java @@ -136,7 +136,7 @@ public class ChronicleMapTest { public void testRemoveWithKey() throws Exception { final ChronicleMap map = - ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .minSegments(2).create(); assertFalse(map.containsKey("key3")); @@ -181,7 +181,7 @@ public class ChronicleMapTest { public void testSize() throws Exception { final ChronicleMap map = - ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .minSegments(1024) .removeReturnsNull(true).create(); @@ -203,7 +203,7 @@ public class ChronicleMapTest { public void testRemoveInteger() throws IOException { int count = 300; - final ChronicleMap map = ChronicleMapOnHeapUpdatableBuilder.of(Object.class, Object.class) + final ChronicleMap map = ChronicleMapBuilder.of(Object.class, Object.class) .entrySize(count) .minSegments(2).create(); @@ -228,7 +228,7 @@ public class ChronicleMapTest { public void testRemoveWithKeyAndRemoveReturnsNull() throws Exception { final ChronicleMap map = - ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .minSegments(2) .removeReturnsNull(true).create(); @@ -274,7 +274,7 @@ public class ChronicleMapTest { public void testReplaceWithKey() throws Exception { final ChronicleMap map = - ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .minSegments(2).create(); @@ -339,7 +339,7 @@ public class ChronicleMapTest { public void testReplaceWithKeyAnd2Params() throws Exception { final ChronicleMap map = - ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .minSegments(2).create(); map.put("key1", "one"); @@ -381,7 +381,7 @@ public class ChronicleMapTest { public void testRemoveWithKeyAndValue() throws Exception { final ChronicleMap map = - ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .minSegments(2).create(); @@ -855,7 +855,7 @@ public class ChronicleMapTest { String TMP = System.getProperty("java.io.tmpdir"); int entries = 100 * 1000; ChronicleMap map = - ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(entries) .minSegments(16) .entrySize(32) @@ -1284,7 +1284,7 @@ public class ChronicleMapTest { private ChronicleMap getViewTestMap(int noOfElements) throws IOException { ChronicleMap map = - ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(noOfElements * 2 + 100) .valueSize((noOfElements + "").length()) .putReturnsNull(true) @@ -1304,7 +1304,7 @@ public class ChronicleMapTest { @Test public void testOversizeEntriesPutRemoveReplace() throws IOException { - ChronicleMapOnHeapUpdatableBuilder builder = ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMapBuilder builder = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .minSegments(1) .entrySize(10); @@ -1356,13 +1356,13 @@ public class ChronicleMapTest { @Test public void equalsTest() throws IOException { - final ChronicleMap map1 = ChronicleMapOnHeapUpdatableBuilder + final ChronicleMap map1 = OnHeapUpdatableChronicleMapBuilder .of(Integer.class, String.class).create(); map1.put(1, "one"); map1.put(2, "two"); - final ChronicleMap map2 = ChronicleMapOnHeapUpdatableBuilder + final ChronicleMap map2 = OnHeapUpdatableChronicleMapBuilder .of(Integer.class, String.class).create(); map2.put(1, "one"); @@ -1469,7 +1469,7 @@ public class ChronicleMapTest { @Test(expected = IllegalArgumentException.class) public void testAcquireUsingLockedWithString() throws IOException { - ChronicleMapOnHeapUpdatableBuilder builder = ChronicleMapOnHeapUpdatableBuilder + ChronicleMapBuilder builder = ChronicleMapBuilder .of(CharSequence.class, String.class) .entries(1000) .defaultValue("") @@ -1494,7 +1494,7 @@ public class ChronicleMapTest { @Test public void testOnheapAcquireUsingLockedStringBuilder() throws IOException { - try (final ChronicleMap map = ChronicleMapOnHeapUpdatableBuilder + try (final ChronicleMap map = ChronicleMapBuilder .of(CharSequence.class, CharSequence.class) .entries(1000) .entrySize(40) @@ -1514,7 +1514,7 @@ public class ChronicleMapTest { @Test public void testOnheapAcquireUsingLocked() throws IOException { - ChronicleMapOnHeapUpdatableBuilder builder = ChronicleMapOnHeapUpdatableBuilder + ChronicleMapBuilder builder = ChronicleMapBuilder .of(CharSequence.class, LongValue.class) .entries(1000) .entrySize(40); diff --git a/src/test/java/net/openhft/chronicle/map/ConcurrentMap8Test.java b/src/test/java/net/openhft/chronicle/map/ConcurrentMap8Test.java index 2dd42a58a..3c1b31f1e 100644 --- a/src/test/java/net/openhft/chronicle/map/ConcurrentMap8Test.java +++ b/src/test/java/net/openhft/chronicle/map/ConcurrentMap8Test.java @@ -42,7 +42,7 @@ public class ConcurrentMap8Test extends JSR166TestCase { /* private static ConcurrentMap newLongMap() { //First create (or access if already created) the shared map - final ChronicleMapOnHeapUpdatableBuilder builder = ChronicleMapOnHeapUpdatableBuilder.of(Long.class, Long.class); + final ChronicleMapOnHeapUpdatableBuilder builder = ChronicleMapBuilder.of(Long.class, Long.class); //// don't include this, just to check it is as expected. @@ -64,7 +64,7 @@ public class ConcurrentMap8Test extends JSR166TestCase { private static ConcurrentMap newIntegerStringMap() { - final ChronicleMapOnHeapUpdatableBuilder builder = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, + final ChronicleMapOnHeapUpdatableBuilder builder = ChronicleMapBuilder.of(Integer.class, String.class); diff --git a/src/test/java/net/openhft/chronicle/map/ConstantSizeBySampleTest.java b/src/test/java/net/openhft/chronicle/map/ConstantSizeBySampleTest.java index 57b010cb9..78ab35c73 100644 --- a/src/test/java/net/openhft/chronicle/map/ConstantSizeBySampleTest.java +++ b/src/test/java/net/openhft/chronicle/map/ConstantSizeBySampleTest.java @@ -32,7 +32,7 @@ public class ConstantSizeBySampleTest { @Test public void testConstantKeys() throws IOException { - ChronicleMap map = ChronicleMapOnHeapUpdatableBuilder.of(byte[].class, Long.class) + ChronicleMap map = ChronicleMapBuilder.of(byte[].class, Long.class) .constantKeySizeBySample(new byte[8]) .immutableKeys() .entries(100) @@ -52,7 +52,7 @@ public class ConstantSizeBySampleTest { @Test public void testUnexpectedlyLongConstantByteArrayValues() throws IOException { - ChronicleMap map = ChronicleMapOnHeapUpdatableBuilder.of(Long.class, byte[].class) + ChronicleMap map = ChronicleMapBuilder.of(Long.class, byte[].class) .constantValueSizeBySample(new byte[512 * 1024]) .entries(100) .actualSegments(1) @@ -89,7 +89,7 @@ public class ConstantSizeBySampleTest { @Test public void testUnexpectedlyLongConstantExternalizableValues() throws IOException { ChronicleMap map = - ChronicleMapOnHeapUpdatableBuilder.of(Long.class, ExternalizableData.class) + ChronicleMapBuilder.of(Long.class, ExternalizableData.class) .constantValueSizeBySample(new ExternalizableData()) .entries(100) .actualSegments(1) @@ -116,7 +116,7 @@ public class ConstantSizeBySampleTest { @Ignore public void testUnexpectedlyLongConstantSerializableValues() throws IOException { ChronicleMap map = - ChronicleMapOnHeapUpdatableBuilder.of(Long.class, SerializableData.class) + ChronicleMapBuilder.of(Long.class, SerializableData.class) .constantValueSizeBySample(new SerializableData()) .entries(100) .actualSegments(1) diff --git a/src/test/java/net/openhft/chronicle/map/DefaultValueTest.java b/src/test/java/net/openhft/chronicle/map/DefaultValueTest.java index 4c09bd6f8..d0b773361 100644 --- a/src/test/java/net/openhft/chronicle/map/DefaultValueTest.java +++ b/src/test/java/net/openhft/chronicle/map/DefaultValueTest.java @@ -37,7 +37,7 @@ public class DefaultValueTest { ArrayList defaultValue = new ArrayList(); defaultValue.add(42); - try (ChronicleMap> map = ChronicleMapOnHeapUpdatableBuilder + try (ChronicleMap> map = OnHeapUpdatableChronicleMapBuilder .of(String.class, (Class>) ((Class) List.class)) .defaultValue(defaultValue).createPersistedTo(file)) { ArrayList using = new ArrayList(); @@ -49,7 +49,7 @@ public class DefaultValueTest { } ArrayList using = new ArrayList(); - try (ChronicleMap> map = ChronicleMapOnHeapUpdatableBuilder + try (ChronicleMap> map = OnHeapUpdatableChronicleMapBuilder .of(String.class, (Class>) ((Class) List.class)) .createPersistedTo(file)) { assertEquals(defaultValue, map.acquireUsing("c", using)); diff --git a/src/test/java/net/openhft/chronicle/map/EntryCountMapTest.java b/src/test/java/net/openhft/chronicle/map/EntryCountMapTest.java index cc3de97c9..f98d29ee3 100644 --- a/src/test/java/net/openhft/chronicle/map/EntryCountMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/EntryCountMapTest.java @@ -51,7 +51,8 @@ public class EntryCountMapTest { private static ChronicleMap getSharedMap( long entries, int segments, int entrySize, Alignment alignment) throws IOException { - ChronicleMapBuilder mapBuilder = ChronicleMapBuilder.of(CharSequence.class, LongValue.class) + ChronicleMapBuilder mapBuilder = ChronicleMapBuilder.of(CharSequence + .class, LongValue.class) .entries(entries) .actualSegments(segments) .entrySize(entrySize) diff --git a/src/test/java/net/openhft/chronicle/map/EventListenerTestWithTCPSocketReplication.java b/src/test/java/net/openhft/chronicle/map/EventListenerTestWithTCPSocketReplication.java index f7ecadd8f..49beb7104 100644 --- a/src/test/java/net/openhft/chronicle/map/EventListenerTestWithTCPSocketReplication.java +++ b/src/test/java/net/openhft/chronicle/map/EventListenerTestWithTCPSocketReplication.java @@ -99,14 +99,14 @@ public class EventListenerTestWithTCPSocketReplication { // we connect the maps via a TCP socket connection on port 8077 - ChronicleMapOnHeapUpdatableBuilder map1Builder = serverBuilder(); + ChronicleMapBuilder map1Builder = serverBuilder(); map1 = map1Builder.create(); } // ---------- SERVER2 2 on the same server as ---------- { - ChronicleMapOnHeapUpdatableBuilder map2Builder = clientBuilder(); + ChronicleMapBuilder map2Builder = clientBuilder(); map2 = map2Builder.create(); } @@ -135,7 +135,7 @@ public class EventListenerTestWithTCPSocketReplication { // we connect the maps via a TCP socket connection on port 8077 - ChronicleMapOnHeapUpdatableBuilder map1Builder = serverBuilder(); + ChronicleMapBuilder map1Builder = serverBuilder(); map1 = map1Builder.create(); @@ -206,7 +206,7 @@ public class EventListenerTestWithTCPSocketReplication { // we connect the maps via a TCP socket connection on port 8077 - ChronicleMapOnHeapUpdatableBuilder map1Builder = serverBuilder(); + ChronicleMapBuilder map1Builder = serverBuilder(); map1 = map1Builder.create(); @@ -237,9 +237,9 @@ public class EventListenerTestWithTCPSocketReplication { Assert.assertEquals(null, map2.get(5)); } - private ChronicleMapOnHeapUpdatableBuilder clientBuilder() { + private ChronicleMapBuilder clientBuilder() { TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(8077); - return ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + return ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(20000L) .replication((byte) 1, tcpConfig) .eventListener(eventListener); @@ -256,9 +256,9 @@ public class EventListenerTestWithTCPSocketReplication { } } - private ChronicleMapOnHeapUpdatableBuilder serverBuilder() { + private ChronicleMapBuilder serverBuilder() { TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(8076, new InetSocketAddress("localhost", 8077)); - return ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + return ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(20000L) .replication((byte) 2, tcpConfig); } diff --git a/src/test/java/net/openhft/chronicle/map/GuavaTest.java b/src/test/java/net/openhft/chronicle/map/GuavaTest.java index d08560df9..4c096767d 100644 --- a/src/test/java/net/openhft/chronicle/map/GuavaTest.java +++ b/src/test/java/net/openhft/chronicle/map/GuavaTest.java @@ -99,8 +99,8 @@ public class GuavaTest extends TestCase { } static class CHMTestGenerator extends TestGenerator { - ChronicleMapOnHeapUpdatableBuilder builder = - ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMapBuilder builder = + ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(100) .minSegments(2); diff --git a/src/test/java/net/openhft/chronicle/map/IntValueMapTest.java b/src/test/java/net/openhft/chronicle/map/IntValueMapTest.java index 37378ba50..597bb622e 100644 --- a/src/test/java/net/openhft/chronicle/map/IntValueMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/IntValueMapTest.java @@ -37,7 +37,7 @@ public class IntValueMapTest { @Test public void test() throws IOException { - final ChronicleMap map = ChronicleMapOnHeapUpdatableBuilder + final ChronicleMap map = OnHeapUpdatableChronicleMapBuilder .of(IntValue.class, CharSequence.class) .entries(20000) .keyMarshaller(ByteableIntValueMarshaller.INSTANCE).create(); diff --git a/src/test/java/net/openhft/chronicle/map/Issue42Test.java b/src/test/java/net/openhft/chronicle/map/Issue42Test.java index 13bd20459..4b1681623 100755 --- a/src/test/java/net/openhft/chronicle/map/Issue42Test.java +++ b/src/test/java/net/openhft/chronicle/map/Issue42Test.java @@ -32,7 +32,7 @@ public class Issue42Test { if (!Jvm.isWindows()) return; - final ChronicleMap map = ChronicleMapOnHeapUpdatableBuilder + final ChronicleMap map = OnHeapUpdatableChronicleMapBuilder .of(CharSequence.class, CharSequence.class) .entrySize(18) .entries(1500000) diff --git a/src/test/java/net/openhft/chronicle/map/KeySizesTest.java b/src/test/java/net/openhft/chronicle/map/KeySizesTest.java index d2a436054..b9af5ffc1 100644 --- a/src/test/java/net/openhft/chronicle/map/KeySizesTest.java +++ b/src/test/java/net/openhft/chronicle/map/KeySizesTest.java @@ -33,7 +33,7 @@ public class KeySizesTest { @Test public void testDifferentKeySizes() throws IOException { - Map map = ChronicleMapOnHeapUpdatableBuilder.of(String.class, String.class).create(); + Map map = ChronicleMapBuilder.of(String.class, String.class).create(); String k = ""; for (int i = 0; i < 100; i++) { diff --git a/src/test/java/net/openhft/chronicle/map/OSResizesMain.java b/src/test/java/net/openhft/chronicle/map/OSResizesMain.java index c09a5ecc3..cc1af2ad4 100755 --- a/src/test/java/net/openhft/chronicle/map/OSResizesMain.java +++ b/src/test/java/net/openhft/chronicle/map/OSResizesMain.java @@ -35,7 +35,7 @@ import java.util.Arrays; public class OSResizesMain { public static void main(String[] args) throws IOException, InterruptedException { File file = File.createTempFile("over-sized", "deleteme"); - ChronicleMap map = ChronicleMapOnHeapUpdatableBuilder.of(String.class, String.class) + ChronicleMap map = ChronicleMapBuilder.of(String.class, String.class) .entrySize(100 * 1024 * 1024) .entries(1000 * 1000) .createPersistedTo(file); diff --git a/src/test/java/net/openhft/chronicle/map/PostChannelCreationTest.java b/src/test/java/net/openhft/chronicle/map/PostChannelCreationTest.java index 93bd564e9..a7db4b5fc 100644 --- a/src/test/java/net/openhft/chronicle/map/PostChannelCreationTest.java +++ b/src/test/java/net/openhft/chronicle/map/PostChannelCreationTest.java @@ -70,11 +70,11 @@ public class PostChannelCreationTest { .createWithId((byte) 1); // this is how you add maps after the custer is created - map1a = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + map1a = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(1000) .instance().replicatedViaChannel(hubA.createChannel((short) 1)).create(); - map2a = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + map2a = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(1000) .instance().replicatedViaChannel(hubA.createChannel((short) 2)).create(); } @@ -89,11 +89,11 @@ public class PostChannelCreationTest { .createWithId((byte) 2); // this is how you add maps after the custer is created - map1b = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + map1b = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(1000) .instance().replicatedViaChannel(hubB.createChannel((short) 1)).create(); - map2b = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + map2b = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(1000) .instance().replicatedViaChannel(hubB.createChannel((short) 2)).create(); } diff --git a/src/test/java/net/openhft/chronicle/map/ProcessInstanceLimiterMain.java b/src/test/java/net/openhft/chronicle/map/ProcessInstanceLimiterMain.java index dd2dcf80f..5bea1f6ae 100644 --- a/src/test/java/net/openhft/chronicle/map/ProcessInstanceLimiterMain.java +++ b/src/test/java/net/openhft/chronicle/map/ProcessInstanceLimiterMain.java @@ -36,8 +36,8 @@ public class ProcessInstanceLimiterMain implements Runnable { public ProcessInstanceLimiterMain(String sharedMapName, Callback callback) throws IOException { this.sharedMapName = sharedMapName; this.callback = callback; - ChronicleMapOnHeapUpdatableBuilder builder = - ChronicleMapOnHeapUpdatableBuilder.of(String.class, Data.class); + ChronicleMapBuilder builder = + ChronicleMapBuilder.of(String.class, Data.class); builder.entries(10000); builder.minSegments(2); File file = new File(System.getProperty("java.io.tmpdir") + "/" + sharedMapName); diff --git a/src/test/java/net/openhft/chronicle/map/RecursiveRefereneChMapTest.java b/src/test/java/net/openhft/chronicle/map/RecursiveRefereneChMapTest.java index b5bd950d4..790b84265 100644 --- a/src/test/java/net/openhft/chronicle/map/RecursiveRefereneChMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/RecursiveRefereneChMapTest.java @@ -33,7 +33,7 @@ public class RecursiveRefereneChMapTest { public void testRecursive() throws IOException { File file = new File(TMP + "/test." + System.nanoTime() + ".tmp"); file.deleteOnExit(); - Map map = ChronicleMapOnHeapUpdatableBuilder.of(String.class, StupidCycle.class) + Map map = ChronicleMapBuilder.of(String.class, StupidCycle.class) .entries(64) .objectSerializer(JDKObjectSerializer.INSTANCE).create(); map.put("Test", new StupidCycle()); diff --git a/src/test/java/net/openhft/chronicle/map/ReplicatedChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/ReplicatedChronicleMapTest.java index 34a87018b..382c299cc 100644 --- a/src/test/java/net/openhft/chronicle/map/ReplicatedChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/ReplicatedChronicleMapTest.java @@ -38,14 +38,14 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { ChronicleMap newShmIntString() throws IOException { - return ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + return ChronicleMapBuilder.of(Integer.class, CharSequence.class) .create(); } ChronicleMap newShmStringString() throws IOException { - return ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + return ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .create(); } diff --git a/src/test/java/net/openhft/chronicle/map/SerializerTest.java b/src/test/java/net/openhft/chronicle/map/SerializerTest.java index e1ddf2573..7551c4037 100644 --- a/src/test/java/net/openhft/chronicle/map/SerializerTest.java +++ b/src/test/java/net/openhft/chronicle/map/SerializerTest.java @@ -72,7 +72,13 @@ public class SerializerTest { final ByteBufferBytes out = new ByteBufferBytes(ByteBuffer.allocateDirect(1024)); ByteBufferBytes in = out.slice(); - ChronicleMapOnHeapUpdatableBuilder builder = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, valueClass); + + ChronicleMapBuilder cBuilder = ChronicleMapBuilder.of(Integer + .class, valueClass); + + OnHeapUpdatableChronicleMapBuilder builder = (OnHeapUpdatableChronicleMapBuilder) cBuilder.delegate; + + builder.preMapConstruction(false); Serializer v = new Serializer(builder.valueBuilder); @@ -95,7 +101,10 @@ public class SerializerTest { final ByteBufferBytes out = new ByteBufferBytes(ByteBuffer.allocateDirect(1024)); ByteBufferBytes in = out.slice(); - ChronicleMapOnHeapUpdatableBuilder builder = ChronicleMapOnHeapUpdatableBuilder.of(clazz, Integer.class); + ChronicleMapBuilder cBuilder = ChronicleMapBuilder.of(clazz, Integer.class); + + OnHeapUpdatableChronicleMapBuilder builder = (OnHeapUpdatableChronicleMapBuilder) cBuilder.delegate; + builder.preMapConstruction(false); { Serializer v = new Serializer(builder.keyBuilder); diff --git a/src/test/java/net/openhft/chronicle/map/SingleMapChannelTest.java b/src/test/java/net/openhft/chronicle/map/SingleMapChannelTest.java index 3c78880e6..315cd86e6 100644 --- a/src/test/java/net/openhft/chronicle/map/SingleMapChannelTest.java +++ b/src/test/java/net/openhft/chronicle/map/SingleMapChannelTest.java @@ -70,7 +70,7 @@ public class SingleMapChannelTest { .tcpTransportAndNetwork(tcpConfig) .createWithId(identifier); // this is how you add maps after the custer is created - map1a = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + map1a = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(1000) .instance().replicatedViaChannel(hubA.createChannel((short) 1)).create(); } @@ -84,7 +84,7 @@ public class SingleMapChannelTest { hubB = ReplicationHub.builder().tcpTransportAndNetwork(tcpConfig).createWithId((byte) 2); // this is how you add maps after the custer is created - map1b = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + map1b = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(1000) .instance().replicatedViaChannel(hubB.createChannel((short) 1)) .create(); diff --git a/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java b/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java index 1842fd8a6..d2385a1cb 100644 --- a/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java +++ b/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java @@ -53,14 +53,14 @@ public class StatelessClientTest { public void testMapForKeyWithEntry() throws IOException, InterruptedException { - try (ChronicleMap serverMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, + try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, StringBuilder.class) .defaultValue(new StringBuilder()) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { serverMap.put(10, new StringBuilder("Hello World")); - try (ChronicleMap statelessMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer + try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, StringBuilder.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { @@ -78,14 +78,14 @@ public class StatelessClientTest { public void testMapForKeyWhenNoEntry() throws IOException, InterruptedException { - try (ChronicleMap serverMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, + try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, StringBuilder.class) .defaultValue(new StringBuilder()) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { serverMap.put(10, new StringBuilder("Hello World")); - try (ChronicleMap statelessMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer + try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, StringBuilder.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { @@ -101,10 +101,10 @@ public class StatelessClientTest { public void testBufferOverFlowPutAllAndEntrySet() throws IOException, InterruptedException { - try (ChronicleMap serverMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { - try (ChronicleMap statelessMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer + try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { @@ -134,10 +134,10 @@ public class StatelessClientTest { @Test public void testBufferOverFlowPutAllAndValues() throws IOException, InterruptedException { - try (ChronicleMap serverMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { - try (ChronicleMap statelessMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer + try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { @@ -166,10 +166,10 @@ public class StatelessClientTest { public void testBufferOverFlowPutAllAndKeySet() throws IOException, InterruptedException { - try (ChronicleMap serverMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { - try (ChronicleMap statelessMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer + try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { @@ -198,11 +198,11 @@ public class StatelessClientTest { public void test() throws IOException, InterruptedException { - try (ChronicleMap serverMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { serverMap.put(10, "EXAMPLE-10"); - try (ChronicleMap statelessMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer + try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { @@ -217,10 +217,10 @@ public class StatelessClientTest { @Test public void testClientCreatedBeforeServer() throws IOException, InterruptedException { - try (ChronicleMap serverMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { - try (ChronicleMap statelessMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer + try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { @@ -241,10 +241,10 @@ public class StatelessClientTest { @Test public void testBufferOverFlowPutAll() throws IOException, InterruptedException { - try (ChronicleMap serverMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { - try (ChronicleMap statelessMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer + try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { @@ -272,10 +272,10 @@ public class StatelessClientTest { public void testBufferOverFlowPutAllWherePutReturnsNull() throws IOException, InterruptedException { - try (ChronicleMap serverMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { - try (ChronicleMap statelessMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer + try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { @@ -304,10 +304,10 @@ public class StatelessClientTest { public void testPutWherePutReturnsNull() throws IOException, InterruptedException { - try (ChronicleMap serverMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { - try (ChronicleMap statelessMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer + try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { @@ -326,10 +326,10 @@ public class StatelessClientTest { public void testRemoveWhereRemoveReturnsNull() throws IOException, InterruptedException { - try (ChronicleMap serverMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + try (ChronicleMap serverMap = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create()) { - try (ChronicleMap statelessMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer + try (ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create()) { @@ -360,9 +360,9 @@ public class StatelessClientTest { // server { - serverMap1 = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + serverMap1 = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8056)).create(); - serverMap2 = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + serverMap2 = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8077)).create(); } @@ -370,10 +370,10 @@ public class StatelessClientTest { // stateless client { - statelessMap1 = ChronicleMapOnHeapUpdatableBuilder.of(Integer + statelessMap1 = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8056)).create(); - statelessMap2 = ChronicleMapOnHeapUpdatableBuilder.of(Integer + statelessMap2 = ChronicleMapBuilder.of(Integer .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", 8077)).create(); } diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplication3wayPutReturnsNullTest.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplication3wayPutReturnsNullTest.java index 4f6a72af8..3af0a9cc2 100755 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplication3wayPutReturnsNullTest.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplication3wayPutReturnsNullTest.java @@ -50,7 +50,7 @@ public class TCPSocketReplication3wayPutReturnsNullTest { final InetSocketAddress... endpoints) throws IOException { TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(serverPort, Arrays.asList(endpoints)); - return (T) ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + return (T) ChronicleMapBuilder.of(Integer.class, CharSequence.class) .putReturnsNull(true) .replication(identifier, tcpConfig).create(); } diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTest.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTest.java index dce3e622b..041c066b4 100644 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTest.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationBootStrapTest.java @@ -47,7 +47,7 @@ public class TCPSocketReplicationBootStrapTest { map1 = newTcpSocketShmIntString((byte) 1, 8069); - ChronicleMapOnHeapUpdatableBuilder map2aBuilder = + ChronicleMapBuilder map2aBuilder = newTcpSocketShmBuilder(Integer.class, CharSequence.class, (byte) 2, 8066, new InetSocketAddress("localhost", 8069)); final ChronicleMap map2a = @@ -108,7 +108,7 @@ public class TCPSocketReplicationBootStrapTest { { // restart map 2 but does not connect it to map1 - final ChronicleMap map2b = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, + final ChronicleMap map2b = ChronicleMapBuilder.of(Integer.class, CharSequence.class).replication((byte) 2).createPersistedTo(persistenceFile); // add data into it map2b.put(11, "ADDED WHEN DISCONNECTED TO MAP1"); diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationIntValueTest.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationIntValueTest.java index 991dde467..93429dd23 100644 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationIntValueTest.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationIntValueTest.java @@ -45,7 +45,7 @@ import static org.junit.Assert.assertTrue; public class TCPSocketReplicationIntValueTest { - private ChronicleMapOnHeapUpdatableBuilder map1Builder; + private ChronicleMapBuilder map1Builder; private ChronicleMap map1; private ChronicleMap map2; private IntValue value; diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationPostConnectionTest.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationPostConnectionTest.java index 79cf9983c..2a931292b 100644 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationPostConnectionTest.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationPostConnectionTest.java @@ -76,7 +76,7 @@ public class TCPSocketReplicationPostConnectionTest { @Test public void testBootStrapIntoNewMapWithNewFile() throws IOException, InterruptedException { - ChronicleMapOnHeapUpdatableBuilder map2aBuilder = + ChronicleMapBuilder map2aBuilder = newTcpSocketShmBuilder(Integer.class, CharSequence.class, (byte) 2, 8077, new InetSocketAddress("localhost", 8076)); try (final ChronicleMap map2a = diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest.java index a964ffed2..f8e8f7a52 100644 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest.java @@ -47,7 +47,7 @@ public class TCPSocketReplicationTest { @Before public void setup() throws IOException { - ChronicleMapOnHeapUpdatableBuilder map1Builder = + ChronicleMapBuilder map1Builder = newTcpSocketShmBuilder(Integer.class, CharSequence.class, (byte) 1, 8076, new InetSocketAddress("localhost", 8077)); map1 = map1Builder.createPersistedTo(getPersistenceFile()); diff --git a/src/test/java/net/openhft/chronicle/map/TestBooleanValues.java b/src/test/java/net/openhft/chronicle/map/TestBooleanValues.java index 4be12c3b8..eff5fa333 100644 --- a/src/test/java/net/openhft/chronicle/map/TestBooleanValues.java +++ b/src/test/java/net/openhft/chronicle/map/TestBooleanValues.java @@ -35,7 +35,7 @@ public class TestBooleanValues { @Test public void testTestBooleanValues() throws IOException, InterruptedException { ChronicleMap map = - ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, Boolean.class).create(); + ChronicleMapBuilder.of(Integer.class, Boolean.class).create(); map.put(7, true); Assert.assertEquals(true, map.get(7)); } diff --git a/src/test/java/net/openhft/chronicle/map/TimeBasedReplicationTest.java b/src/test/java/net/openhft/chronicle/map/TimeBasedReplicationTest.java index 189a3a599..639da0acd 100644 --- a/src/test/java/net/openhft/chronicle/map/TimeBasedReplicationTest.java +++ b/src/test/java/net/openhft/chronicle/map/TimeBasedReplicationTest.java @@ -49,7 +49,7 @@ public class TimeBasedReplicationTest extends JSR166TestCase { public void testIgnoreALatePut() throws IOException { final TimeProvider timeProvider = Mockito.mock(TimeProvider.class); - ChronicleMap map = ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) .createReplicated((byte) 1); @@ -78,7 +78,7 @@ public class TimeBasedReplicationTest extends JSR166TestCase { public void testIgnoreALatePutIfAbsent() throws IOException { final TimeProvider timeProvider = Mockito.mock(TimeProvider.class); - ChronicleMap map = ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) .createReplicated((byte) 1); @@ -108,7 +108,7 @@ public class TimeBasedReplicationTest extends JSR166TestCase { public void testIgnoreALateReplace() throws IOException { final TimeProvider timeProvider = Mockito.mock(TimeProvider.class); - ChronicleMap map = ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) .createReplicated((byte) 1); @@ -141,7 +141,7 @@ public class TimeBasedReplicationTest extends JSR166TestCase { public void testIgnoreALateReplaceWithValue() throws IOException { final TimeProvider timeProvider = Mockito.mock(TimeProvider.class); - ChronicleMap map = ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) .createReplicated((byte) 1); @@ -171,7 +171,7 @@ public class TimeBasedReplicationTest extends JSR166TestCase { public void testIgnoreALateRemoveWithValue() throws IOException { final TimeProvider timeProvider = Mockito.mock(TimeProvider.class); - ChronicleMap map = ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) .createReplicated((byte) 1); @@ -200,7 +200,7 @@ public class TimeBasedReplicationTest extends JSR166TestCase { public void testIgnoreALateRemove() throws IOException { final TimeProvider timeProvider = Mockito.mock(TimeProvider.class); - ChronicleMap map = ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) .createReplicated((byte) 1); @@ -229,7 +229,7 @@ public class TimeBasedReplicationTest extends JSR166TestCase { public void testIgnoreWithRemoteRemove() throws IOException { final TimeProvider timeProvider = Mockito.mock(TimeProvider.class); - ReplicatedChronicleMap map = (ReplicatedChronicleMap) ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ReplicatedChronicleMap map = (ReplicatedChronicleMap) ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) .createReplicated((byte) 1); @@ -259,7 +259,7 @@ public class TimeBasedReplicationTest extends JSR166TestCase { final TimeProvider timeProvider = Mockito.mock(TimeProvider.class); - ReplicatedChronicleMap map = (ReplicatedChronicleMap) ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ReplicatedChronicleMap map = (ReplicatedChronicleMap) ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) .createReplicated((byte) 1); @@ -289,7 +289,7 @@ public class TimeBasedReplicationTest extends JSR166TestCase { public void testRemoveFollowedByLatePut() throws IOException { final TimeProvider timeProvider = Mockito.mock(TimeProvider.class); - ReplicatedChronicleMap map = (ReplicatedChronicleMap) ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ReplicatedChronicleMap map = (ReplicatedChronicleMap) ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) .createReplicated((byte) 1); @@ -317,7 +317,7 @@ public class TimeBasedReplicationTest extends JSR166TestCase { public void testPutRemovePut() throws IOException { final TimeProvider timeProvider = Mockito.mock(TimeProvider.class); - ChronicleMap map = ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMap map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(10) .timeProvider(timeProvider) .createReplicated((byte) 1); diff --git a/src/test/java/net/openhft/chronicle/map/TwoMapOnDifferentServersTest.java b/src/test/java/net/openhft/chronicle/map/TwoMapOnDifferentServersTest.java index 8ca1838c5..484c8c769 100644 --- a/src/test/java/net/openhft/chronicle/map/TwoMapOnDifferentServersTest.java +++ b/src/test/java/net/openhft/chronicle/map/TwoMapOnDifferentServersTest.java @@ -48,11 +48,11 @@ public class TwoMapOnDifferentServersTest { .heartBeatInterval(1, SECONDS); - map1 = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + map1 = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(20000) .replication((byte) 1, tcpConfig).create(); - map2 = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + map2 = ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(20000) .replication((byte) 2, TcpTransportAndNetworkConfig.of(8077) .heartBeatInterval(1, SECONDS)).create(); diff --git a/src/test/java/net/openhft/chronicle/map/UDPSocketReplicationTest.java b/src/test/java/net/openhft/chronicle/map/UDPSocketReplicationTest.java index 0ff22fdde..4f44e0b29 100644 --- a/src/test/java/net/openhft/chronicle/map/UDPSocketReplicationTest.java +++ b/src/test/java/net/openhft/chronicle/map/UDPSocketReplicationTest.java @@ -44,7 +44,7 @@ public class UDPSocketReplicationTest { UdpTransportConfig udpConfig = UdpTransportConfig .of(Inet4Address.getByName("255.255.255.255"), udpPort); - return ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + return ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(1000) .replication(SingleChronicleHashReplication.builder().udpTransport(udpConfig) .createWithId((byte) identifier)) diff --git a/src/test/java/net/openhft/chronicle/map/example/ChannelExample.java b/src/test/java/net/openhft/chronicle/map/example/ChannelExample.java index 1bc1457b7..0189fa77b 100644 --- a/src/test/java/net/openhft/chronicle/map/example/ChannelExample.java +++ b/src/test/java/net/openhft/chronicle/map/example/ChannelExample.java @@ -3,7 +3,8 @@ package net.openhft.chronicle.map.example; import net.openhft.chronicle.hash.replication.ReplicationHub; import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig; import net.openhft.chronicle.map.ChronicleMap; -import net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder; +import net.openhft.chronicle.map.ChronicleMapBuilder; +import net.openhft.chronicle.map.ChronicleMapBuilder; import org.junit.Assert; import org.junit.Test; @@ -63,8 +64,8 @@ public class ChannelExample { // server 1 with identifier = 1 { - ChronicleMapOnHeapUpdatableBuilder smallStringToStringMapBuilder = - ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMapBuilder smallStringToStringMapBuilder = + ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(1000); byte identifier = (byte) 1; @@ -98,8 +99,8 @@ public class ChannelExample { // server 2 with identifier = 2 { - ChronicleMapOnHeapUpdatableBuilder smallStringToStringMapBuilder = - ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + ChronicleMapBuilder smallStringToStringMapBuilder = + ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(1000); byte identifier = (byte) 2; diff --git a/src/test/java/net/openhft/chronicle/map/example/DistributedSequenceMain.java b/src/test/java/net/openhft/chronicle/map/example/DistributedSequenceMain.java index 77331fca3..13f03e882 100644 --- a/src/test/java/net/openhft/chronicle/map/example/DistributedSequenceMain.java +++ b/src/test/java/net/openhft/chronicle/map/example/DistributedSequenceMain.java @@ -19,7 +19,7 @@ package net.openhft.chronicle.map.example; import net.openhft.chronicle.map.ChronicleMap; -import net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder; +import net.openhft.chronicle.map.ChronicleMapBuilder; import net.openhft.lang.model.DataValueClasses; import net.openhft.lang.values.LongValue; @@ -30,7 +30,7 @@ public class DistributedSequenceMain { public static void main(String... ignored) throws IOException { Class longValueClass = DataValueClasses.directClassFor(LongValue.class); ChronicleMap map = - ChronicleMapOnHeapUpdatableBuilder.of(String.class, longValueClass) + ChronicleMapBuilder.of(String.class, longValueClass) .entries(128) .actualSegments(1).create(); LongValue value = DataValueClasses.newDirectReference(longValueClass); diff --git a/src/test/java/net/openhft/chronicle/map/example/ServersMapMain.java b/src/test/java/net/openhft/chronicle/map/example/ServersMapMain.java index 441f3003a..57706e3c0 100644 --- a/src/test/java/net/openhft/chronicle/map/example/ServersMapMain.java +++ b/src/test/java/net/openhft/chronicle/map/example/ServersMapMain.java @@ -20,7 +20,7 @@ package net.openhft.chronicle.map.example; import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig; import net.openhft.chronicle.map.ChronicleMap; -import net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder; +import net.openhft.chronicle.map.ChronicleMapBuilder; import java.io.File; import java.io.IOException; @@ -39,7 +39,7 @@ public class ServersMapMain { public static void startServer() throws IOException { File file = File.createTempFile("testServersMapMain", ".deleteme"); file.deleteOnExit(); - final ChronicleMap serverMap = ChronicleMapOnHeapUpdatableBuilder.of(byte[].class, byte[].class) + final ChronicleMap serverMap = ChronicleMapBuilder.of(byte[].class, byte[].class) .putReturnsNull(true) .entrySize(50) .replication((byte) 2, TcpTransportAndNetworkConfig.of(port)) @@ -52,7 +52,7 @@ public class ServersMapMain { public static void startRemoteClient(String hostname) throws IOException { final ChronicleMap map; if (stateless) { - map = ChronicleMapOnHeapUpdatableBuilder.of( + map = ChronicleMapBuilder.of( byte[].class, byte[].class) .putReturnsNull(true) .statelessClient(new InetSocketAddress(hostname, port)).create(); @@ -61,7 +61,7 @@ public class ServersMapMain { file.deleteOnExit(); TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(port, new InetSocketAddress(hostname, port)); - map = ChronicleMapOnHeapUpdatableBuilder.of( + map = ChronicleMapBuilder.of( byte[].class, byte[].class) .putReturnsNull(true) .replication((byte) 1, tcpConfig) diff --git a/src/test/java/net/openhft/chronicle/map/example/StringsMapMain.java b/src/test/java/net/openhft/chronicle/map/example/StringsMapMain.java index 9bf177ee5..08b700c13 100644 --- a/src/test/java/net/openhft/chronicle/map/example/StringsMapMain.java +++ b/src/test/java/net/openhft/chronicle/map/example/StringsMapMain.java @@ -20,7 +20,7 @@ package net.openhft.chronicle.map.example; import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig; import net.openhft.chronicle.map.ChronicleMap; -import net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder; +import net.openhft.chronicle.map.ChronicleMapBuilder; import java.io.File; import java.io.IOException; @@ -38,7 +38,7 @@ public class StringsMapMain { public static void startServer() throws IOException { File file = File.createTempFile("testServersMapMain", ".deleteme"); file.deleteOnExit(); - final ChronicleMap serverMap = ChronicleMapOnHeapUpdatableBuilder + final ChronicleMap serverMap = ChronicleMapBuilder .of(CharSequence.class, CharSequence.class) .putReturnsNull(true) .entrySize(50) @@ -52,8 +52,7 @@ public class StringsMapMain { public static void startRemoteClient(String hostname) throws IOException { final ChronicleMap map; if (stateless) { - map = ChronicleMapOnHeapUpdatableBuilder - .of(CharSequence.class, CharSequence.class) + map = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .putReturnsNull(true) .statelessClient(new InetSocketAddress(hostname, port)).create(); } else { @@ -61,7 +60,7 @@ public class StringsMapMain { file.deleteOnExit(); TcpTransportAndNetworkConfig tcpConfig = TcpTransportAndNetworkConfig.of(port, new InetSocketAddress(hostname, port)); - map = ChronicleMapOnHeapUpdatableBuilder + map = ChronicleMapBuilder .of(CharSequence.class, CharSequence.class) .putReturnsNull(true) .replication((byte) 1, tcpConfig) diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongCASLeft.java b/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongCASLeft.java index fdcee15c4..cd1a98c5e 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongCASLeft.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongCASLeft.java @@ -20,7 +20,7 @@ package net.openhft.chronicle.map.fromdocs.pingpong_latency; import net.openhft.affinity.AffinitySupport; import net.openhft.chronicle.map.ChronicleMap; -import net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder; +import net.openhft.chronicle.map.ChronicleMapBuilder; import net.openhft.chronicle.map.fromdocs.BondVOInterface; import java.io.IOException; @@ -89,7 +89,7 @@ public class PingPongCASLeft { static ChronicleMap acquireCHM() throws IOException { // ensure thread ids are globally unique. AffinitySupport.setThreadId(); - return ChronicleMapOnHeapUpdatableBuilder.of(String.class, BondVOInterface.class) + return ChronicleMapBuilder.of(String.class, BondVOInterface.class) .entries(16) .entrySize(64).create(); } diff --git a/src/test/java/net/openhft/chronicle/map/ipc/StateMachineTutorial.java b/src/test/java/net/openhft/chronicle/map/ipc/StateMachineTutorial.java index bf8986368..7cc518e78 100644 --- a/src/test/java/net/openhft/chronicle/map/ipc/StateMachineTutorial.java +++ b/src/test/java/net/openhft/chronicle/map/ipc/StateMachineTutorial.java @@ -19,7 +19,7 @@ package net.openhft.chronicle.map.ipc; import net.openhft.chronicle.map.ChronicleMap; -import net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder; +import net.openhft.chronicle.map.ChronicleMapBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,7 +40,7 @@ public class StateMachineTutorial { try { File dataFile = new File(System.getProperty("java.io.tmpdir"), "hft-state-machine"); - map = ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, StateMachineData.class) + map = ChronicleMapBuilder.of(Integer.class, StateMachineData.class) .entries(8).create(); if (args.length > 0) { diff --git a/src/test/java/net/openhft/chronicle/map/jrs166/map/ChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/jrs166/map/ChronicleMapTest.java index 6c28aa50c..c3665fa8c 100644 --- a/src/test/java/net/openhft/chronicle/map/jrs166/map/ChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/jrs166/map/ChronicleMapTest.java @@ -19,7 +19,7 @@ package net.openhft.chronicle.map.jrs166.map; import net.openhft.chronicle.map.ChronicleMap; -import net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder; +import net.openhft.chronicle.map.ChronicleMapBuilder; import net.openhft.chronicle.map.jrs166.JSR166TestCase; import org.junit.Test; @@ -49,33 +49,33 @@ public class ChronicleMapTest extends JSR166TestCase { } static ChronicleMap newShmIntString(int size) throws IOException { - return ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class) + return ChronicleMapBuilder.of(Integer.class, CharSequence.class) .entries(size).create(); } static ChronicleMap newShmListBoolean(int size) throws IOException { - return ChronicleMapOnHeapUpdatableBuilder.of(ArrayList.class, CharSequence.class) + return ChronicleMapBuilder.of(ArrayList.class, CharSequence.class) .entries(size).create(); } static ChronicleMap newShmListBoolean() throws IOException { - return ChronicleMapOnHeapUpdatableBuilder.of(ArrayList.class, CharSequence.class).create(); + return ChronicleMapBuilder.of(ArrayList.class, CharSequence.class).create(); } static ChronicleMap newShmStringString(int size) throws IOException { - return ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + return ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .entries(size).create(); } static ChronicleMap newShmIntString() throws IOException { - return ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, CharSequence.class).create(); + return ChronicleMapBuilder.of(Integer.class, CharSequence.class).create(); } static ChronicleMap newShmBiBoolean() throws IOException { - return ChronicleMapOnHeapUpdatableBuilder.of(BI.class, Boolean.class).create(); + return ChronicleMapBuilder.of(BI.class, Boolean.class).create(); } /** diff --git a/src/test/java/net/openhft/chronicle/map/jrs166/map/MapCheck.java b/src/test/java/net/openhft/chronicle/map/jrs166/map/MapCheck.java index 8d4edab60..e97ce82af 100644 --- a/src/test/java/net/openhft/chronicle/map/jrs166/map/MapCheck.java +++ b/src/test/java/net/openhft/chronicle/map/jrs166/map/MapCheck.java @@ -19,7 +19,7 @@ package net.openhft.chronicle.map.jrs166.map; import net.openhft.chronicle.map.ChronicleMap; -import net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder; +import net.openhft.chronicle.map.ChronicleMapBuilder; import java.io.*; import java.util.*; @@ -123,7 +123,7 @@ public class MapCheck { static Map newMap() { try { - return ChronicleMapOnHeapUpdatableBuilder.of(Object.class, Object.class).create(); + return ChronicleMapBuilder.of(Object.class, Object.class).create(); } catch (Exception e) { throw new RuntimeException("Can't instantiate CHM : " + e); diff --git a/src/test/java/net/openhft/chronicle/map/jrs166/map/StatelessChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/jrs166/map/StatelessChronicleMapTest.java index debe6f367..51b9e8fa4 100755 --- a/src/test/java/net/openhft/chronicle/map/jrs166/map/StatelessChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/jrs166/map/StatelessChronicleMapTest.java @@ -20,7 +20,7 @@ package net.openhft.chronicle.map.jrs166.map; import net.openhft.chronicle.hash.replication.TcpTransportAndNetworkConfig; import net.openhft.chronicle.map.ChronicleMap; -import net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder; +import net.openhft.chronicle.map.ChronicleMapBuilder; import net.openhft.chronicle.map.ReadContext; import net.openhft.chronicle.map.WriteContext; import net.openhft.chronicle.map.jrs166.JSR166TestCase; @@ -193,10 +193,10 @@ public class StatelessChronicleMapTest extends JSR166TestCase { static ChronicleMap newShmIntString(int port) throws IOException { final ChronicleMap serverMap = - ChronicleMapOnHeapUpdatableBuilder.of(Integer.class, String.class) + ChronicleMapBuilder.of(Integer.class, String.class) .replication((byte) 1, TcpTransportAndNetworkConfig.of(port)).create(); - final ChronicleMap statelessMap = ChronicleMapOnHeapUpdatableBuilder.of(Integer + final ChronicleMap statelessMap = ChronicleMapBuilder.of(Integer .class, String.class) .statelessClient(new InetSocketAddress("localhost", port)).create(); @@ -207,11 +207,11 @@ public class StatelessChronicleMapTest extends JSR166TestCase { static ChronicleMap newStrStrMap(int port) throws IOException { - final ChronicleMap serverMap = ChronicleMapOnHeapUpdatableBuilder.of(CharSequence.class, CharSequence.class) + final ChronicleMap serverMap = ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) .replication((byte) 2, TcpTransportAndNetworkConfig.of(port)).create(); - final ChronicleMap statelessMap = ChronicleMapOnHeapUpdatableBuilder.of(CharSequence + final ChronicleMap statelessMap = ChronicleMapBuilder.of(CharSequence .class, CharSequence.class) .statelessClient(new InetSocketAddress("localhost", port)).create(); @@ -221,12 +221,12 @@ public class StatelessChronicleMapTest extends JSR166TestCase { static ChronicleMap newByteArrayMap(int port) throws IOException { - final ChronicleMap serverMap = ChronicleMapOnHeapUpdatableBuilder.of(byte[].class, byte[].class) + final ChronicleMap serverMap = ChronicleMapBuilder.of(byte[].class, byte[].class) .putReturnsNull(true) .replication((byte) 2, TcpTransportAndNetworkConfig.of(port)).create(); - final ChronicleMap statelessMap = ChronicleMapOnHeapUpdatableBuilder.of( + final ChronicleMap statelessMap = ChronicleMapBuilder.of( byte[].class, byte[].class) .putReturnsNull(true) .statelessClient(new InetSocketAddress("localhost", port)).create(); diff --git a/src/test/java/net/openhft/chronicle/map/utility/ProcessInstanceLimiter.java b/src/test/java/net/openhft/chronicle/map/utility/ProcessInstanceLimiter.java index d93f2878d..cecae189c 100644 --- a/src/test/java/net/openhft/chronicle/map/utility/ProcessInstanceLimiter.java +++ b/src/test/java/net/openhft/chronicle/map/utility/ProcessInstanceLimiter.java @@ -20,7 +20,7 @@ package net.openhft.chronicle.map.utility; import net.openhft.affinity.AffinitySupport; import net.openhft.chronicle.map.ChronicleMap; -import net.openhft.chronicle.map.ChronicleMapOnHeapUpdatableBuilder; +import net.openhft.chronicle.map.ChronicleMapBuilder; import net.openhft.lang.model.DataValueClasses; import net.openhft.lang.model.constraints.MaxSize; @@ -134,8 +134,8 @@ public class ProcessInstanceLimiter implements Runnable { public ProcessInstanceLimiter(String sharedMapPath, Callback callback) throws IOException { this.sharedMapPath = sharedMapPath; this.callback = callback; - ChronicleMapOnHeapUpdatableBuilder builder = - ChronicleMapOnHeapUpdatableBuilder.of(String.class, Data.class); + ChronicleMapBuilder builder = + ChronicleMapBuilder.of(String.class, Data.class); builder.entries(1000); builder.entrySize(1024); this.theSharedMap = builder.createPersistedTo(new File(sharedMapPath));