From 6289c9300ccb3309d37be5c27f5b7a64a7253e8a Mon Sep 17 00:00:00 2001 From: leventov Date: Sun, 25 Jan 2015 08:17:34 +0700 Subject: [PATCH 1/8] Issue with MarkTest.persistedTest possibly resolved? --- src/test/java/net/openhft/chronicle/map/MarkTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/openhft/chronicle/map/MarkTest.java b/src/test/java/net/openhft/chronicle/map/MarkTest.java index d5bb4c67c..504e5df69 100644 --- a/src/test/java/net/openhft/chronicle/map/MarkTest.java +++ b/src/test/java/net/openhft/chronicle/map/MarkTest.java @@ -44,10 +44,11 @@ public class MarkTest { }); } - @Ignore("fails sometimes on TC") - @Test(timeout = 50000) + @Test(timeout = 25000) public void persistedTest() { final File db = Paths.get(System.getProperty("java.io.tmpdir"), "mark").toFile(); + if (db.exists()) + db.delete(); try { test(new Function, ChronicleMap>() { From 893d918811e5beed5ac6e7f514c3c927229eed5e Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Sun, 25 Jan 2015 10:10:11 +0000 Subject: [PATCH 2/8] the next release will be 2.1.0-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f540e87c4..91dc9de58 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 4.0.0 chronicle-map - 2.0.22rc7-SNAPSHOT + 2.1.0-SNAPSHOT OpenHFT/Chronicle-Map Chronicle-Map From 62892f74c0d7bcf94304ddad5cb2f1d1f4b1f613 Mon Sep 17 00:00:00 2001 From: leventov Date: Sun, 25 Jan 2015 17:19:15 +0700 Subject: [PATCH 3/8] Try to avoid MarkTest failing because of interference of different builds --- src/test/java/net/openhft/chronicle/map/MarkTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/net/openhft/chronicle/map/MarkTest.java b/src/test/java/net/openhft/chronicle/map/MarkTest.java index 504e5df69..03ef0b534 100644 --- a/src/test/java/net/openhft/chronicle/map/MarkTest.java +++ b/src/test/java/net/openhft/chronicle/map/MarkTest.java @@ -46,7 +46,8 @@ public class MarkTest { @Test(timeout = 25000) public void persistedTest() { - final File db = Paths.get(System.getProperty("java.io.tmpdir"), "mark").toFile(); + int rnd = new Random().nextInt(); + final File db = Paths.get(System.getProperty("java.io.tmpdir"), "mark" + rnd).toFile(); if (db.exists()) db.delete(); try { From 2ed4790eb9c50a6bf4edd000933c0beab1453b8b Mon Sep 17 00:00:00 2001 From: leventov Date: Mon, 26 Jan 2015 09:40:50 +0700 Subject: [PATCH 4/8] Made ReplicatedChronicleMapTest really a test of ReplicatedChronicleMap --- .../net/openhft/chronicle/map/ReplicatedChronicleMapTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/java/net/openhft/chronicle/map/ReplicatedChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/ReplicatedChronicleMapTest.java index eaee51f2c..14f5d7517 100644 --- a/src/test/java/net/openhft/chronicle/map/ReplicatedChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/ReplicatedChronicleMapTest.java @@ -37,11 +37,15 @@ import static org.junit.Assert.*; public class ReplicatedChronicleMapTest extends JSR166TestCase { ChronicleMap newShmIntString() throws IOException { return ChronicleMapBuilder.of(Integer.class, CharSequence.class) + .replication((byte) 1) + .entries(1000) .create(); } ChronicleMap newShmStringString() throws IOException { return ChronicleMapBuilder.of(CharSequence.class, CharSequence.class) + .replication((byte) 1) + .entries(1000) .create(); } From 07333660d0fdb02b56b020d098f39749789646c0 Mon Sep 17 00:00:00 2001 From: leventov Date: Wed, 28 Jan 2015 11:43:50 +0700 Subject: [PATCH 5/8] HCOLL-286 HCOLL-292 added replicationEvent flag to event callbacks --- .../chronicle/map/BytesMapEventListener.java | 6 +++-- .../chronicle/map/MapEventListener.java | 18 +++++++------- .../chronicle/map/ReplicatedChronicleMap.java | 8 +++---- .../map/ReplicationHubFindByName.java | 4 ++-- .../chronicle/map/VanillaChronicleMap.java | 24 +++++++++---------- .../chronicle/map/CHMMetaDataTest.java | 4 ++-- ...tListenerWithTCPSocketReplicationTest.java | 4 ++-- 7 files changed, 35 insertions(+), 33 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/BytesMapEventListener.java b/src/main/java/net/openhft/chronicle/map/BytesMapEventListener.java index 745221023..4fac85ad7 100644 --- a/src/main/java/net/openhft/chronicle/map/BytesMapEventListener.java +++ b/src/main/java/net/openhft/chronicle/map/BytesMapEventListener.java @@ -44,11 +44,13 @@ public abstract class BytesMapEventListener implements Serializable { // do nothing } - public void onPut(Bytes entry, long metaDataPos, long keyPos, long valuePos, boolean added) { + public void onPut(Bytes entry, long metaDataPos, long keyPos, long valuePos, boolean added, + boolean replicationEvent) { // do nothing } - public void onRemove(Bytes entry, long metaDataPos, long keyPos, long valuePos) { + public void onRemove(Bytes entry, long metaDataPos, long keyPos, long valuePos, + boolean replicationEvent) { // do nothing } } diff --git a/src/main/java/net/openhft/chronicle/map/MapEventListener.java b/src/main/java/net/openhft/chronicle/map/MapEventListener.java index 8535d1b29..bccf3eec0 100644 --- a/src/main/java/net/openhft/chronicle/map/MapEventListener.java +++ b/src/main/java/net/openhft/chronicle/map/MapEventListener.java @@ -81,12 +81,12 @@ public abstract class MapEventListener implements Serializable { } @Override - public void onPut(Object key, Object value, Object replacedValue) { + public void onPut(Object key, Object value, Object replacedValue, boolean replicationEvent) { LOGGER.info("{} put {} => {}", prefix, key, value); } @Override - public void onRemove(Object key, Object value) { + public void onRemove(Object key, Object value, boolean replicationEvent) { LOGGER.info("{} remove {} was {}", prefix, key, value); } } @@ -112,24 +112,24 @@ public abstract class MapEventListener implements Serializable { * as well. * *

This method is called when put is already happened. - * - * @param key the key the given value is put for + * @param key the key the given value is put for * @param newValue the value which is now associated with the given key * @param replacedValue the value which was replaced by {@code newValue}, {@code null} if the - * key was absent in the map before current {@code ChronicleMap} + * key was absent in the map before current {@code ChronicleMap} + * @param replicationEvent */ - public void onPut(K key, V newValue, @Nullable V replacedValue) { + public void onPut(K key, V newValue, @Nullable V replacedValue, boolean replicationEvent) { // do nothing } /** * This is called when an entry is removed. Misses, i. e. when {@code map.remove(key)} is * called, but key is already absent in the map, are not notified. - * - * @param key the key removed from the map + * @param key the key removed from the map * @param value the value which was associated with the given key + * @param replicationEvent */ - public void onRemove(K key, V value) { + public void onRemove(K key, V value, boolean replicationEvent) { // do nothing } } diff --git a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java index aad7653a4..bb25b3406 100644 --- a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java @@ -766,11 +766,11 @@ final class ReplicatedChronicleMap implements FindByName { // creates a map based on the details that are sent to the map of builders @Override public void onPut(CharSequence key, MapInstanceBuilder value, - MapInstanceBuilder replacedValue) { - super.onPut(key, value, replacedValue); + MapInstanceBuilder replacedValue, boolean replicationEvent) { + super.onPut(key, value, replacedValue, replicationEvent); boolean added = replacedValue == null; if (!added || value == null) return; diff --git a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java index 82ec86641..f765d04d8 100755 --- a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java @@ -1758,11 +1758,11 @@ class VanillaChronicleMap, onPut(this, segmentState.pos); if (bytesEventListener != null) { long keyPos = metaDataBytes; - bytesEventListener.onPut(entry, 0L, keyPos, segmentState.valueSizePos, true); + bytesEventListener.onPut(entry, 0L, keyPos, segmentState.valueSizePos, true, false); } if (eventListener != null) { eventListener.onPut(toKey.toInstance(copies, key, keySize), - toValue.toInstance(copies, v, valueSize), null); + toValue.toInstance(copies, v, valueSize), null, false); } return v; @@ -1866,10 +1866,10 @@ class VanillaChronicleMap, onPut(this, segmentState.pos); if (bytesEventListener != null) bytesEventListener.onPut(entry, 0L, metaDataBytes, - segmentState.valueSizePos, true); + segmentState.valueSizePos, true, false); if (eventListener != null) eventListener.onPut(toKey.toInstance(copies, key, keySize), - toValue.toInstance(copies, value, valueSize), null); + toValue.toInstance(copies, value, valueSize), null, false); return resultUnused ? null : readValue.readNull(); } @@ -1913,10 +1913,10 @@ class VanillaChronicleMap, // put callbacks onPutMaybeRemote(segmentState.pos, remote); if (bytesEventListener != null) - bytesEventListener.onPut(entry, 0L, metaDataBytes, valueSizePos, false); + bytesEventListener.onPut(entry, 0L, metaDataBytes, valueSizePos, false, remote); if (eventListener != null) { eventListener.onPut(toKey.toInstance(copies, key, keySize), - toValue.toInstance(copies, value, valueSize), prevValueInstance); + toValue.toInstance(copies, value, valueSize), prevValueInstance, remote); } return resultUnused ? null : prevValue; @@ -2153,12 +2153,12 @@ class VanillaChronicleMap, // remove callbacks onRemoveMaybeRemote(pos, remote); if (bytesEventListener != null) - bytesEventListener.onRemove(entry, 0L, metaDataBytes, valueSizePos); + bytesEventListener.onRemove(entry, 0L, metaDataBytes, valueSizePos, remote); if (eventListener != null) { V removedValueForEventListener = toValue.toInstance(copies, removedValue, valueSize); eventListener.onRemove(toKey.toInstance(copies, key, keySize), - removedValueForEventListener); + removedValueForEventListener, remote); } return booleanResult ? Boolean.TRUE : removedValue; @@ -2292,12 +2292,12 @@ class VanillaChronicleMap, onPut(this, segmentState.pos); if (bytesEventListener != null) { long keyPos = metaDataBytes; - bytesEventListener.onPut(entry, 0L, keyPos, segmentState.valueSizePos, true); + bytesEventListener.onPut(entry, 0L, keyPos, segmentState.valueSizePos, true, false); } if (eventListener != null) eventListener.onPut(toKey.toInstance(copies, key, keySize), toValue.toInstance(copies, newValue, newValueSize), - toValue.toInstance(copies, prevValue, valueSize)); + toValue.toInstance(copies, prevValue, valueSize), false); return expectedValue == null ? prevValue : Boolean.TRUE; } @@ -2590,9 +2590,9 @@ class VanillaChronicleMap, // remove callbacks onRemove(segment, pos); if (bytesEventListener != null) - bytesEventListener.onRemove(entry, 0L, metaDataBytes, valueSizePos); + bytesEventListener.onRemove(entry, 0L, metaDataBytes, valueSizePos, false); if (eventListener != null) - eventListener.onRemove(returnedEntry.getKey(), returnedEntry.getValue()); + eventListener.onRemove(returnedEntry.getKey(), returnedEntry.getValue(), false); } } diff --git a/src/test/java/net/openhft/chronicle/map/CHMMetaDataTest.java b/src/test/java/net/openhft/chronicle/map/CHMMetaDataTest.java index d4e787013..99081f6bc 100644 --- a/src/test/java/net/openhft/chronicle/map/CHMMetaDataTest.java +++ b/src/test/java/net/openhft/chronicle/map/CHMMetaDataTest.java @@ -76,14 +76,14 @@ public class CHMMetaDataTest { } @Override - public void onPut(Bytes entry, long metaDataPos, long keyPos, long valuePos, boolean added) { + public void onPut(Bytes entry, long metaDataPos, long keyPos, long valuePos, boolean added, boolean replicationEvent) { if (added) assertEquals(0, entry.readLong(metaDataPos)); entry.writeLong(metaDataPos, timeStamps.incrementAndGet()); } @Override - public void onRemove(Bytes entry, long metaDataPos, long keyPos, long valuePos) { + public void onRemove(Bytes entry, long metaDataPos, long keyPos, long valuePos, boolean replicationEvent) { System.out.println("Removed entry with ts of " + entry.readLong(metaDataPos));; } } diff --git a/src/test/java/net/openhft/chronicle/map/EventListenerWithTCPSocketReplicationTest.java b/src/test/java/net/openhft/chronicle/map/EventListenerWithTCPSocketReplicationTest.java index f1ead09b4..312626b60 100644 --- a/src/test/java/net/openhft/chronicle/map/EventListenerWithTCPSocketReplicationTest.java +++ b/src/test/java/net/openhft/chronicle/map/EventListenerWithTCPSocketReplicationTest.java @@ -55,7 +55,7 @@ public class EventListenerWithTCPSocketReplicationTest { private static final long serialVersionUID = 1L; @Override - public void onPut(Integer key, CharSequence value, CharSequence replacedValue) { + public void onPut(Integer key, CharSequence value, CharSequence replacedValue, boolean replicationEvent) { putWasCalled.getAndSet(true); keyRef.set(key); valueRef.set(value); @@ -63,7 +63,7 @@ public class EventListenerWithTCPSocketReplicationTest { } @Override - public void onRemove(Integer key, CharSequence value) { + public void onRemove(Integer key, CharSequence value, boolean replicationEvent) { wasRemoved.set(true); valueRemoved.set(value); } From 938b9dca7b79ceff544a060b4af64832d82eb9c7 Mon Sep 17 00:00:00 2001 From: leventov Date: Sun, 1 Feb 2015 19:49:58 +0700 Subject: [PATCH 6/8] Fixed usages of Bytes.write(Bytes) to conform old semantics --- .../serialization/internal/BasicCopyingMetaBytesInterop.java | 2 +- .../hash/serialization/internal/BytesBytesInterop.java | 2 +- src/main/java/net/openhft/chronicle/map/ChannelProvider.java | 2 +- src/main/java/net/openhft/chronicle/map/NodeDiscovery.java | 2 +- .../net/openhft/chronicle/map/ReplicatedChronicleMap.java | 4 ++-- .../java/net/openhft/chronicle/map/VanillaChronicleMap.java | 2 +- src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java | 3 --- .../java/net/openhft/chronicle/map/DemoChronicleMapTest.java | 1 - .../java/net/openhft/chronicle/map/StatelessClientTest.java | 3 --- 9 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/hash/serialization/internal/BasicCopyingMetaBytesInterop.java b/src/main/java/net/openhft/chronicle/hash/serialization/internal/BasicCopyingMetaBytesInterop.java index 8bdb4412b..c20f5cc96 100644 --- a/src/main/java/net/openhft/chronicle/hash/serialization/internal/BasicCopyingMetaBytesInterop.java +++ b/src/main/java/net/openhft/chronicle/hash/serialization/internal/BasicCopyingMetaBytesInterop.java @@ -65,6 +65,6 @@ public abstract class BasicCopyingMetaBytesInterop implements MetaBytesInt @Override public void write(W writer, Bytes bytes, E e) { - bytes.write(buffer.buffer); + bytes.write(buffer.buffer, buffer.buffer.position(), buffer.buffer.remaining()); } } diff --git a/src/main/java/net/openhft/chronicle/hash/serialization/internal/BytesBytesInterop.java b/src/main/java/net/openhft/chronicle/hash/serialization/internal/BytesBytesInterop.java index 6c5a59174..e482ceb59 100644 --- a/src/main/java/net/openhft/chronicle/hash/serialization/internal/BytesBytesInterop.java +++ b/src/main/java/net/openhft/chronicle/hash/serialization/internal/BytesBytesInterop.java @@ -44,6 +44,6 @@ public enum BytesBytesInterop implements BytesInterop { @Override public void write(Bytes bytes, Bytes e) { - bytes.write(e); + bytes.write(e, e.position(), e.remaining()); } } diff --git a/src/main/java/net/openhft/chronicle/map/ChannelProvider.java b/src/main/java/net/openhft/chronicle/map/ChannelProvider.java index 2b877a3a8..383e1eb2c 100644 --- a/src/main/java/net/openhft/chronicle/map/ChannelProvider.java +++ b/src/main/java/net/openhft/chronicle/map/ChannelProvider.java @@ -504,7 +504,7 @@ final class ChannelProvider implements Closeable { @Override public void writeExternalEntry(@NotNull Bytes entry, @NotNull Bytes destination, int na) { - destination.write(entry); + destination.write(entry, entry.position(), entry.remaining()); } @Override diff --git a/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java b/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java index 137bca57d..893f9a4be 100644 --- a/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java +++ b/src/main/java/net/openhft/chronicle/map/NodeDiscovery.java @@ -755,7 +755,7 @@ class DiscoveryNodeBytesMarshallable implements BytesMarshallable { return false; BOOTSTRAP_BYTES.clear(); - out.write(BOOTSTRAP_BYTES); + out.write(BOOTSTRAP_BYTES, BOOTSTRAP_BYTES.position(), BOOTSTRAP_BYTES.remaining()); ourProposedIdentifier.writeMarshallable(out); return true; diff --git a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java index bb25b3406..d57cdb644 100644 --- a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java @@ -514,7 +514,7 @@ final class ReplicatedChronicleMap, @Override public void write(Void writer, Bytes bytes, Bytes value) { - bytes.write(value); + bytes.write(value, value.position(), value.remaining()); } } diff --git a/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java b/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java index 884d10213..fb68da878 100644 --- a/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java +++ b/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java @@ -480,7 +480,6 @@ public class CHMUseCasesTest { } } - @Ignore @Test public void testStringStringMap() throws ExecutionException, InterruptedException, IOException { @@ -516,7 +515,6 @@ public class CHMUseCasesTest { } - @Ignore @Test public void testStringStringMapMutableValue() throws ExecutionException, InterruptedException, IOException { @@ -2510,7 +2508,6 @@ public class CHMUseCasesTest { } } - @Ignore @Test public void testMapStringIntegerValueWithoutListMarshallers() throws IOException { ChronicleMapBuilder> builder = ChronicleMapBuilder diff --git a/src/test/java/net/openhft/chronicle/map/DemoChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/DemoChronicleMapTest.java index 952d83aa5..fb5013777 100755 --- a/src/test/java/net/openhft/chronicle/map/DemoChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/DemoChronicleMapTest.java @@ -53,7 +53,6 @@ public class DemoChronicleMapTest { } } - @Ignore @Test public void testMapLocked() throws Exception { File file = File.createTempFile("DummyOrders-"+System.currentTimeMillis(), ".test"); diff --git a/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java b/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java index f80823660..a3bf2b922 100644 --- a/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java +++ b/src/test/java/net/openhft/chronicle/map/StatelessClientTest.java @@ -269,7 +269,6 @@ public class StatelessClientTest { } } - @Ignore @Test(timeout = 10000) public void testServerPutStringKeyMap() throws IOException, InterruptedException { @@ -287,7 +286,6 @@ public class StatelessClientTest { } } - @Ignore @Test(timeout = 10000) public void testServerPutClientReplace() throws IOException, InterruptedException { @@ -330,7 +328,6 @@ public class StatelessClientTest { } - @Ignore @Test(timeout = 10000) public void testStringKeyMapPutIfAbsentIntoStatelessMap() throws IOException, InterruptedException { From bec5b2a3c5eabc43f8e8acf501313f3982cba964 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Sun, 1 Feb 2015 22:19:41 +0000 Subject: [PATCH 7/8] introduced NativeBytesI to allow us to checks if the buffer has been closed, if the buffer is accessed after it is closed an exception is thrown, This class should be used to investigate JVM crashes, it should not be used in production code ( as its slow ) --- .../chronicle/map/MultiMapFactory.java | 10 +++---- .../chronicle/map/ReplicatedChronicleMap.java | 14 +++++----- .../chronicle/map/VanillaChronicleMap.java | 28 ++++++++++--------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/MultiMapFactory.java b/src/main/java/net/openhft/chronicle/map/MultiMapFactory.java index ca137ab23..1a615bd24 100644 --- a/src/main/java/net/openhft/chronicle/map/MultiMapFactory.java +++ b/src/main/java/net/openhft/chronicle/map/MultiMapFactory.java @@ -21,7 +21,7 @@ package net.openhft.chronicle.map; import net.openhft.lang.Maths; import net.openhft.lang.collection.ATSDirectBitSet; import net.openhft.lang.io.DirectStore; -import net.openhft.lang.io.NativeBytes; +import net.openhft.lang.io.NativeBytesI; import static net.openhft.lang.Maths.isPowerOf2; import static net.openhft.lang.MemoryUnit.*; @@ -39,7 +39,7 @@ enum MultiMapFactory { } @Override - public MultiMap create(NativeBytes bytes, NativeBytes bitSetBytes) { + public MultiMap create(NativeBytesI bytes, NativeBytesI bitSetBytes) { return new ShortShortMultiMap(bytes, bitSetBytes); } }, @@ -50,7 +50,7 @@ enum MultiMapFactory { } @Override - public MultiMap create(NativeBytes bytes, NativeBytes bitSetBytes) { + public MultiMap create(NativeBytesI bytes, NativeBytesI bitSetBytes) { return new Int24Int24MultiMap(bytes, bitSetBytes); } }, @@ -61,7 +61,7 @@ enum MultiMapFactory { } @Override - public MultiMap create(NativeBytes bytes, NativeBytes bitSetBytes) { + public MultiMap create(NativeBytesI bytes, NativeBytesI bitSetBytes) { return new IntIntMultiMap(bytes, bitSetBytes); } }; @@ -104,5 +104,5 @@ enum MultiMapFactory { public abstract long sizeInBytes(long minCapacity); - public abstract MultiMap create(NativeBytes bytes, NativeBytes bitSetBytes); + public abstract MultiMap create(NativeBytesI bytes, NativeBytesI bitSetBytes); } diff --git a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java index d57cdb644..28c67936d 100644 --- a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java @@ -30,7 +30,7 @@ import net.openhft.lang.Maths; import net.openhft.lang.collection.ATSDirectBitSet; import net.openhft.lang.io.Bytes; import net.openhft.lang.io.MultiStoreBytes; -import net.openhft.lang.io.NativeBytes; +import net.openhft.lang.io.NativeBytesI; import net.openhft.lang.threadlocal.ThreadLocalCopies; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -126,7 +126,7 @@ final class ReplicatedChronicleMap.Segment createSegment( - NativeBytes segmentHeader, NativeBytes bytes, int index) { + NativeBytesI segmentHeader, NativeBytesI bytes, int index) { return new Segment(segmentHeader, bytes, index); } @@ -678,7 +678,7 @@ final class ReplicatedChronicleMap.Segment { - Segment(NativeBytes segmentHeader, NativeBytes bytes, int index) { + Segment(NativeBytesI segmentHeader, NativeBytesI bytes, int index) { super(segmentHeader, bytes, index); } @@ -993,7 +993,7 @@ final class ReplicatedChronicleMap, } final long createMappedStoreAndSegments(BytesStore bytesStore) throws IOException { - this.ms = bytesStore; + // checks the the store has not been closed + // todo remove the CheckedBytesStore before the release + this.ms = new CheckedBytesStore(bytesStore); onHeaderCreated(); @@ -242,9 +244,9 @@ class VanillaChronicleMap, long segmentSize = segmentSize(); long headerOffset = 0; for (int i = 0; i < this.segments.length; i++) { - NativeBytes segmentHeader = - (NativeBytes) segmentHeaders.bytes(headerOffset, segmentHeaderSize); - NativeBytes segmentData = (NativeBytes) ms.bytes(offset, segmentSize); + NativeBytesI segmentHeader = + (NativeBytesI) segmentHeaders.bytes(headerOffset, segmentHeaderSize); + NativeBytesI segmentData = (NativeBytesI) ms.bytes(offset, segmentSize); this.segments[i] = createSegment(segmentHeader, segmentData, i); headerOffset += segmentHeaderSize; offset += segmentSize; @@ -306,7 +308,7 @@ class VanillaChronicleMap, return segmentHeaderSize; } - Segment createSegment(NativeBytes segmentHeader, NativeBytes bytes, int index) { + Segment createSegment(NativeBytesI segmentHeader, NativeBytesI bytes, int index) { return new Segment(segmentHeader, bytes, index); } @@ -1411,8 +1413,8 @@ class VanillaChronicleMap, */ static final long LOCK_OFFSET = 0L; // 64-bit static final long SIZE_OFFSET = LOCK_OFFSET + 8L; // 32-bit - final NativeBytes segmentHeader; - final NativeBytes bytes; + final NativeBytesI segmentHeader; + final NativeBytesI bytes; final long entriesOffset; private final int index; private final SingleThreadedDirectBitSet freeList; @@ -1426,7 +1428,7 @@ class VanillaChronicleMap, /** * @param index the index of this segment held by the map */ - Segment(NativeBytes segmentHeader, NativeBytes bytes, int index) { + Segment(NativeBytesI segmentHeader, NativeBytesI bytes, int index) { this.segmentHeader = segmentHeader; this.bytes = bytes; this.index = index; @@ -1435,7 +1437,7 @@ class VanillaChronicleMap, hashLookup = createMultiMap(start); start += CACHE_LINES.align(sizeOfMultiMap() + sizeOfMultiMapBitSet(), BYTES) * multiMapsPerSegment(); - final NativeBytes bsBytes = new NativeBytes(ms.objectSerializer(), + final NativeBytesI bsBytes = new NativeBytes(ms.objectSerializer(), start, start + MultiMapFactory.sizeOfBitSetInBytes(actualChunksPerSegment), null); @@ -1453,11 +1455,11 @@ class VanillaChronicleMap, } private MultiMap createMultiMap(long start) { - final NativeBytes multiMapBytes = + final NativeBytesI multiMapBytes = new NativeBytes((ObjectSerializer) null, start, start = start + sizeOfMultiMap(), null); - final NativeBytes sizeOfMultiMapBitSetBytes = + final NativeBytesI sizeOfMultiMapBitSetBytes = new NativeBytes((ObjectSerializer) null, start, start + sizeOfMultiMapBitSet(), null); // multiMapBytes.load(); @@ -2574,7 +2576,7 @@ class VanillaChronicleMap, // of returnedEntry.getKey(), but it seems rather wasteful to workaround so rare // case. final long offset = segment.offsetFromPos(pos); - final NativeBytes entry = segment.reuse(this.entry, offset); + final NativeBytesI entry = segment.reuse(this.entry, offset); final long keySize = keySizeMarshaller.readSize(entry); long position = entry.position(); @@ -2583,7 +2585,7 @@ class VanillaChronicleMap, removePresent(segment, pos, entry, keySize, segmentHash, true); } - final void removePresent(Segment segment, long pos, NativeBytes entry, long keySize, + final void removePresent(Segment segment, long pos, NativeBytesI entry, long keySize, long segmentHash, boolean removeFromMultiMap) { entry.skip(keySize); segment.manageReplicationBytes(entry, true, true); From 4f9892636cb59533349b1f95a906b68e32f06a89 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Sun, 1 Feb 2015 22:56:17 +0000 Subject: [PATCH 8/8] corrected message - LOG.info("Thread took " + lockTime / 1000000 + "ms to release the lock, (Was there a GC?)"); --- .../java/net/openhft/chronicle/map/VanillaChronicleMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java index f876e35d7..3f8772856 100755 --- a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java @@ -1630,7 +1630,7 @@ class VanillaChronicleMap, if (lockTime > 1e8 && LOG.isInfoEnabled()) - LOG.info("Thread took %,d ms to release lock%n", lockTime / 1000000 + "(Was there a GC?)"); + LOG.info("Thread took " + lockTime / 1000000 + "ms to release the lock, (Was there a GC?)"); } @Override