diff --git a/docs/CM_FAQs.adoc b/docs/CM_FAQs.adoc index 0029907d8..c890c8e3c 100755 --- a/docs/CM_FAQs.adoc +++ b/docs/CM_FAQs.adoc @@ -40,13 +40,11 @@ Does Chronicle Map work by using Memory Mapped Files? ===== Answer Yes; Chronicle Map uses memory mapped files see https://en.wikipedia.org/wiki/Memory-mapped_file. This works the same way on both Linux and Windows. - == Is there a difference in performance between Linux and Windows systems? ===== Question Is there a difference in performance between Linux and Windows systems? - ===== Answer The same code is run on both Windows and Linux. However, we encourage all our clients to use Linux, as it has improved handling of memory mapped files over Windows. @@ -80,6 +78,5 @@ For Chronicle Map, it is somewhat more complicated because Chronicle Map reads a It follows that if you have quite a few maps, especially large maps, and your page cache is not large enough to hold all of these maps, then a read, or write, to a random entry may cause a cache miss. This in turn would cause a disk read or write. If you were going to install high-speed SSDs, Chronicle recommends that you use them to store the Chronicle maps and leave the slower cheap disks for the Chronicle queues. In addition, you should avoid using network attached storage, as this usually offers worst performance than local disks. - ''' <<../ReadMe.adoc#,Back to ReadMe>> diff --git a/docs/CM_Replication.adoc b/docs/CM_Replication.adoc index f96fbc350..a41c44058 100755 --- a/docs/CM_Replication.adoc +++ b/docs/CM_Replication.adoc @@ -164,7 +164,6 @@ try (ReplicatedMap clusterOnHost1 = createCluster(CLUSTER_YAML, 1); } .... - This example is available in the repository https://github.com/ChronicleEnterprise/Chronicle-Map-Enterprise-Demo/blob/master/Example1/src/main/java/software/chronicle/enterprise/map/ThreeWayMapReplicationExampleMain.java[here] == Replication event logging diff --git a/src/main/java/net/openhft/chronicle/hash/impl/VanillaChronicleHash.java b/src/main/java/net/openhft/chronicle/hash/impl/VanillaChronicleHash.java index 5ec3561c0..ebbfd9a63 100755 --- a/src/main/java/net/openhft/chronicle/hash/impl/VanillaChronicleHash.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/VanillaChronicleHash.java @@ -239,7 +239,8 @@ public abstract class VanillaChronicleHash 0; + + return globalMutableState.getAllocatedExtraTierBulks() > 0; } @Override public long offHeapMemoryUsed() { throwExceptionIfClosed(); - return resources.totalMemory(); + + return resources.totalMemory(); } public long allocateTier() { throwExceptionIfClosed(); - globalMutableStateLock(); + + globalMutableStateLock(); try { long tiersInUse = globalMutableState.getExtraTiersInUse(); if (tiersInUse >= maxExtraTiers) { @@ -856,7 +873,8 @@ public abstract class VanillaChronicleHash> allContexts() { throwExceptionIfClosed(); - return Collections.unmodifiableList(resources.contexts()); + + return Collections.unmodifiableList(resources.contexts()); } public static class TierBulkData { @@ -1083,7 +1108,8 @@ public abstract class VanillaChronicleHash> public long tierEntriesForIteration() { throwExceptionIfClosed(); - return s.tierEntries(); + + return s.tierEntries(); } abstract boolean entryRemovedOnThisIterationInit(); @@ -69,7 +70,8 @@ public abstract class HashSegmentIteration> public void initHashLookupEntry(long entry) { throwExceptionIfClosed(); - hashLookupEntry = entry; + + hashLookupEntry = entry; } abstract void closeHashLookupEntry(); @@ -77,7 +79,8 @@ public abstract class HashSegmentIteration> @Override public boolean forEachSegmentEntryWhile(Predicate predicate) { throwExceptionIfClosed(); - checkOnEachPublicOperation.checkOnEachPublicOperation(); + + checkOnEachPublicOperation.checkOnEachPublicOperation(); s.innerUpdateLock.lock(); return innerForEachSegmentEntryWhile(predicate); } @@ -178,12 +181,14 @@ public abstract class HashSegmentIteration> public void hookAfterEachIteration() { throwExceptionIfClosed(); - } + + } @Override public void forEachSegmentEntry(Consumer action) { throwExceptionIfClosed(); - forEachSegmentEntryWhile(e -> { + + forEachSegmentEntryWhile(e -> { action.accept(e); return true; }); @@ -191,7 +196,8 @@ public abstract class HashSegmentIteration> public void checkEntryNotRemovedOnThisIteration() { throwExceptionIfClosed(); - if (entryRemovedOnThisIterationInit()) { + + if (entryRemovedOnThisIterationInit()) { throw new IllegalStateException( hh.h().toIdentityString() + ": Entry was already removed on this iteration"); } @@ -200,7 +206,8 @@ public abstract class HashSegmentIteration> @Override public void doRemove() { throwExceptionIfClosed(); - checkOnEachPublicOperation.checkOnEachPublicOperation(); + + checkOnEachPublicOperation.checkOnEachPublicOperation(); s.innerWriteLock.lock(); try { iterationRemove(); @@ -212,7 +219,8 @@ public abstract class HashSegmentIteration> public void iterationRemove() { throwExceptionIfClosed(); - // this condition mean -- some other entry taken place of the removed one + + // this condition mean -- some other entry taken place of the removed one if (hh.h().hashLookup.remove(s.tierBaseAddr, hlp.hashLookupPos) != hlp.hashLookupPos) { // if so, should make step back, to compensate step forward on the next iteration, // to consume the shifted entry diff --git a/src/main/java/net/openhft/chronicle/hash/impl/stage/iter/SegmentsRecovery.java b/src/main/java/net/openhft/chronicle/hash/impl/stage/iter/SegmentsRecovery.java index 920ea52a7..a987cf71c 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/stage/iter/SegmentsRecovery.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/stage/iter/SegmentsRecovery.java @@ -45,7 +45,8 @@ public abstract class SegmentsRecovery implements IterationContext { ChronicleHashCorruption.Listener corruptionListener, ChronicleHashCorruptionImpl corruption) { throwExceptionIfClosed(); - VanillaChronicleHash h = hh.h(); + + VanillaChronicleHash h = hh.h(); for (int segmentIndex = 0; segmentIndex < h.actualSegments; segmentIndex++) { s.initSegmentIndex(segmentIndex); resetSegmentLock(corruptionListener, corruption); diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java index e7e7d81b8..7596127cc 100755 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java @@ -330,8 +330,7 @@ public final class ChronicleMapBuilder implements return valueBuilder.sizeIsStaticallyKnown; } - - private static void checkSegments(long segments) { +private static void checkSegments(long segments) { if (segments <= 0) { throw new IllegalArgumentException("segments should be positive, " + segments + " given"); diff --git a/src/main/java/net/openhft/chronicle/map/OldDeletedEntriesCleanupThread.java b/src/main/java/net/openhft/chronicle/map/OldDeletedEntriesCleanupThread.java index 6c2fbb4b9..af47f9976 100644 --- a/src/main/java/net/openhft/chronicle/map/OldDeletedEntriesCleanupThread.java +++ b/src/main/java/net/openhft/chronicle/map/OldDeletedEntriesCleanupThread.java @@ -115,7 +115,8 @@ class OldDeletedEntriesCleanupThread extends Thread @Override public void run() { throwExceptionIfClosed(); - if (System.currentTimeMillis() - startTime < 1_000) + + if (System.currentTimeMillis() - startTime < 1_000) return; while (!shutdown) { @@ -177,7 +178,8 @@ class OldDeletedEntriesCleanupThread extends Thread @Override public boolean test(ReplicableEntry e) { throwExceptionIfClosed(); - if (shutdown) + + if (shutdown) return false; if (e instanceof MapAbsentEntry) { long deleteTimeout = systemTimeIntervalBetween( diff --git a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java index 16fce38eb..cc004d1c6 100644 --- a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java @@ -173,13 +173,15 @@ public class ReplicatedChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap raise change for all + + // -1 is invalid remoteIdentifier => raise change for all changeCount.incrementAndGet(); raiseChangeForAllExcept(tierIndex, pos, (byte) -1); } public void raiseChangeFor(long tierIndex, long pos, byte remoteIdentifier) { throwExceptionIfClosed(); - acquireModificationIterator(remoteIdentifier).raiseChange0(tierIndex, pos); + + acquireModificationIterator(remoteIdentifier).raiseChange0(tierIndex, pos); } public void raiseChangeForAllExcept(long tierIndex, long pos, byte remoteIdentifier) { throwExceptionIfClosed(); - updateModificationIteratorsArray(); + + updateModificationIteratorsArray(); if (tierIndex <= actualSegments) { long segmentIndex = tierIndex - 1; long offsetToTierBitSet = segmentIndex * tierModIterBitSetOuterSize; @@ -390,7 +403,8 @@ public class ReplicatedChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap keys) { throwExceptionIfClosed(); - if (payload != null) + + if (payload != null) writePayload(payload, destination); if (entry != null) writeExternalEntry0(entry, destination, keys); @@ -594,7 +613,8 @@ public class ReplicatedChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap * Once a change occurs to a map, map replication requires that these changes are picked up * by another thread, this class provides an iterator like interface to poll for such changes. @@ -705,7 +723,8 @@ public class ReplicatedChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap c = iterationContext()) { + + try (CompiledReplicatedMapIterationContext c = iterationContext()) { // iterate over all the segments and mark bit in the modification iterator // that correspond to entries with an older timestamp boolean debugEnabled = LOG.isDebugEnabled(); @@ -962,7 +984,8 @@ public class ReplicatedChronicleMap extends VanillaChronicleMap @Override public void initTransients() { throwExceptionIfClosed(); - super.initTransients(); + + super.initTransients(); initOwnTransients(); } @@ -171,7 +172,8 @@ public class VanillaChronicleMap ChronicleHashResources resources, ChronicleHashCorruption.Listener corruptionListener, ChronicleHashCorruptionImpl corruption) throws IOException { throwExceptionIfClosed(); - basicRecover(resources, corruptionListener, corruption); + + basicRecover(resources, corruptionListener, corruption); try (IterationContext iterationContext = iterationContext()) { iterationContext.recoverSegments(corruptionListener, corruption); } @@ -216,25 +218,29 @@ public class VanillaChronicleMap @Override public Class keyClass() { throwExceptionIfClosed(); - return (Class) keyClass; + + return (Class) keyClass; } @Override public Type keyType() { throwExceptionIfClosed(); - return keyClass; + + return keyClass; } @Override public Class valueClass() { throwExceptionIfClosed(); - return (Class) valueClass; + + return (Class) valueClass; } @Override public Type valueType() { throwExceptionIfClosed(); - return valueClass; + + return valueClass; } private long tiersUsed() { @@ -248,14 +254,15 @@ public class VanillaChronicleMap @Override public int remainingAutoResizes() { throwExceptionIfClosed(); - return (int) (maxTiers() - tiersUsed()); + + return (int) (maxTiers() - tiersUsed()); } @Override public short percentageFreeSpace() { throwExceptionIfClosed(); - double totalUsed = 0; + double totalUsed = 0; double totalSize = 0; try (IterationContext c = iterationContext()) { @@ -320,13 +327,15 @@ public class VanillaChronicleMap @Override public int hashCode() { throwExceptionIfClosed(); - return mapHashCode(); + + return mapHashCode(); } @Override public boolean equals(Object obj) { throwExceptionIfClosed(); - return mapEquals(obj); + + return mapEquals(obj); } @Override @@ -342,7 +351,8 @@ public class VanillaChronicleMap @Override public String toIdentityString() { throwExceptionIfClosed(); - if (identityString == null) + + if (identityString == null) identityString = makeIdentityString(); return identityString; } @@ -360,7 +370,8 @@ public class VanillaChronicleMap @Override public void clear() { throwExceptionIfClosed(); - forEachEntry(c -> c.context().remove(c)); + + forEachEntry(c -> c.context().remove(c)); } public final long readValueSize(Bytes entry) { @@ -371,7 +382,8 @@ public class VanillaChronicleMap public void alignReadPosition(Bytes entry) { throwExceptionIfClosed(); - long positionAddr = entry.addressForRead(entry.readPosition()); + + long positionAddr = entry.addressForRead(entry.readPosition()); long skip = alignAddr(positionAddr, alignment) - positionAddr; if (skip > 0) entry.readSkip(skip); @@ -535,7 +547,8 @@ public class VanillaChronicleMap @Override public V get(Object key) { throwExceptionIfClosed(); - return defaultEntryOperationsAndMethods ? optimizedGet(key, null) : defaultGet(key); + + return defaultEntryOperationsAndMethods ? optimizedGet(key, null) : defaultGet(key); } final V defaultGet(Object key) { @@ -709,7 +722,8 @@ public class VanillaChronicleMap @Override public V getUsing(K key, V usingValue) { throwExceptionIfClosed(); - return defaultEntryOperationsAndMethods ? optimizedGet(key, usingValue) : + + return defaultEntryOperationsAndMethods ? optimizedGet(key, usingValue) : defaultGetUsing(key, usingValue); } @@ -724,7 +738,8 @@ public class VanillaChronicleMap @Override public V acquireUsing(K key, V usingValue) { throwExceptionIfClosed(); - try (QueryContextInterface q = queryContext(key)) { + + try (QueryContextInterface q = queryContext(key)) { return acquireUsingBody(q, usingValue); } } @@ -738,7 +753,8 @@ public class VanillaChronicleMap @Override public V putIfAbsent(K key, V value) { throwExceptionIfClosed(); - checkValue(value); + + checkValue(value); try (QueryContextInterface q = queryContext(key)) { methods.putIfAbsent(q, q.inputValueDataAccess().getData(value), q.defaultReturnValue()); return q.defaultReturnValue().returnValue(); @@ -748,7 +764,8 @@ public class VanillaChronicleMap @Override public boolean remove(Object key, Object value) { throwExceptionIfClosed(); - if (value == null) + + if (value == null) return false; // ConcurrentHashMap compatibility V v = checkValue(value); try (QueryContextInterface q = queryContext(key)) { @@ -759,7 +776,8 @@ public class VanillaChronicleMap @Override public boolean replace(K key, V oldValue, V newValue) { throwExceptionIfClosed(); - checkValue(oldValue); + + checkValue(oldValue); checkValue(newValue); try (QueryContextInterface q = queryContext(key)) { return methods.replace( @@ -770,7 +788,8 @@ public class VanillaChronicleMap @Override public V replace(K key, V value) { throwExceptionIfClosed(); - checkValue(value); + + checkValue(value); try (QueryContextInterface q = queryContext(key)) { methods.replace(q, q.inputValueDataAccess().getData(value), q.defaultReturnValue()); return q.defaultReturnValue().returnValue(); @@ -780,7 +799,8 @@ public class VanillaChronicleMap @Override public boolean containsKey(Object key) { throwExceptionIfClosed(); - try (QueryContextInterface q = queryContext(key)) { + + try (QueryContextInterface q = queryContext(key)) { return methods.containsKey(q); } } @@ -788,7 +808,8 @@ public class VanillaChronicleMap @Override public V put(K key, V value) { throwExceptionIfClosed(); - checkValue(value); + + checkValue(value); try (QueryContextInterface q = queryContext(key)) { Data valueData = q.inputValueDataAccess().getData(value); InstanceReturnValue returnValue = @@ -801,7 +822,8 @@ public class VanillaChronicleMap @Override public V remove(Object key) { throwExceptionIfClosed(); - try (QueryContextInterface q = queryContext(key)) { + + try (QueryContextInterface q = queryContext(key)) { InstanceReturnValue returnValue = removeReturnsNull ? NullReturnValue.get() : q.defaultReturnValue(); methods.remove(q, returnValue); @@ -813,7 +835,8 @@ public class VanillaChronicleMap public V merge(K key, V value, BiFunction remappingFunction) { throwExceptionIfClosed(); - try (QueryContextInterface q = queryContext(key)) { + + try (QueryContextInterface q = queryContext(key)) { methods.merge(q, q.inputValueDataAccess().getData(value), remappingFunction, q.defaultReturnValue()); return q.defaultReturnValue().returnValue(); @@ -823,7 +846,8 @@ public class VanillaChronicleMap @Override public V compute(K key, BiFunction remappingFunction) { throwExceptionIfClosed(); - try (QueryContextInterface q = queryContext(key)) { + + try (QueryContextInterface q = queryContext(key)) { methods.compute(q, remappingFunction, q.defaultReturnValue()); return q.defaultReturnValue().returnValue(); } @@ -832,7 +856,8 @@ public class VanillaChronicleMap @Override public V computeIfAbsent(K key, Function mappingFunction) { throwExceptionIfClosed(); - try (QueryContextInterface q = queryContext(key)) { + + try (QueryContextInterface q = queryContext(key)) { methods.computeIfAbsent(q, mappingFunction, q.defaultReturnValue()); return q.defaultReturnValue().returnValue(); } @@ -842,7 +867,8 @@ public class VanillaChronicleMap public V computeIfPresent(K key, BiFunction remappingFunction) { throwExceptionIfClosed(); - try (QueryContextInterface q = queryContext(key)) { + + try (QueryContextInterface q = queryContext(key)) { methods.computeIfPresent(q, remappingFunction, q.defaultReturnValue()); return q.defaultReturnValue().returnValue(); } @@ -850,7 +876,8 @@ public class VanillaChronicleMap public void verifyTierCountersAreaData() { throwExceptionIfClosed(); - for (int i = 0; i < actualSegments; i++) { + + for (int i = 0; i < actualSegments; i++) { try (MapSegmentContext c = segmentContext(i)) { Method verifyTierCountersAreaData = c.getClass().getMethod("verifyTierCountersAreaData"); diff --git a/src/main/java/net/openhft/chronicle/map/impl/stage/data/ZeroBytesStore.java b/src/main/java/net/openhft/chronicle/map/impl/stage/data/ZeroBytesStore.java index 966606fd3..655b3a8b5 100755 --- a/src/main/java/net/openhft/chronicle/map/impl/stage/data/ZeroBytesStore.java +++ b/src/main/java/net/openhft/chronicle/map/impl/stage/data/ZeroBytesStore.java @@ -38,8 +38,7 @@ public enum ZeroBytesStore implements BytesStore { throw new UnsupportedOperationException("Cannot get the address of nothing"); } - - @Override +@Override public int peekUnsignedByte(long offset) { return 0; } @@ -157,8 +156,7 @@ public enum ZeroBytesStore implements BytesStore { return true; } - - @Override +@Override public void reserve(ReferenceOwner id) throws IllegalStateException { } diff --git a/src/main/java/net/openhft/chronicle/map/impl/stage/iter/MapSegmentIteration.java b/src/main/java/net/openhft/chronicle/map/impl/stage/iter/MapSegmentIteration.java index 72540a242..fab7faa66 100644 --- a/src/main/java/net/openhft/chronicle/map/impl/stage/iter/MapSegmentIteration.java +++ b/src/main/java/net/openhft/chronicle/map/impl/stage/iter/MapSegmentIteration.java @@ -41,13 +41,15 @@ public abstract class MapSegmentIteration extends HashSegmentIteration< @Override public void hookAfterEachIteration() { throwExceptionIfClosed(); - wrappedValueInstanceDataHolder.closeValue(); + + wrappedValueInstanceDataHolder.closeValue(); } @Override public void doReplaceValue(Data newValue) { throwExceptionIfClosed(); - checkOnEachPublicOperation.checkOnEachPublicOperation(); + + checkOnEachPublicOperation.checkOnEachPublicOperation(); try { entry.innerDefaultReplaceValue(newValue); } finally { diff --git a/src/main/java/net/openhft/chronicle/map/impl/stage/iter/ReplicatedMapSegmentIteration.java b/src/main/java/net/openhft/chronicle/map/impl/stage/iter/ReplicatedMapSegmentIteration.java index d4c5c5f1a..584a1748a 100644 --- a/src/main/java/net/openhft/chronicle/map/impl/stage/iter/ReplicatedMapSegmentIteration.java +++ b/src/main/java/net/openhft/chronicle/map/impl/stage/iter/ReplicatedMapSegmentIteration.java @@ -61,25 +61,29 @@ public abstract class ReplicatedMapSegmentIteration extends MapSegmentI @Override public boolean shouldTestEntry() { throwExceptionIfClosed(); - return entriesToTest == ALL || !e.entryDeleted(); + + return entriesToTest == ALL || !e.entryDeleted(); } @Override public Object entryForIteration() { throwExceptionIfClosed(); - return !e.entryDeleted() ? entryDelegating : absentEntryDelegating; + + return !e.entryDeleted() ? entryDelegating : absentEntryDelegating; } @Override public long tierEntriesForIteration() { throwExceptionIfClosed(); - return entriesToTest == ALL ? s.tierEntries() : s.tierEntries() - s.tierDeleted(); + + return entriesToTest == ALL ? s.tierEntries() : s.tierEntries() - s.tierDeleted(); } @Override public void doReplaceValue(Data newValue) { throwExceptionIfClosed(); - checkOnEachPublicOperation.checkOnEachPublicOperation(); + + checkOnEachPublicOperation.checkOnEachPublicOperation(); try { entry.innerDefaultReplaceValue(newValue); e.updatedReplicationStateOnPresentEntry(); @@ -92,7 +96,8 @@ public abstract class ReplicatedMapSegmentIteration extends MapSegmentI @Override public boolean forEachSegmentEntryWhile(Predicate> predicate) { throwExceptionIfClosed(); - checkOnEachPublicOperation.checkOnEachPublicOperation(); + + checkOnEachPublicOperation.checkOnEachPublicOperation(); initEntriesToTest(PRESENT); s.innerUpdateLock.lock(); return innerForEachSegmentEntryWhile(predicate); @@ -102,7 +107,8 @@ public abstract class ReplicatedMapSegmentIteration extends MapSegmentI public boolean forEachSegmentReplicableEntryWhile( Predicate predicate) { throwExceptionIfClosed(); - checkOnEachPublicOperation.checkOnEachPublicOperation(); + + checkOnEachPublicOperation.checkOnEachPublicOperation(); initEntriesToTest(ALL); s.innerUpdateLock.lock(); return innerForEachSegmentEntryWhile(predicate); @@ -111,7 +117,8 @@ public abstract class ReplicatedMapSegmentIteration extends MapSegmentI @Override public void forEachSegmentReplicableEntry(Consumer action) { throwExceptionIfClosed(); - forEachSegmentReplicableEntryWhile(e -> { + + forEachSegmentReplicableEntryWhile(e -> { action.accept(e); return true; }); @@ -120,7 +127,8 @@ public abstract class ReplicatedMapSegmentIteration extends MapSegmentI @Override public void doRemove() { throwExceptionIfClosed(); - checkOnEachPublicOperation.checkOnEachPublicOperation(); + + checkOnEachPublicOperation.checkOnEachPublicOperation(); try { if (e.valueSize > dummyValue.size()) e.innerDefaultReplaceValue(dummyValue); @@ -137,7 +145,8 @@ public abstract class ReplicatedMapSegmentIteration extends MapSegmentI @Override public void doRemoveCompletely() { throwExceptionIfClosed(); - boolean wasDeleted = e.entryDeleted(); + + boolean wasDeleted = e.entryDeleted(); super.doRemove(); ru.dropChange(); if (wasDeleted) @@ -146,7 +155,8 @@ public abstract class ReplicatedMapSegmentIteration extends MapSegmentI public void doInsert(Data value) { throwExceptionIfClosed(); - checkOnEachPublicOperation.checkOnEachPublicOperation(); + + checkOnEachPublicOperation.checkOnEachPublicOperation(); if (e.entryDeleted()) { try { s.tierDeleted(s.tierDeleted() - 1); @@ -166,7 +176,8 @@ public abstract class ReplicatedMapSegmentIteration extends MapSegmentI public void doInsert() { throwExceptionIfClosed(); - if (mh.set() == null) + + if (mh.set() == null) throw new IllegalStateException(mh.h().toIdentityString() + ": Called SetAbsentEntry.doInsert() from Map context"); doInsert((Data) DummyValueData.INSTANCE); diff --git a/src/main/java/net/openhft/chronicle/set/SetFromMap.java b/src/main/java/net/openhft/chronicle/set/SetFromMap.java index 2e5bf508d..edadc8f7a 100644 --- a/src/main/java/net/openhft/chronicle/set/SetFromMap.java +++ b/src/main/java/net/openhft/chronicle/set/SetFromMap.java @@ -52,42 +52,50 @@ class SetFromMap extends AbstractSet implements ChronicleSet { public void clear() { throwExceptionIfClosed(); - m.clear(); + + m.clear(); } public int size() { throwExceptionIfClosed(); - return m.size(); + + return m.size(); } public boolean isEmpty() { throwExceptionIfClosed(); - return m.isEmpty(); + + return m.isEmpty(); } public boolean contains(Object o) { throwExceptionIfClosed(); - return m.containsKey(o); + + return m.containsKey(o); } public boolean remove(Object o) { throwExceptionIfClosed(); - return m.remove(o, DUMMY_VALUE); + + return m.remove(o, DUMMY_VALUE); } public boolean add(E e) { throwExceptionIfClosed(); - return m.putIfAbsent(e, DUMMY_VALUE) == null; + + return m.putIfAbsent(e, DUMMY_VALUE) == null; } public Iterator iterator() { throwExceptionIfClosed(); - return s.iterator(); + + return s.iterator(); } public Object[] toArray() { throwExceptionIfClosed(); - return s.toArray(); + + return s.toArray(); } public T[] toArray(T[] a) { @@ -101,7 +109,8 @@ class SetFromMap extends AbstractSet implements ChronicleSet { @Override public String toIdentityString() { throwExceptionIfClosed(); - return "ChronicleSet{" + + + return "ChronicleSet{" + "name=" + name() + ", file=" + file() + ", identityHashCode=" + System.identityHashCode(this) + @@ -110,52 +119,61 @@ class SetFromMap extends AbstractSet implements ChronicleSet { public int hashCode() { throwExceptionIfClosed(); - return s.hashCode(); + + return s.hashCode(); } public boolean equals(Object o) { throwExceptionIfClosed(); - return o == this || s.equals(o); + + return o == this || s.equals(o); } public boolean containsAll(Collection c) { throwExceptionIfClosed(); - return s.containsAll(c); + + return s.containsAll(c); } public boolean removeAll(Collection c) { throwExceptionIfClosed(); - return s.removeAll(c); + + return s.removeAll(c); } public boolean retainAll(Collection c) { throwExceptionIfClosed(); - return s.retainAll(c); + + return s.retainAll(c); } // addAll is the only inherited implementation @Override public long longSize() { throwExceptionIfClosed(); - return m.longSize(); + + return m.longSize(); } @Override public long offHeapMemoryUsed() { throwExceptionIfClosed(); - return m.offHeapMemoryUsed(); + + return m.offHeapMemoryUsed(); } @Override public Class keyClass() { throwExceptionIfClosed(); - return m.keyClass(); + + return m.keyClass(); } @Override public Type keyType() { throwExceptionIfClosed(); - return m.keyType(); + + return m.keyType(); } // TODO test queryContext methods @@ -190,7 +208,8 @@ class SetFromMap extends AbstractSet implements ChronicleSet { @Override public int segments() { throwExceptionIfClosed(); - return m.segments(); + + return m.segments(); } // TODO test forEach methods @@ -198,27 +217,31 @@ class SetFromMap extends AbstractSet implements ChronicleSet { @Override public boolean forEachEntryWhile(Predicate> predicate) { throwExceptionIfClosed(); - Objects.requireNonNull(predicate); + + Objects.requireNonNull(predicate); return m.forEachEntryWhile(e -> predicate.test(((SetEntry) e))); } @Override public void forEachEntry(Consumer> action) { throwExceptionIfClosed(); - Objects.requireNonNull(action); + + Objects.requireNonNull(action); m.forEachEntry(e -> action.accept(((SetEntry) e))); } @Override public File file() { throwExceptionIfClosed(); - return m.file(); + + return m.file(); } @Override public String name() { throwExceptionIfClosed(); - return m.name(); + + return m.name(); } @Override @@ -229,6 +252,7 @@ class SetFromMap extends AbstractSet implements ChronicleSet { @Override public boolean isOpen() { throwExceptionIfClosed(); - return m.isOpen(); + + return m.isOpen(); } } diff --git a/src/test/java/net/openhft/chronicle/map/perf/MapStress.java b/src/test/java/net/openhft/chronicle/map/perf/MapStress.java index 7ad0a06a5..55e478d3b 100644 --- a/src/test/java/net/openhft/chronicle/map/perf/MapStress.java +++ b/src/test/java/net/openhft/chronicle/map/perf/MapStress.java @@ -91,8 +91,7 @@ public class MapStress { secs[4].securityUltimateUnderlyingTicker = "RTYU"; secs[4].securityUnderlyingTicker = "RTYU"; - - Future[] futures = new Future[N_WRITE_THREADS + N_READ_THREADS]; +Future[] futures = new Future[N_WRITE_THREADS + N_READ_THREADS]; for (int i = 0; i < N_WRITE_THREADS; i++) { String id = i + " -> "; futures[i] = executor.submit(() -> { diff --git a/src/test/java/net/openhft/chronicle/map/watcher/MapFileManager.java b/src/test/java/net/openhft/chronicle/map/watcher/MapFileManager.java index 63fc2c33c..766b03fd3 100755 --- a/src/test/java/net/openhft/chronicle/map/watcher/MapFileManager.java +++ b/src/test/java/net/openhft/chronicle/map/watcher/MapFileManager.java @@ -104,8 +104,7 @@ public class MapFileManager extends JMXFileManager implements MapFileManagerMBea map.createMappedStoreAndSegments( new PersistedChronicleHashResources(file)); - - keyClass = map.keyType(); +keyClass = map.keyType(); valueClass = map.valueType(); size = map.longSize(); name = map.name();