diff --git a/src/main/java/net/openhft/chronicle/hash/ChronicleFileLockException.java b/src/main/java/net/openhft/chronicle/hash/ChronicleFileLockException.java index cd560c71f..b1a33aab1 100644 --- a/src/main/java/net/openhft/chronicle/hash/ChronicleFileLockException.java +++ b/src/main/java/net/openhft/chronicle/hash/ChronicleFileLockException.java @@ -18,7 +18,6 @@ package net.openhft.chronicle.hash; /** * This exception is thrown, when a Chronicle Hash cannot acquire a required file lock. - * */ public final class ChronicleFileLockException extends RuntimeException { private static final long serialVersionUID = -2034623786298623984L; diff --git a/src/main/java/net/openhft/chronicle/hash/ChronicleHashBuilder.java b/src/main/java/net/openhft/chronicle/hash/ChronicleHashBuilder.java index 752b1913e..b1585f990 100755 --- a/src/main/java/net/openhft/chronicle/hash/ChronicleHashBuilder.java +++ b/src/main/java/net/openhft/chronicle/hash/ChronicleHashBuilder.java @@ -555,7 +555,7 @@ public interface ChronicleHashBuilder, * provided {@code file} during recovery across all JVMs/threads/processes or else * the behavior is unspecified including the possibility that the Map file gets * completely corrupted and/or is silently returning stale or otherwise erroneous data. - * + *

* Chronicle Map employs a best-effort to ensure file exclusivity during recovery operations. * However, these efforts may not be applicable for all platforms and/or situations. Ultimately, * the user is responsible for ensuring absolute exclusivity. @@ -590,7 +590,7 @@ public interface ChronicleHashBuilder, * provided {@code file} during recovery across all JVMs/threads/processes or else * the behavior is unspecified including the possibility that the Map file gets * completely corrupted and/or is silently returning stale or otherwise erroneous data. - * + *

* Chronicle Map employs a best-effort to ensure file exclusivity during recovery operations. * However, these efforts may not be applicable for all platforms and/or situations. Ultimately, * the user is responsible for ensuring absolute exclusivity. @@ -630,7 +630,7 @@ public interface ChronicleHashBuilder, * provided {@code file} during recovery across all JVMs/threads/processes or else * the behavior is unspecified including the possibility that the Map file gets * completely corrupted and/or is silently returning stale or otherwise erroneous data. - * + *

* Chronicle Map employs a best-effort to ensure file exclusivity during recovery operations. * However, these efforts may not be applicable for all platforms and/or situations. Ultimately, * the user is responsible for ensuring absolute exclusivity. @@ -701,7 +701,7 @@ public interface ChronicleHashBuilder, * provided {@code file} during recovery across all JVMs/threads/processes or else * the behavior is unspecified including the possibility that the Map file gets * completely corrupted and/or is silently returning stale or otherwise erroneous data. - * + *

* Chronicle Map employs a best-effort to ensure file exclusivity during recovery operations. * However, these efforts may not be applicable for all platforms and/or situations. Ultimately, * the user is responsible for ensuring absolute exclusivity. @@ -763,11 +763,12 @@ public interface ChronicleHashBuilder, * provided {@code file} during recovery across all JVMs/threads/processes or else * the behavior is unspecified including the possibility that the Map file gets * completely corrupted and/or is silently returning stale or otherwise erroneous data. - * + *

* Chronicle Map employs a best-effort to ensure file exclusivity during recovery operations. * However, these efforts may not be applicable for all platforms and/or situations. Ultimately, * the user is responsible for ensuring absolute exclusivity. *

+ * * @param file a hash container was mapped to the given file * @param sameBuilderConfigAndLibraryVersion if this builder is configured with the same * configurations, as the builder, which created the file (the persisted Chronicle Hash diff --git a/src/main/java/net/openhft/chronicle/hash/impl/CompactOffHeapLinearHashTable.java b/src/main/java/net/openhft/chronicle/hash/impl/CompactOffHeapLinearHashTable.java index 4ebff571e..a9a821c76 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/CompactOffHeapLinearHashTable.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/CompactOffHeapLinearHashTable.java @@ -52,6 +52,7 @@ public abstract class CompactOffHeapLinearHashTable { this.keyMask = mask(keyBits); this.valueMask = mask(valueBits); } + /** * Must not store {@code h} in a field, to avoid memory leaks. * 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 38bea5bb9..a78ec3d1e 100755 --- a/src/main/java/net/openhft/chronicle/hash/impl/VanillaChronicleHash.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/VanillaChronicleHash.java @@ -68,8 +68,8 @@ import static net.openhft.chronicle.map.ChronicleHashCorruptionImpl.format; import static net.openhft.chronicle.map.ChronicleHashCorruptionImpl.report; public abstract class VanillaChronicleHash, SC extends HashSegmentContext, - ECQ extends ExternalHashQueryContext> + C extends HashEntry, SC extends HashSegmentContext, + ECQ extends ExternalHashQueryContext> implements ChronicleHash, Marshallable { public static final long TIER_COUNTERS_AREA_SIZE = 64; @@ -158,7 +158,8 @@ public abstract class VanillaChronicleHash builder) { // Version @@ -633,7 +634,7 @@ public abstract class VanillaChronicleHash> public long tierEntriesForIteration() { throwExceptionIfClosed(); - return s.tierEntries(); + return s.tierEntries(); } abstract boolean entryRemovedOnThisIterationInit(); @@ -71,7 +71,7 @@ public abstract class HashSegmentIteration> public void initHashLookupEntry(long entry) { throwExceptionIfClosed(); - hashLookupEntry = entry; + hashLookupEntry = entry; } abstract void closeHashLookupEntry(); @@ -80,7 +80,7 @@ public abstract class HashSegmentIteration> public boolean forEachSegmentEntryWhile(Predicate predicate) { throwExceptionIfClosed(); - checkOnEachPublicOperation.checkOnEachPublicOperation(); + checkOnEachPublicOperation.checkOnEachPublicOperation(); s.innerUpdateLock.lock(); return innerForEachSegmentEntryWhile(predicate); } @@ -182,13 +182,13 @@ public abstract class HashSegmentIteration> public void hookAfterEachIteration() { throwExceptionIfClosed(); - } + } @Override public void forEachSegmentEntry(Consumer action) { throwExceptionIfClosed(); - forEachSegmentEntryWhile(e -> { + forEachSegmentEntryWhile(e -> { action.accept(e); return true; }); @@ -197,7 +197,7 @@ 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"); } @@ -207,7 +207,7 @@ public abstract class HashSegmentIteration> public void doRemove() { throwExceptionIfClosed(); - checkOnEachPublicOperation.checkOnEachPublicOperation(); + checkOnEachPublicOperation.checkOnEachPublicOperation(); s.innerWriteLock.lock(); try { iterationRemove(); @@ -220,7 +220,7 @@ 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 a987cf71c..a1a4cc578 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 @@ -46,7 +46,7 @@ public abstract class SegmentsRecovery implements IterationContext { 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/hash/impl/util/CanonicalRandomAccessFiles.java b/src/main/java/net/openhft/chronicle/hash/impl/util/CanonicalRandomAccessFiles.java index f99b364ee..9c801ea4f 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/util/CanonicalRandomAccessFiles.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/util/CanonicalRandomAccessFiles.java @@ -30,7 +30,8 @@ public final class CanonicalRandomAccessFiles { private static final ConcurrentHashMap CANONICAL_RAFS = new ConcurrentHashMap<>(); - private CanonicalRandomAccessFiles() {} + private CanonicalRandomAccessFiles() { + } public static RandomAccessFile acquire(@NotNull final File file) throws FileNotFoundException { return CANONICAL_RAFS.compute(file, (f, ref) -> { diff --git a/src/main/java/net/openhft/chronicle/hash/replication/TimeProvider.java b/src/main/java/net/openhft/chronicle/hash/replication/TimeProvider.java index 0b10254bf..73f6992c9 100644 --- a/src/main/java/net/openhft/chronicle/hash/replication/TimeProvider.java +++ b/src/main/java/net/openhft/chronicle/hash/replication/TimeProvider.java @@ -40,6 +40,7 @@ public final class TimeProvider { private static final AtomicLong lastTimeHolder = new AtomicLong(); private static LongSupplier millisecondSupplier = System::currentTimeMillis; + private TimeProvider() { } diff --git a/src/main/java/net/openhft/chronicle/hash/serialization/SetMarshaller.java b/src/main/java/net/openhft/chronicle/hash/serialization/SetMarshaller.java index 8f6baeadd..acdeb4d02 100644 --- a/src/main/java/net/openhft/chronicle/hash/serialization/SetMarshaller.java +++ b/src/main/java/net/openhft/chronicle/hash/serialization/SetMarshaller.java @@ -68,6 +68,7 @@ public final class SetMarshaller * Cache field */ private transient Deque orderedElements; + /** * Constructs a {@code SetMarshaller} with the given set elements' serializers. *

diff --git a/src/main/java/net/openhft/chronicle/hash/serialization/impl/BytesMarshallableReaderWriter.java b/src/main/java/net/openhft/chronicle/hash/serialization/impl/BytesMarshallableReaderWriter.java index f7496be4c..b2115a3ae 100644 --- a/src/main/java/net/openhft/chronicle/hash/serialization/impl/BytesMarshallableReaderWriter.java +++ b/src/main/java/net/openhft/chronicle/hash/serialization/impl/BytesMarshallableReaderWriter.java @@ -14,12 +14,12 @@ import org.jetbrains.annotations.Nullable; public class BytesMarshallableReaderWriter extends CachingCreatingMarshaller { + private static final ThreadLocal VANILLA_BYTES_TL = ThreadLocal.withInitial(() -> new VanillaBytes<>(BytesStore.empty())); + public BytesMarshallableReaderWriter(Class vClass) { super(vClass); } - private static final ThreadLocal VANILLA_BYTES_TL = ThreadLocal.withInitial(() -> new VanillaBytes<>(BytesStore.empty())); - @NotNull @Override public V read(Bytes in, long size, @Nullable V using) { diff --git a/src/main/java/net/openhft/chronicle/hash/serialization/impl/InstanceCreatingMarshaller.java b/src/main/java/net/openhft/chronicle/hash/serialization/impl/InstanceCreatingMarshaller.java index 2d623495c..76a85df9c 100644 --- a/src/main/java/net/openhft/chronicle/hash/serialization/impl/InstanceCreatingMarshaller.java +++ b/src/main/java/net/openhft/chronicle/hash/serialization/impl/InstanceCreatingMarshaller.java @@ -59,7 +59,7 @@ public abstract class InstanceCreatingMarshaller implements Marshallable { } protected Type tType() { - return tClass; + return tClass; } /** diff --git a/src/main/java/net/openhft/chronicle/hash/serialization/impl/StopBitSizeMarshaller.java b/src/main/java/net/openhft/chronicle/hash/serialization/impl/StopBitSizeMarshaller.java index 225025393..a7d06028b 100644 --- a/src/main/java/net/openhft/chronicle/hash/serialization/impl/StopBitSizeMarshaller.java +++ b/src/main/java/net/openhft/chronicle/hash/serialization/impl/StopBitSizeMarshaller.java @@ -29,6 +29,7 @@ public final class StopBitSizeMarshaller public static final StopBitSizeMarshaller INSTANCE = new StopBitSizeMarshaller(); private static final long MIN_ENCODABLE_SIZE = Long.MIN_VALUE; private static final long MAX_ENCODABLE_SIZE = Long.MAX_VALUE; + private StopBitSizeMarshaller() { } diff --git a/src/main/java/net/openhft/chronicle/hash/serialization/impl/TypedMarshallableReaderWriter.java b/src/main/java/net/openhft/chronicle/hash/serialization/impl/TypedMarshallableReaderWriter.java index 847b1552e..eb3bd48c8 100644 --- a/src/main/java/net/openhft/chronicle/hash/serialization/impl/TypedMarshallableReaderWriter.java +++ b/src/main/java/net/openhft/chronicle/hash/serialization/impl/TypedMarshallableReaderWriter.java @@ -25,6 +25,7 @@ public class TypedMarshallableReaderWriter BinaryWire wire = Wires.binaryWireForRead(in, in.readPosition(), size); return (V) wire.getValueIn().object(using, tClass()); } + protected void writeToWire(Wire wire, @NotNull V toWrite) { wire.getValueOut().object(toWrite); } diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ChronicleMap.java index 8034b570c..72297d694 100755 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMap.java @@ -218,7 +218,7 @@ public interface ChronicleMap extends ConcurrentMap, * @return the amount of free space in the map as a percentage. When the free space gets low ( around 5% ) the map will automatically expand. The * number of times it can automatically expand is based on the {@code net.openhft.chronicle.map.ChronicleMapBuilder#maxBloatFactor}. If the map * expands you will see an increase in the available free space. NOTE: It is not possible to expand the chronicle map manually. - * + *

* see also {@see net.openhft.chronicle.map.ChronicleMap#remainingAutoResizes} as these operations are related. */ default short percentageFreeSpace() { @@ -230,7 +230,7 @@ public interface ChronicleMap extends ConcurrentMap, * can be stored into the map), the map will expand automatically. However, there is an upper limit to the number of times the map can expand. * This limit is set via the {@code net.openhft.chronicle.map.ChronicleMapBuilder#maxBloatFactor} if the {@code remainingAutoResizes} drops to zero, * then the map is no longer able to expand, if subsequently, the free space ( see {@link net.openhft.chronicle.map.ChronicleMap#percentageFreeSpace}) - * in the map becomes low ( around 5% ), the map will not be able to take more entries and will fail with an {@code + * in the map becomes low ( around 5% ), the map will not be able to take more entries and will fail with an {@code * java.lang.IllegalStateException} for production systems it is recommended you periodically monitor the remainingAutoResizes and * {@link net.openhft.chronicle.map.ChronicleMap#percentageFreeSpace}. */ diff --git a/src/main/java/net/openhft/chronicle/map/FileLockUtil.java b/src/main/java/net/openhft/chronicle/map/FileLockUtil.java index 448f43332..b016515b6 100644 --- a/src/main/java/net/openhft/chronicle/map/FileLockUtil.java +++ b/src/main/java/net/openhft/chronicle/map/FileLockUtil.java @@ -22,7 +22,8 @@ public final class FileLockUtil { private static final boolean USE_LOCKING = !OS.isWindows() && !Boolean.getBoolean("chronicle.map.disable.locking"); private static final AtomicBoolean LOCK_WARNING_PRINTED = new AtomicBoolean(); - private FileLockUtil() { } + private FileLockUtil() { + } public static void acquireSharedFileLock(@NotNull final File canonicalFile, @NotNull final FileChannel channel) { if (USE_LOCKING) @@ -121,6 +122,27 @@ public final class FileLockUtil { } } + static void dump() { + System.out.println(FILE_LOCKS); + } + + private static ChronicleFileLockException newUnableToAcquireSharedFileLockException(@NotNull final File canonicalFile, @Nullable final Exception e) { + return new ChronicleFileLockException("Unable to acquire a shared file lock for " + canonicalFile + ". " + + "Make sure another process is not recovering the map.", e); + } + + private static ChronicleFileLockException newUnableToAcquireExclusiveFileLockException(@NotNull final File canonicalFile, @Nullable final Exception e) { + return new ChronicleFileLockException("Unable to acquire an exclusive file lock for " + canonicalFile + ". " + + "Make sure no other process is using the map.", e); + } + + private static void printWarningTheFirstTime() { + if (LOCK_WARNING_PRINTED.compareAndSet(false, true)) { + Jvm.warn().on(FileLockUtil.class, "File locking is disabled or not supported on this platform (" + System.getProperty("os.name") + "). " + + "Make sure you are not running ChronicleMapBuilder::*recover* methods when other processes or threads have the mapped file open!"); + } + } + // This class is not thread-safe but instances // are protected by means of the FILE_LOCKS map private static final class FileLockReference { @@ -162,25 +184,4 @@ public final class FileLockUtil { } } - static void dump() { - System.out.println(FILE_LOCKS); - } - - private static ChronicleFileLockException newUnableToAcquireSharedFileLockException(@NotNull final File canonicalFile, @Nullable final Exception e) { - return new ChronicleFileLockException("Unable to acquire a shared file lock for " + canonicalFile + ". " + - "Make sure another process is not recovering the map.", e); - } - - private static ChronicleFileLockException newUnableToAcquireExclusiveFileLockException(@NotNull final File canonicalFile, @Nullable final Exception e) { - return new ChronicleFileLockException("Unable to acquire an exclusive file lock for " + canonicalFile + ". " + - "Make sure no other process is using the map.", e); - } - - private static void printWarningTheFirstTime() { - if (LOCK_WARNING_PRINTED.compareAndSet(false, true)) { - Jvm.warn().on(FileLockUtil.class, "File locking is disabled or not supported on this platform (" + System.getProperty("os.name") + "). " + - "Make sure you are not running ChronicleMapBuilder::*recover* methods when other processes or threads have the mapped file open!"); - } - } - } \ No newline at end of file diff --git a/src/main/java/net/openhft/chronicle/map/OldDeletedEntriesCleanupThread.java b/src/main/java/net/openhft/chronicle/map/OldDeletedEntriesCleanupThread.java index af47f9976..7ea93840f 100644 --- a/src/main/java/net/openhft/chronicle/map/OldDeletedEntriesCleanupThread.java +++ b/src/main/java/net/openhft/chronicle/map/OldDeletedEntriesCleanupThread.java @@ -71,6 +71,7 @@ class OldDeletedEntriesCleanupThread extends Thread private long prevSegment0ScanStart = -1; private long removedCompletely; private long startTime = System.currentTimeMillis(); + OldDeletedEntriesCleanupThread(ReplicatedChronicleMap map) { super("Cleanup Thread for " + map.toIdentityString()); setDaemon(true); @@ -116,7 +117,7 @@ class OldDeletedEntriesCleanupThread extends Thread public void run() { throwExceptionIfClosed(); - if (System.currentTimeMillis() - startTime < 1_000) + if (System.currentTimeMillis() - startTime < 1_000) return; while (!shutdown) { @@ -179,7 +180,7 @@ class OldDeletedEntriesCleanupThread extends Thread 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/Replica.java b/src/main/java/net/openhft/chronicle/map/Replica.java index ee7888220..256d2a979 100644 --- a/src/main/java/net/openhft/chronicle/map/Replica.java +++ b/src/main/java/net/openhft/chronicle/map/Replica.java @@ -191,7 +191,7 @@ public interface Replica extends Closeable { * @param chronicleId is the channel id used to identify the canonical map or queue * @param keys list of keys corresponding to given ReplicableEntry (added to during the call) */ - void writeExternalEntry(ReplicableEntry entry, Bytes payload, @NotNull Bytes destination, int chronicleId, ArrayList keys ); + void writeExternalEntry(ReplicableEntry entry, Bytes payload, @NotNull Bytes destination, int chronicleId, ArrayList keys); /** * The map implements this method to restore its contents. This method must read the values diff --git a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java index 1638777f7..08084f473 100644 --- a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java @@ -101,7 +101,7 @@ public class ReplicatedChronicleMap extends VanillaChronicleMap public boolean equals(final Object obj) { throwExceptionIfClosed(); - return mapEquals(obj); + return mapEquals(obj); } @Override @@ -773,7 +773,7 @@ public class VanillaChronicleMap public boolean remove(@NotNull final Object key, final Object value) { throwExceptionIfClosed(); - if (value == null) + if (value == null) return false; // ConcurrentHashMap compatibility final V v = checkValue(value); try (QueryContextInterface q = queryContext(key)) { 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 ebd138cd3..57fb3d3c4 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 @@ -39,7 +39,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,7 +157,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 fab7faa66..6f4354f7f 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 @@ -42,14 +42,14 @@ public abstract class MapSegmentIteration extends HashSegmentIteration< 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 584a1748a..45be28942 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 @@ -62,28 +62,28 @@ public abstract class ReplicatedMapSegmentIteration extends MapSegmentI 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(); @@ -97,7 +97,7 @@ public abstract class ReplicatedMapSegmentIteration extends MapSegmentI public boolean forEachSegmentEntryWhile(Predicate> predicate) { throwExceptionIfClosed(); - checkOnEachPublicOperation.checkOnEachPublicOperation(); + checkOnEachPublicOperation.checkOnEachPublicOperation(); initEntriesToTest(PRESENT); s.innerUpdateLock.lock(); return innerForEachSegmentEntryWhile(predicate); @@ -108,7 +108,7 @@ public abstract class ReplicatedMapSegmentIteration extends MapSegmentI Predicate predicate) { throwExceptionIfClosed(); - checkOnEachPublicOperation.checkOnEachPublicOperation(); + checkOnEachPublicOperation.checkOnEachPublicOperation(); initEntriesToTest(ALL); s.innerUpdateLock.lock(); return innerForEachSegmentEntryWhile(predicate); @@ -118,7 +118,7 @@ public abstract class ReplicatedMapSegmentIteration extends MapSegmentI public void forEachSegmentReplicableEntry(Consumer action) { throwExceptionIfClosed(); - forEachSegmentReplicableEntryWhile(e -> { + forEachSegmentReplicableEntryWhile(e -> { action.accept(e); return true; }); @@ -128,7 +128,7 @@ public abstract class ReplicatedMapSegmentIteration extends MapSegmentI public void doRemove() { throwExceptionIfClosed(); - checkOnEachPublicOperation.checkOnEachPublicOperation(); + checkOnEachPublicOperation.checkOnEachPublicOperation(); try { if (e.valueSize > dummyValue.size()) e.innerDefaultReplaceValue(dummyValue); @@ -146,7 +146,7 @@ public abstract class ReplicatedMapSegmentIteration extends MapSegmentI public void doRemoveCompletely() { throwExceptionIfClosed(); - boolean wasDeleted = e.entryDeleted(); + boolean wasDeleted = e.entryDeleted(); super.doRemove(); ru.dropChange(); if (wasDeleted) @@ -156,7 +156,7 @@ 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); @@ -177,7 +177,7 @@ 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 c0cb6deef..349958a9c 100644 --- a/src/main/java/net/openhft/chronicle/set/SetFromMap.java +++ b/src/main/java/net/openhft/chronicle/set/SetFromMap.java @@ -53,37 +53,37 @@ 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; } @NotNull @@ -96,7 +96,7 @@ class SetFromMap extends AbstractSet implements ChronicleSet { public Object[] toArray() { throwExceptionIfClosed(); - return s.toArray(); + return s.toArray(); } public T[] toArray(T[] a) { @@ -122,13 +122,13 @@ 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(@NotNull Collection c) { @@ -154,28 +154,28 @@ class SetFromMap extends AbstractSet implements ChronicleSet { 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 @@ -211,7 +211,7 @@ class SetFromMap extends AbstractSet implements ChronicleSet { public int segments() { throwExceptionIfClosed(); - return m.segments(); + return m.segments(); } // TODO test forEach methods @@ -220,7 +220,7 @@ class SetFromMap extends AbstractSet implements ChronicleSet { public boolean forEachEntryWhile(Predicate> predicate) { throwExceptionIfClosed(); - Objects.requireNonNull(predicate); + Objects.requireNonNull(predicate); return m.forEachEntryWhile(e -> predicate.test(((SetEntry) e))); } @@ -228,7 +228,7 @@ class SetFromMap extends AbstractSet implements ChronicleSet { public void forEachEntry(Consumer> action) { throwExceptionIfClosed(); - Objects.requireNonNull(action); + Objects.requireNonNull(action); m.forEachEntry(e -> action.accept(((SetEntry) e))); } @@ -236,14 +236,14 @@ class SetFromMap extends AbstractSet implements ChronicleSet { public File file() { throwExceptionIfClosed(); - return m.file(); + return m.file(); } @Override public String name() { throwExceptionIfClosed(); - return m.name(); + return m.name(); } @Override @@ -255,6 +255,6 @@ class SetFromMap extends AbstractSet implements ChronicleSet { public boolean isOpen() { throwExceptionIfClosed(); - return m.isOpen(); + return m.isOpen(); } } diff --git a/src/test/java/net/openhft/chronicle/map/AutoResizeTest.java b/src/test/java/net/openhft/chronicle/map/AutoResizeTest.java index 657fac2ec..953875cb8 100644 --- a/src/test/java/net/openhft/chronicle/map/AutoResizeTest.java +++ b/src/test/java/net/openhft/chronicle/map/AutoResizeTest.java @@ -43,7 +43,7 @@ public class AutoResizeTest { Assert.assertNotEquals(0.0, map.remainingAutoResizes()); System.out.println(actual); } - } + } @Test public void testAutoResizeNotZeroUponRestart2() throws IOException { @@ -58,6 +58,6 @@ public class AutoResizeTest { Assert.assertNotEquals(0.0, actual); System.out.println(actual); } - } + } } diff --git a/src/test/java/net/openhft/chronicle/map/BasicReplicationTest.java b/src/test/java/net/openhft/chronicle/map/BasicReplicationTest.java index a22a4bc0b..3dc8d3993 100644 --- a/src/test/java/net/openhft/chronicle/map/BasicReplicationTest.java +++ b/src/test/java/net/openhft/chronicle/map/BasicReplicationTest.java @@ -195,7 +195,7 @@ public class BasicReplicationTest { try { buffer.clear(); keys.clear(); - sourceMap.writeExternalEntry(entry, null, buffer, chronicleId,keys); + sourceMap.writeExternalEntry(entry, null, buffer, chronicleId, keys); buffer.readPosition(0); buffer.readLimit(buffer.writePosition()); diff --git a/src/test/java/net/openhft/chronicle/map/BloatFactorTest.java b/src/test/java/net/openhft/chronicle/map/BloatFactorTest.java index 3013eae01..c03eb32bd 100644 --- a/src/test/java/net/openhft/chronicle/map/BloatFactorTest.java +++ b/src/test/java/net/openhft/chronicle/map/BloatFactorTest.java @@ -39,9 +39,9 @@ public class BloatFactorTest { .createOrRecoverPersistedTo(cmap)) { double maxBloatFactor = Jvm.getValue(map, "maxBloatFactor"); - Assert.assertEquals(EXPECTED_MAX_BLOAT_FACTOR, maxBloatFactor,0.0); + Assert.assertEquals(EXPECTED_MAX_BLOAT_FACTOR, maxBloatFactor, 0.0); } - } + } } diff --git a/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java b/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java index d440dc394..70ea850f2 100644 --- a/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java +++ b/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java @@ -2557,6 +2557,7 @@ public class CHMUseCasesTest { } } } + @Test public void testBytesMarshallable3() throws IOException { BytesMarshallableReaderWriter bmwr = new BytesMarshallableReaderWriter<>(IData.Data.class); diff --git a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java index 28030fed0..8cbc04e34 100755 --- a/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/ChronicleMapTest.java @@ -1882,6 +1882,7 @@ public class ChronicleMapTest { static class BMClass implements BytesMarshallable, BMSUper { } + private static final class IncrementRunnable implements Runnable { private final ChronicleMap map; diff --git a/src/test/java/net/openhft/chronicle/map/Issue125Test.java b/src/test/java/net/openhft/chronicle/map/Issue125Test.java index 5dc7bd120..b4520a9de 100644 --- a/src/test/java/net/openhft/chronicle/map/Issue125Test.java +++ b/src/test/java/net/openhft/chronicle/map/Issue125Test.java @@ -28,7 +28,7 @@ import java.io.IOException; public class Issue125Test { @Test public void test() throws IOException { - final File cacheRoot = new File(OS.getTarget() + "/test-" + Time.unqiueId+".cm3"); + final File cacheRoot = new File(OS.getTarget() + "/test-" + Time.unqiueId + ".cm3"); ChronicleMapBuilder shaToNodeBuilder = ChronicleMapBuilder.of(byte[].class, byte[].class) // .name("bytes-to-bytes") diff --git a/src/test/java/net/openhft/chronicle/map/Issue62ChronicleServer.java b/src/test/java/net/openhft/chronicle/map/Issue62ChronicleServer.java index 18aa6ac08..e45178cb6 100644 --- a/src/test/java/net/openhft/chronicle/map/Issue62ChronicleServer.java +++ b/src/test/java/net/openhft/chronicle/map/Issue62ChronicleServer.java @@ -30,10 +30,10 @@ public class Issue62ChronicleServer { //"This is just a long string, which causes sink to fail for some reason."; "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; final static File MAP_FILE_B = - Paths.get(OS.getTarget(), Time.uniqueId()+"map.b").toFile(); + Paths.get(OS.getTarget(), Time.uniqueId() + "map.b").toFile(); private final static Logger LOGGER = LoggerFactory.getLogger(Issue62ChronicleServer.class); private final static File MAP_FILE_A = - Paths.get(OS.getTarget(), Time.uniqueId()+"map.a").toFile(); + Paths.get(OS.getTarget(), Time.uniqueId() + "map.a").toFile(); static void prepare(File file) { if (file.exists()) diff --git a/src/test/java/net/openhft/chronicle/map/Issue63Test.java b/src/test/java/net/openhft/chronicle/map/Issue63Test.java index b2f37baee..06f98bb5e 100644 --- a/src/test/java/net/openhft/chronicle/map/Issue63Test.java +++ b/src/test/java/net/openhft/chronicle/map/Issue63Test.java @@ -87,7 +87,7 @@ public class Issue63Test { @Test public void issue63test() throws IOException { - Path path = Paths.get(OS.getTarget() + "/test-vectors1-"+Time.uniqueId()+".dat"); + Path path = Paths.get(OS.getTarget() + "/test-vectors1-" + Time.uniqueId() + ".dat"); if (Files.exists(path)) Files.delete(path); File mapFile = path.toFile(); mapFile.deleteOnExit(); diff --git a/src/test/java/net/openhft/chronicle/map/ReplicatedChronicleMapTest.java b/src/test/java/net/openhft/chronicle/map/ReplicatedChronicleMapTest.java index 38900e723..0ad3206e9 100644 --- a/src/test/java/net/openhft/chronicle/map/ReplicatedChronicleMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/ReplicatedChronicleMapTest.java @@ -468,7 +468,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { ChronicleMap c = newShmIntString(); c.get(null); shouldThrow(); - } catch (NullPointerException|IllegalArgumentException success) { + } catch (NullPointerException | IllegalArgumentException success) { } } @@ -481,7 +481,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { ChronicleMap c = newShmIntString(); c.containsKey(null); shouldThrow(); - } catch (NullPointerException|IllegalArgumentException success) { + } catch (NullPointerException | IllegalArgumentException success) { } } @@ -494,7 +494,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { ChronicleMap c = newShmIntString(); c.put(null, "whatever"); shouldThrow(); - } catch (NullPointerException|IllegalArgumentException success) { + } catch (NullPointerException | IllegalArgumentException success) { } } @@ -507,7 +507,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { ChronicleMap c = newShmIntString(); c.put(JSR166TestCase.notPresent, null); shouldThrow(); - } catch (NullPointerException|IllegalArgumentException success) { + } catch (NullPointerException | IllegalArgumentException success) { } } @@ -520,7 +520,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { ChronicleMap c = newShmIntString(); c.putIfAbsent(null, "whatever"); shouldThrow(); - } catch (NullPointerException|IllegalArgumentException success) { + } catch (NullPointerException | IllegalArgumentException success) { } } @@ -568,7 +568,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { ChronicleMap c = newShmIntString(); c.replace(null, "whatever"); shouldThrow(); - } catch (NullPointerException|IllegalArgumentException success) { + } catch (NullPointerException | IllegalArgumentException success) { } } @@ -581,7 +581,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { ChronicleMap c = newShmIntString(); c.replace(null, "A", "whatever"); shouldThrow(); - } catch (NullPointerException|IllegalArgumentException success) { + } catch (NullPointerException | IllegalArgumentException success) { } } @@ -620,7 +620,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { ChronicleMap c = newShmIntString(); c.putIfAbsent(JSR166TestCase.notPresent, null); shouldThrow(); - } catch (NullPointerException|IllegalArgumentException success) { + } catch (NullPointerException | IllegalArgumentException success) { } } @@ -633,7 +633,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { ChronicleMap c = newShmIntString(); c.replace(JSR166TestCase.notPresent, null); shouldThrow(); - } catch (NullPointerException|IllegalArgumentException success) { + } catch (NullPointerException | IllegalArgumentException success) { } } @@ -646,7 +646,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { ChronicleMap c = newShmIntString(); c.replace(JSR166TestCase.notPresent, null, "A"); shouldThrow(); - } catch (NullPointerException|IllegalArgumentException success) { + } catch (NullPointerException | IllegalArgumentException success) { } } @@ -659,7 +659,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { ChronicleMap c = newShmIntString(); c.replace(JSR166TestCase.notPresent, "A", null); shouldThrow(); - } catch (NullPointerException|IllegalArgumentException success) { + } catch (NullPointerException | IllegalArgumentException success) { } } @@ -673,7 +673,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { c.put("sadsdf", "asdads"); c.remove(null); shouldThrow(); - } catch (NullPointerException|IllegalArgumentException success) { + } catch (NullPointerException | IllegalArgumentException success) { } } @@ -687,7 +687,7 @@ public class ReplicatedChronicleMapTest extends JSR166TestCase { c.put("sadsdf", "asdads"); c.remove(null, "whatever"); shouldThrow(); - } catch (NullPointerException|IllegalArgumentException success) { + } catch (NullPointerException | IllegalArgumentException success) { } } diff --git a/src/test/java/net/openhft/chronicle/map/example/StringArrayExample.java b/src/test/java/net/openhft/chronicle/map/example/StringArrayExample.java index c495af995..b1e0190cc 100644 --- a/src/test/java/net/openhft/chronicle/map/example/StringArrayExample.java +++ b/src/test/java/net/openhft/chronicle/map/example/StringArrayExample.java @@ -14,19 +14,6 @@ public class StringArrayExample { private final CharSequenceArray charSequenceArray = Values.newHeapInstance(CharSequenceArray.class); - public interface CharSequenceArray { - @Array(length = 8) - void setCharSequenceWrapperAt(int index, CharSequenceWrapper value); - - CharSequenceWrapper getCharSequenceWrapperAt(int index); - } - - public interface CharSequenceWrapper { - void setCharSequence(@MaxUtf8Length(6) CharSequence charSequence); - - CharSequence getCharSequence(); - } - @Test public void examplePutAndGet() { ChronicleMap map = ChronicleMapBuilder @@ -52,11 +39,24 @@ public class StringArrayExample { // to string all the values System.out.println(map.getUsing(1, charSequenceArray).toString()); } - } + } private CharSequenceArray setToHello(final Integer integer, final CharSequenceArray charSequenceArray) { charSequenceArray.getCharSequenceWrapperAt(1).setCharSequence("hello"); return charSequenceArray; } + public interface CharSequenceArray { + @Array(length = 8) + void setCharSequenceWrapperAt(int index, CharSequenceWrapper value); + + CharSequenceWrapper getCharSequenceWrapperAt(int index); + } + + public interface CharSequenceWrapper { + CharSequence getCharSequence(); + + void setCharSequence(@MaxUtf8Length(6) CharSequence charSequence); + } + } diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/ChronicleAcidIsolation.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/ChronicleAcidIsolation.java index 30c2371c0..4a75df78d 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/ChronicleAcidIsolation.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/ChronicleAcidIsolation.java @@ -1,6 +1,6 @@ package net.openhft.chronicle.map.fromdocs.acid; -public interface ChronicleAcidIsolation extends java.sql.Connection{ +public interface ChronicleAcidIsolation extends java.sql.Connection { int LOWEST_LATENCY = ChronicleAcidIsolation.TRANSACTION_NONE; int DIRTY_READ_OPTIMISTIC = ChronicleAcidIsolation.TRANSACTION_READ_UNCOMMITTED; diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/ChronicleAcidIsolationGovernor.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/ChronicleAcidIsolationGovernor.java index db8dfa975..4ba7b1a75 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/ChronicleAcidIsolationGovernor.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/ChronicleAcidIsolationGovernor.java @@ -15,14 +15,14 @@ public class ChronicleAcidIsolationGovernor implements ChronicleAcidIsolation { private ChronicleMap transactionIsolationMap; private ChronicleMap compositeChronicleMap; //hacked in, not generic private String priorCusip; - private Double aCoupon; + private Double aCoupon; -public synchronized void put(String cusip, BondVOInterface bond) throws Exception { + public synchronized void put(String cusip, BondVOInterface bond) throws Exception { System.out.println( - " , @t="+System.currentTimeMillis()+ - " Tx="+Thread.currentThread().toString().replaceAll(",",".")+ - " inside chrAig.put('"+cusip+"'/"+aCoupon+") BEGIN"+ + " , @t=" + System.currentTimeMillis() + + " Tx=" + Thread.currentThread().toString().replaceAll(",", ".") + + " inside chrAig.put('" + cusip + "'/" + aCoupon + ") BEGIN" + ", " ); ChronicleMap cMap = this.getCompositeChronicleMap(); @@ -31,39 +31,39 @@ public synchronized void put(String cusip, BondVOInterface bond) throws Exceptio bond.setCoupon(aCoupon); cMap.put(cusip, bond); System.out.println( - " , @t="+System.currentTimeMillis()+ - " Tx="+Thread.currentThread().toString().replaceAll(",",".")+ - " inside chrAig.put('"+cusip+"'/"+aCoupon+") DONE"+ + " , @t=" + System.currentTimeMillis() + + " Tx=" + Thread.currentThread().toString().replaceAll(",", ".") + + " inside chrAig.put('" + cusip + "'/" + aCoupon + ") DONE" + ", " ); } -//here is where the drama happens + //here is where the drama happens public synchronized BondVOInterface get(String cusip) throws Exception { System.out.println( - " , @t="+System.currentTimeMillis()+ - " Tx="+Thread.currentThread().toString().replaceAll(",",".")+ - " inside chrAig.get('"+cusip+"') BEGIN"+ + " , @t=" + System.currentTimeMillis() + + " Tx=" + Thread.currentThread().toString().replaceAll(",", ".") + + " inside chrAig.get('" + cusip + "') BEGIN" + ", " ); BondVOInterface b = null; String tx = Thread.currentThread().toString(); - ChronicleMap txMap = this.getTransactionIsolationMap(); + ChronicleMap txMap = this.getTransactionIsolationMap(); if (txMap.size() > 1) { //other ACID transactions are active if (txMap.get(tx) <= ChronicleAcidIsolation.DIRTY_READ_OPTIMISTIC) { b = this.compositeChronicleMap.get(cusip); } else if (txMap.get(tx) >= ChronicleAcidIsolation.DIRTY_READ_INTOLERANT) { System.out.println( - ", @t="+System.currentTimeMillis()+ - " Tx="+Thread.currentThread().toString().replaceAll(",",".")+ - " inside chrAig.get() WAITING"+ + ", @t=" + System.currentTimeMillis() + + " Tx=" + Thread.currentThread().toString().replaceAll(",", ".") + + " inside chrAig.get() WAITING" + " ," ); this.wait(); System.out.println( - " , @t="+System.currentTimeMillis()+ - " Tx="+Thread.currentThread().toString().replaceAll(",",".")+ - " inside chrAig.get() RESUMING"+ + " , @t=" + System.currentTimeMillis() + + " Tx=" + Thread.currentThread().toString().replaceAll(",", ".") + + " inside chrAig.get() RESUMING" + ", " ); b = this.compositeChronicleMap.get(cusip); @@ -72,9 +72,9 @@ public synchronized void put(String cusip, BondVOInterface bond) throws Exceptio b = this.compositeChronicleMap.get(cusip); } System.out.println( - " , @t="+System.currentTimeMillis()+ - " Tx="+Thread.currentThread().toString().replaceAll(",",".")+ - " inside chrAig.get() DONE"+ + " , @t=" + System.currentTimeMillis() + + " Tx=" + Thread.currentThread().toString().replaceAll(",", ".") + + " inside chrAig.get() DONE" + " ," ); return b; @@ -99,6 +99,13 @@ public synchronized void put(String cusip, BondVOInterface bond) throws Exceptio this.compositeChronicleMap = ccm; } + @Override + public synchronized int getTransactionIsolation() throws SQLException { + + int iL = this.getTransactionIsolationMap().get(Thread.currentThread()); + return (iL); + } + @Override public synchronized void setTransactionIsolation(int level) throws SQLException { @@ -108,34 +115,27 @@ public synchronized void put(String cusip, BondVOInterface bond) throws Exceptio ); } - @Override - public synchronized int getTransactionIsolation() throws SQLException { - - int iL = this.getTransactionIsolationMap().get(Thread.currentThread()); - return(iL); - } - @Override public synchronized void commit() throws SQLException { System.out.println( - " ,@t="+System.currentTimeMillis()+ - " Tx="+Thread.currentThread().toString().replaceAll(",",".")+ - " chrAig.commit() BEGIN "+ - ", " + " ,@t=" + System.currentTimeMillis() + + " Tx=" + Thread.currentThread().toString().replaceAll(",", ".") + + " chrAig.commit() BEGIN " + + ", " ); this.getTransactionIsolationMap().remove(Thread.currentThread().toString()); System.out.println( - " , @t="+System.currentTimeMillis()+ - " Tx="+Thread.currentThread().toString().replaceAll(",",".")+ - " chrAig.commit() END "+ - ", " + " , @t=" + System.currentTimeMillis() + + " Tx=" + Thread.currentThread().toString().replaceAll(",", ".") + + " chrAig.commit() END " + + ", " ); this.notifyAll(); System.out.println( - ", @t="+System.currentTimeMillis()+ - " Tx="+Thread.currentThread().toString().replaceAll(",",".")+ - " chrAig.commit() complete notifyAll() to waiting Tx Threads "+ - "," + ", @t=" + System.currentTimeMillis() + + " Tx=" + Thread.currentThread().toString().replaceAll(",", ".") + + " chrAig.commit() complete notifyAll() to waiting Tx Threads " + + "," ); } @@ -148,24 +148,24 @@ public synchronized void put(String cusip, BondVOInterface bond) throws Exceptio this.getCompositeChronicleMap().put("369604101", priorBond); } System.out.println( - " , @t="+System.currentTimeMillis()+ - " Tx="+Thread.currentThread().toString().replaceAll(",",".")+ - " chrAig.rollback() BEGIN "+ - ", " + " , @t=" + System.currentTimeMillis() + + " Tx=" + Thread.currentThread().toString().replaceAll(",", ".") + + " chrAig.rollback() BEGIN " + + ", " ); this.getTransactionIsolationMap().remove(Thread.currentThread().toString()); System.out.println( - " ,@t="+System.currentTimeMillis()+ - " Tx="+Thread.currentThread().toString().replaceAll(",",".")+ - " chrAig.rollback() COMPLETE coupon=3.50"+ - ", " + " ,@t=" + System.currentTimeMillis() + + " Tx=" + Thread.currentThread().toString().replaceAll(",", ".") + + " chrAig.rollback() COMPLETE coupon=3.50" + + ", " ); this.notifyAll(); System.out.println( - ", @t="+System.currentTimeMillis()+ - " Tx="+Thread.currentThread().toString().replaceAll(",",".")+ - " chrAig.rollback() completed notifyAll() to waiting Tx Threads"+ - ", " + ", @t=" + System.currentTimeMillis() + + " Tx=" + Thread.currentThread().toString().replaceAll(",", ".") + + " chrAig.rollback() completed notifyAll() to waiting Tx Threads" + + ", " ); } // rest of these java.sql.Connection methods remain unimplemented ... @@ -173,17 +173,17 @@ public synchronized void put(String cusip, BondVOInterface bond) throws Exceptio // intense. In the real world, even in Captital Markets 'dirty read' intolerance // is likely the only isolation level Chronicle would accommodate. -@Override - public void setAutoCommit(boolean autoCommit) throws SQLException { - - } - @Override public boolean getAutoCommit() throws SQLException { return false; } -@Override + @Override + public void setAutoCommit(boolean autoCommit) throws SQLException { + + } + + @Override public void rollback(Savepoint savepoint) throws SQLException { } @@ -193,7 +193,7 @@ public synchronized void put(String cusip, BondVOInterface bond) throws Exceptio } -@Override + @Override public Statement createStatement() throws SQLException { return null; } @@ -213,7 +213,7 @@ public synchronized void put(String cusip, BondVOInterface bond) throws Exceptio return null; } -@Override + @Override public boolean isClosed() throws SQLException { return false; } @@ -223,18 +223,13 @@ public synchronized void put(String cusip, BondVOInterface bond) throws Exceptio return null; } - @Override - public void setReadOnly(boolean readOnly) throws SQLException { - - } - @Override public boolean isReadOnly() throws SQLException { return false; } @Override - public void setCatalog(String catalog) throws SQLException { + public void setReadOnly(boolean readOnly) throws SQLException { } @@ -243,7 +238,12 @@ public synchronized void put(String cusip, BondVOInterface bond) throws Exceptio return null; } -@Override + @Override + public void setCatalog(String catalog) throws SQLException { + + } + + @Override public SQLWarning getWarnings() throws SQLException { return null; } @@ -279,13 +279,13 @@ public synchronized void put(String cusip, BondVOInterface bond) throws Exceptio } @Override - public void setHoldability(int holdability) throws SQLException { - + public int getHoldability() throws SQLException { + return 0; } @Override - public int getHoldability() throws SQLException { - return 0; + public void setHoldability(int holdability) throws SQLException { + } @Override @@ -298,7 +298,7 @@ public synchronized void put(String cusip, BondVOInterface bond) throws Exceptio return null; } -@Override + @Override public void releaseSavepoint(Savepoint savepoint) throws SQLException { } @@ -363,11 +363,6 @@ public synchronized void put(String cusip, BondVOInterface bond) throws Exceptio } - @Override - public void setClientInfo(Properties properties) throws SQLClientInfoException { - - } - @Override public String getClientInfo(String name) throws SQLException { return null; @@ -378,6 +373,11 @@ public synchronized void put(String cusip, BondVOInterface bond) throws Exceptio return null; } + @Override + public void setClientInfo(Properties properties) throws SQLClientInfoException { + + } + @Override public Array createArrayOf(String typeName, Object[] elements) throws SQLException { return null; @@ -389,13 +389,13 @@ public synchronized void put(String cusip, BondVOInterface bond) throws Exceptio } @Override - public void setSchema(String schema) throws SQLException { - + public String getSchema() throws SQLException { + return null; } @Override - public String getSchema() throws SQLException { - return null; + public void setSchema(String schema) throws SQLException { + } @Override diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/exodus/DirtyReadOffender.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/exodus/DirtyReadOffender.java index c4b85399e..9cd5135a5 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/exodus/DirtyReadOffender.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/exodus/DirtyReadOffender.java @@ -53,15 +53,15 @@ public class DirtyReadOffender implements Runnable { double newCoupon = 3.5 + Math.random(); System.out.println( " @t=" + System.currentTimeMillis() + - " DirtyReadOffender "+ - " calling chm.put('369604101',"+newCoupon+") " + " DirtyReadOffender " + + " calling chm.put('369604101'," + newCoupon + ") " ); bond.setCoupon(newCoupon); chm.put("369604101", bond); System.out.println( " @t=" + System.currentTimeMillis() + - " DirtyReadOffender coupon=["+ - bond.getCoupon()+ + " DirtyReadOffender coupon=[" + + bond.getCoupon() + "] written. " ); } finally { diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/exodus/DirtyReadTolerance.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/exodus/DirtyReadTolerance.java index 27c909f4a..1936e0e78 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/exodus/DirtyReadTolerance.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/exodus/DirtyReadTolerance.java @@ -9,10 +9,10 @@ import java.io.File; import java.io.IOException; import java.util.concurrent.locks.StampedLock; -public class DirtyReadTolerance { +public class DirtyReadTolerance { public static void main(String args[]) throws Exception { - System.out.println("DirtyReadOffender,chrAig["+args[0]+"]coupon=3.50,DirtyReadVictim"); + System.out.println("DirtyReadOffender,chrAig[" + args[0] + "]coupon=3.50,DirtyReadVictim"); String isoLevel = args[0]; ChronicleMap chm = diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/exodus/DirtyReadVictim.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/exodus/DirtyReadVictim.java index 07e793748..5cf7d2240 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/exodus/DirtyReadVictim.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/exodus/DirtyReadVictim.java @@ -27,8 +27,8 @@ public class DirtyReadVictim implements Runnable { try { /** - * ben.cotton@rutgers.edu START - */ + * ben.cotton@rutgers.edu START + */ Double coupon = 0.00; BondVOInterface bond = newNativeReference(BondVOInterface.class); long stamp = 0; @@ -54,13 +54,13 @@ public class DirtyReadVictim implements Runnable { coupon = bond.getCoupon(); System.out.println( " ,,@t=" + System.currentTimeMillis() + - " DirtyReadVictim coupon=[" +coupon+"] read." + " DirtyReadVictim coupon=[" + coupon + "] read." ); System.out.println( " ,,@t=" + System.currentTimeMillis() + " DirtyReadVictim sleeping 60 seconds" ); - Thread.sleep( 60_000); + Thread.sleep(60_000); } finally { if (this.offHeapLock.validate(stamp)) { System.out.println( @@ -97,7 +97,7 @@ public class DirtyReadVictim implements Runnable { } } -public ChronicleMap getCraig() { + public ChronicleMap getCraig() { return this.chm; } diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/genesis/DirtyReadOffender.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/genesis/DirtyReadOffender.java index 856e24d94..d43157c0d 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/genesis/DirtyReadOffender.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/genesis/DirtyReadOffender.java @@ -53,15 +53,15 @@ public class DirtyReadOffender implements Runnable { double newCoupon = 3.5 + Math.random(); System.out.println( " @t=" + System.currentTimeMillis() + - " DirtyReadOffender "+ - " calling chm.put('369604101',"+newCoupon+") " + " DirtyReadOffender " + + " calling chm.put('369604101'," + newCoupon + ") " ); bond.setCoupon(newCoupon); chm.put("369604101", bond); System.out.println( " @t=" + System.currentTimeMillis() + - " DirtyReadOffender coupon=["+ - bond.getCoupon()+ + " DirtyReadOffender coupon=[" + + bond.getCoupon() + "] written. " ); } finally { diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/genesis/DirtyReadTolerance.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/genesis/DirtyReadTolerance.java index 89be5f66b..5b6acd82d 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/genesis/DirtyReadTolerance.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/genesis/DirtyReadTolerance.java @@ -9,10 +9,10 @@ import java.io.File; import java.io.IOException; import java.util.concurrent.locks.StampedLock; -public class DirtyReadTolerance { +public class DirtyReadTolerance { public static void main(String args[]) throws Exception { - System.out.println("DirtyReadOffender,chrAig["+args[0]+"]coupon=3.50,DirtyReadVictim"); + System.out.println("DirtyReadOffender,chrAig[" + args[0] + "]coupon=3.50,DirtyReadVictim"); String isoLevel = args[0]; ChronicleMap chm = diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/genesis/DirtyReadVictim.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/genesis/DirtyReadVictim.java index 06511e84d..ab176e0a2 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/genesis/DirtyReadVictim.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/genesis/DirtyReadVictim.java @@ -27,8 +27,8 @@ public class DirtyReadVictim implements Runnable { try { /** - * ben.cotton@rutgers.edu START - */ + * ben.cotton@rutgers.edu START + */ Double coupon = 0.00; BondVOInterface bond = newNativeReference(BondVOInterface.class); long stamp = 0; @@ -54,13 +54,13 @@ public class DirtyReadVictim implements Runnable { coupon = bond.getCoupon(); System.out.println( " ,,@t=" + System.currentTimeMillis() + - " DirtyReadVictim coupon=[" +coupon+"] read." + " DirtyReadVictim coupon=[" + coupon + "] read." ); System.out.println( " ,,@t=" + System.currentTimeMillis() + " DirtyReadVictim sleeping 10 seconds" ); - Thread.sleep( 10_000); + Thread.sleep(10_000); } finally { if (this.offHeapLock.validate(stamp)) { System.out.println( @@ -97,7 +97,7 @@ public class DirtyReadVictim implements Runnable { } } -public ChronicleMap getCraig() { + public ChronicleMap getCraig() { return this.chm; } diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/ChronicleStampedLock.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/ChronicleStampedLock.java index d49335bcf..3be87f9d5 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/ChronicleStampedLock.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/ChronicleStampedLock.java @@ -41,7 +41,7 @@ public class ChronicleStampedLock extends StampedLock { LongValue.class ); //WriterSet cardinality -ChronicleStampedLock(String chronicelStampedLockLocality) { // path of Operand set i.e. /dev/shm/ + ChronicleStampedLock(String chronicelStampedLockLocality) { // path of Operand set i.e. /dev/shm/ try { chm = offHeapLock(chronicelStampedLockLocality); chmR = offHeapLockReaderCount(chronicelStampedLockLocality + "=ReaderCount"); @@ -60,6 +60,32 @@ ChronicleStampedLock(String chronicelStampedLockLocality) { // path of Operand s } } + static ChronicleMap offHeapLock(String operand) + throws IOException { + + return ChronicleMapBuilder.of(String.class, ChronicleStampedLockVOInterface.class) + .entries(16) + .averageKeySize("123456789".length()) + .createPersistedTo( + new File( + operand + ) + ); + } + + static ChronicleMap offHeapLockReaderCount(String operand) + throws IOException { + + return ChronicleMapBuilder.of(String.class, LongValue.class) + .entries(16) + .averageKeySize("123456789".length()) + .createPersistedTo( + new File( + operand + ) + ); + } + @Override public long tryOptimisticRead() { (offHeapLock = chm.get("Stamp ")).setEntryLockState(0L); @@ -119,7 +145,7 @@ ChronicleStampedLock(String chronicelStampedLockLocality) { // path of Operand s lastWriterT = chm.get("LastWriterTime "); writeLockHolderCount = chmW.get("WriterCount "); -l = offHeapLock.getEntryLockState(); + l = offHeapLock.getEntryLockState(); if (l != 0L) return 0L; @@ -150,7 +176,7 @@ l = offHeapLock.getEntryLockState(); System.out.println( " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock trywriteLock() ++ writeSeekers=[" + - +writeLockHolderCount.getVolatileValue()+"] " + + +writeLockHolderCount.getVolatileValue() + "] " + "..," ); System.out.println( @@ -261,7 +287,7 @@ l = offHeapLock.getEntryLockState(); System.out.println( " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock writeLock() ++ writeSeekers=[" + - +writeLockHolderCount.getVolatileValue()+"] " + + +writeLockHolderCount.getVolatileValue() + "] " + "..," ); @@ -398,7 +424,7 @@ l = offHeapLock.getEntryLockState(); System.out.println( " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock unlockWrite(" + stamp + ") -- writeSeekers=[" + - +writeLockHolderCount.getVolatileValue()+"] " + + +writeLockHolderCount.getVolatileValue() + "] " + "..," ); @@ -411,6 +437,14 @@ l = offHeapLock.getEntryLockState(); ); } +// @Override +// public boolean isWriteLocked() { +// if (this.getReadLockCount() < 0) +// return (Boolean.TRUE); +// else +// return (Boolean.FALSE); +// } + @Override public int getReadLockCount() { return ((int) chmR.get("ReaderCount ").getVolatileValue()); @@ -423,38 +457,4 @@ l = offHeapLock.getEntryLockState(); else return (Boolean.FALSE); } - -// @Override -// public boolean isWriteLocked() { -// if (this.getReadLockCount() < 0) -// return (Boolean.TRUE); -// else -// return (Boolean.FALSE); -// } - - static ChronicleMap offHeapLock(String operand) - throws IOException { - - return ChronicleMapBuilder.of(String.class, ChronicleStampedLockVOInterface.class) - .entries(16) - .averageKeySize("123456789".length()) - .createPersistedTo( - new File( - operand - ) - ); - } - - static ChronicleMap offHeapLockReaderCount(String operand) - throws IOException { - - return ChronicleMapBuilder.of(String.class, LongValue.class) - .entries(16) - .averageKeySize("123456789".length()) - .createPersistedTo( - new File( - operand - ) - ); - } } diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/ChronicleStampedLockTest.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/ChronicleStampedLockTest.java index 4e5e7413d..31a9b138d 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/ChronicleStampedLockTest.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/ChronicleStampedLockTest.java @@ -8,7 +8,7 @@ import org.junit.*; public class ChronicleStampedLockTest { -@Test + @Test public void tryOptimisticRead() { Assert.assertEquals(Boolean.TRUE, Boolean.TRUE); } diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadIntolerant.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadIntolerant.java index c4068389c..90b846c7d 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadIntolerant.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadIntolerant.java @@ -75,11 +75,11 @@ public class DirtyReadIntolerant { } finally { offHeapLock.unlockRead(stamp); - System.out.println( - " ,,@t=" + System.currentTimeMillis() + - " DirtyReadIntolerant offHeapLock.unlockRead(" + - stamp + ") completed." - ); + System.out.println( + " ,,@t=" + System.currentTimeMillis() + + " DirtyReadIntolerant offHeapLock.unlockRead(" + + stamp + ") completed." + ); } /** diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadTolerance.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadTolerance.java index d4d4426f2..25e23c798 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadTolerance.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadTolerance.java @@ -10,16 +10,16 @@ import java.io.File; import java.io.IOException; import java.util.concurrent.locks.StampedLock; -public class DirtyReadTolerance { +public class DirtyReadTolerance { public static void main(String args[]) throws Exception { - System.out.println("DirtyReadOffender,chrAig["+args[0]+"]coupon=3.50,DirtyReadVictim"); + System.out.println("DirtyReadOffender,chrAig[" + args[0] + "]coupon=3.50,DirtyReadVictim"); String isoLevel = args[0]; ChronicleMap chm = DirtyReadTolerance.offHeap( args[2] - + "OPERAND_CHRONICLE_MAP" + + "OPERAND_CHRONICLE_MAP" ); System.out.println(",Established chm,"); } diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadVictimTest.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadVictimTest.java index 49e8ce025..bd2454497 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadVictimTest.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadVictimTest.java @@ -85,7 +85,7 @@ public class DirtyReadVictimTest { ); // THIS Test will execute pass when ChronicleStampedLock is GA Assert.assertNotEquals( - stamp, + stamp, offHeapLock.lastWriterT.getEntryLockState() ); } diff --git a/src/test/java/net/openhft/chronicle/map/perf/MapJLBHTest.java b/src/test/java/net/openhft/chronicle/map/perf/MapJLBHTest.java index 7889de9e0..2d839555f 100644 --- a/src/test/java/net/openhft/chronicle/map/perf/MapJLBHTest.java +++ b/src/test/java/net/openhft/chronicle/map/perf/MapJLBHTest.java @@ -42,6 +42,8 @@ public class MapJLBHTest implements JLBHTask { private NanoSampler writeSampler; private NanoSampler e2eSampler; private File mapFile = new File("perfmap/map.cm3"); + private long counter = -WARM_UP_ITERATIONS; + private IFacade datum = Values.newNativeReference(IFacade.class); public static void main(String[] args) { //Create the JLBH options you require for the benchmark @@ -76,7 +78,6 @@ public class MapJLBHTest implements JLBHTask { } } - private long counter = -WARM_UP_ITERATIONS; @Override public void run(long startTimeNS) { long runNo = counter++; @@ -106,191 +107,684 @@ public class MapJLBHTest implements JLBHTask { read.close(); } - private IFacade datum = Values.newNativeReference(IFacade.class); - //IFacade (at the bottom) is the façade we need tested interface IFacadeBase { - short getValue0(); void setValue0(short value); - byte getValue1(); void setValue1(byte value); - byte getValue2(); void setValue2(byte value); - int getValue3(); void setValue3(int value); - short getValue4(); void setValue4(short value); - boolean getValue5(); void setValue5(boolean value); - boolean getValue6(); void setValue6(boolean value); - short getValue7(); void setValue7(short value); - short getValue8(); void setValue8(short value); - long getValue9(); void setValue9(long value); - long getValue10(); void setValue10(long value); - long getValue11(); void setValue11(long value); - long getValue12(); void setValue12(long value); - long getValue13(); void setValue13(long value); - long getValue14(); void setValue14(long value); - long getValue15(); void setValue15(long value); - short getValue16(); void setValue16(short value); - short getValue17(); void setValue17(short value); - short getValue18(); void setValue18(short value); + short getValue0(); + + void setValue0(short value); + + byte getValue1(); + + void setValue1(byte value); + + byte getValue2(); + + void setValue2(byte value); + + int getValue3(); + + void setValue3(int value); + + short getValue4(); + + void setValue4(short value); + + boolean getValue5(); + + void setValue5(boolean value); + + boolean getValue6(); + + void setValue6(boolean value); + + short getValue7(); + + void setValue7(short value); + + short getValue8(); + + void setValue8(short value); + + long getValue9(); + + void setValue9(long value); + + long getValue10(); + + void setValue10(long value); + + long getValue11(); + + void setValue11(long value); + + long getValue12(); + + void setValue12(long value); + + long getValue13(); + + void setValue13(long value); + + long getValue14(); + + void setValue14(long value); + + long getValue15(); + + void setValue15(long value); + + short getValue16(); + + void setValue16(short value); + + short getValue17(); + + void setValue17(short value); + + short getValue18(); + + void setValue18(short value); } interface IFacadeSon extends IFacadeBase { - long getValue19(); void setValue19(long value); - int getValue20(); void setValue20(int value); - int getValue21(); void setValue21(int value); - double getValue22(); void setValue22(double value); - String getValue23(); void setValue23(@MaxUtf8Length(10) String value); - int getValue24(); void setValue24(int value); - double getValue25(); void setValue25(double value); - byte getValue26(); void setValue26(byte value); - double getValue27(); void setValue27(double value); - double getValue28(); void setValue28(double value); - double getValue29(); void setValue29(double value); - double getValue30(); void setValue30(double value); - double getValue31(); void setValue31(double value); - double getValue32(); void setValue32(double value); + long getValue19(); + + void setValue19(long value); + + int getValue20(); + + void setValue20(int value); + + int getValue21(); + + void setValue21(int value); + + double getValue22(); + + void setValue22(double value); + + String getValue23(); + + void setValue23(@MaxUtf8Length(10) String value); + + int getValue24(); + + void setValue24(int value); + + double getValue25(); + + void setValue25(double value); + + byte getValue26(); + + void setValue26(byte value); + + double getValue27(); + + void setValue27(double value); + + double getValue28(); + + void setValue28(double value); + + double getValue29(); + + void setValue29(double value); + + double getValue30(); + + void setValue30(double value); + + double getValue31(); + + void setValue31(double value); + + double getValue32(); + + void setValue32(double value); } interface IFacadeDaughter extends IFacadeBase { - long getValue33(); void setValue33(long value); - String getValue34(); void setValue34(@MaxUtf8Length(11)String value); - int getValue35(); void setValue35(int value); - String getValue36(); void setValue36(@MaxUtf8Length(11)String value); - int getValue37(); void setValue37(int value); - long getValue38(); void setValue38(long value); - short getValue39(); void setValue39(short value); - long getValue40(); void setValue40(long value); - String getValue41(); void setValue41(@MaxUtf8Length(43)String value); - long getValue42(); void setValue42(long value); - long getValue43(); void setValue43(long value); - long getValue44(); void setValue44(long value); - long getValue45(); void setValue45(long value); - long getValue46(); void setValue46(long value); - byte getValue47(); void setValue47(byte value); - byte getValue48(); void setValue48(byte value); - double getValue49(); void setValue49(double value); - double getValue50(); void setValue50(double value); - double getValue51(); void setValue51(double value); - byte getValue52(); void setValue52(byte value); - byte getValue53(); void setValue53(byte value); - byte getValue54(); void setValue54(byte value); - byte getValue55(); void setValue55(byte value); - byte getValue56(); void setValue56(byte value); - long getValue57(); void setValue57(long value); - byte getValue58(); void setValue58(byte value); - double getValue59(); void setValue59(double value); - double getValue60(); void setValue60(double value); - double getValue61(); void setValue61(double value); - double getValue62(); void setValue62(double value); - double getValue63(); void setValue63(double value); - long getValue64(); void setValue64(long value); - long getValue65(); void setValue65(long value); - double getValue66(); void setValue66(double value); - double getValue67(); void setValue67(double value); - short getValue68(); void setValue68(short value); - String getValue69(); void setValue69(@MaxUtf8Length(101)String value); - String getValue70(); void setValue70(@MaxUtf8Length(17)String value); - boolean getValue71(); void setValue71(boolean value); - boolean getValue72(); void setValue72(boolean value); - String getValue73(); void setValue73(@MaxUtf8Length(11)String value); - String getValue74(); void setValue74(@MaxUtf8Length(9)String value); - byte getValue75(); void setValue75(byte value); - int getValue76(); void setValue76(int value); - int getValue77(); void setValue77(int value); - String getValue78(); void setValue78(@MaxUtf8Length(3)String value); - int getValue79(); void setValue79(int value); - double getValue80(); void setValue80(double value); - byte getValue81(); void setValue81(byte value); - byte getValue82(); void setValue82(byte value); - byte getValue83(); void setValue83(byte value); - byte getValue84(); void setValue84(byte value); - byte getValue85(); void setValue85(byte value); - byte getValue86(); void setValue86(byte value); - byte getValue87(); void setValue87(byte value); - byte getValue88(); void setValue88(byte value); - int getValue89(); void setValue89(int value); - int getValue90(); void setValue90(int value); - int getValue91(); void setValue91(int value); - int getValue92(); void setValue92(int value); - int getValue93(); void setValue93(int value); - int getValue94(); void setValue94(int value); - int getValue95(); void setValue95(int value); - int getValue96(); void setValue96(int value); - int getValue97(); void setValue97(int value); - int getValue98(); void setValue98(int value); - int getValue99(); void setValue99(int value); - int getValue100(); void setValue100(int value); - int getValue101(); void setValue101(int value); - int getValue102(); void setValue102(int value); - int getValue103(); void setValue103(int value); - int getValue104(); void setValue104(int value); - double getValue105(); void setValue105(double value); - double getValue106(); void setValue106(double value); - long getValue107(); void setValue107(long value); - long getValue108(); void setValue108(long value); - long getValue109(); void setValue109(long value); - byte getValue110(); void setValue110(byte value); - byte getValue111(); void setValue111(byte value); - byte getValue112(); void setValue112(byte value); - byte getValue113(); void setValue113(byte value); - byte getValue114(); void setValue114(byte value); - byte getValue115(); void setValue115(byte value); - byte getValue116(); void setValue116(byte value); - byte getValue117(); void setValue117(byte value); - byte getValue118(); void setValue118(byte value); - byte getValue119(); void setValue119(byte value); - byte getValue120(); void setValue120(byte value); - byte getValue121(); void setValue121(byte value); - byte getValue122(); void setValue122(byte value); - byte getValue123(); void setValue123(byte value); - byte getValue124(); void setValue124(byte value); - byte getValue125(); void setValue125(byte value); - int getValue126(); void setValue126(int value); - int getValue127(); void setValue127(int value); - int getValue128(); void setValue128(int value); - int getValue129(); void setValue129(int value); - int getValue130(); void setValue130(int value); - int getValue131(); void setValue131(int value); - int getValue132(); void setValue132(int value); - int getValue133(); void setValue133(int value); - int getValue134(); void setValue134(int value); - int getValue135(); void setValue135(int value); - int getValue136(); void setValue136(int value); - int getValue137(); void setValue137(int value); - int getValue138(); void setValue138(int value); - int getValue139(); void setValue139(int value); - int getValue140(); void setValue140(int value); - int getValue141(); void setValue141(int value); - double getValue142(); void setValue142(double value); - double getValue143(); void setValue143(double value); - byte getValue144(); void setValue144(byte value); - String getValue145(); void setValue145(@MaxUtf8Length(3)String value); - short getValue146(); void setValue146(short value); - byte getValue147(); void setValue147(byte value); - byte getValue148(); void setValue148(byte value); - int getValue149(); void setValue149(int value); - short getValue150(); void setValue150(short value); - boolean getValue151(); void setValue151(boolean value); - boolean getValue152(); void setValue152(boolean value); - short getValue153(); void setValue153(short value); - short getValue154(); void setValue154(short value); - long getValue155(); void setValue155(long value); - long getValue156(); void setValue156(long value); - long getValue157(); void setValue157(long value); - long getValue158(); void setValue158(long value); - long getValue159(); void setValue159(long value); - long getValue160(); void setValue160(long value); - long getValue161(); void setValue161(long value); - short getValue162(); void setValue162(short value); - short getValue163(); void setValue163(short value); - short getValue164(); void setValue164(short value); + long getValue33(); + + void setValue33(long value); + + String getValue34(); + + void setValue34(@MaxUtf8Length(11) String value); + + int getValue35(); + + void setValue35(int value); + + String getValue36(); + + void setValue36(@MaxUtf8Length(11) String value); + + int getValue37(); + + void setValue37(int value); + + long getValue38(); + + void setValue38(long value); + + short getValue39(); + + void setValue39(short value); + + long getValue40(); + + void setValue40(long value); + + String getValue41(); + + void setValue41(@MaxUtf8Length(43) String value); + + long getValue42(); + + void setValue42(long value); + + long getValue43(); + + void setValue43(long value); + + long getValue44(); + + void setValue44(long value); + + long getValue45(); + + void setValue45(long value); + + long getValue46(); + + void setValue46(long value); + + byte getValue47(); + + void setValue47(byte value); + + byte getValue48(); + + void setValue48(byte value); + + double getValue49(); + + void setValue49(double value); + + double getValue50(); + + void setValue50(double value); + + double getValue51(); + + void setValue51(double value); + + byte getValue52(); + + void setValue52(byte value); + + byte getValue53(); + + void setValue53(byte value); + + byte getValue54(); + + void setValue54(byte value); + + byte getValue55(); + + void setValue55(byte value); + + byte getValue56(); + + void setValue56(byte value); + + long getValue57(); + + void setValue57(long value); + + byte getValue58(); + + void setValue58(byte value); + + double getValue59(); + + void setValue59(double value); + + double getValue60(); + + void setValue60(double value); + + double getValue61(); + + void setValue61(double value); + + double getValue62(); + + void setValue62(double value); + + double getValue63(); + + void setValue63(double value); + + long getValue64(); + + void setValue64(long value); + + long getValue65(); + + void setValue65(long value); + + double getValue66(); + + void setValue66(double value); + + double getValue67(); + + void setValue67(double value); + + short getValue68(); + + void setValue68(short value); + + String getValue69(); + + void setValue69(@MaxUtf8Length(101) String value); + + String getValue70(); + + void setValue70(@MaxUtf8Length(17) String value); + + boolean getValue71(); + + void setValue71(boolean value); + + boolean getValue72(); + + void setValue72(boolean value); + + String getValue73(); + + void setValue73(@MaxUtf8Length(11) String value); + + String getValue74(); + + void setValue74(@MaxUtf8Length(9) String value); + + byte getValue75(); + + void setValue75(byte value); + + int getValue76(); + + void setValue76(int value); + + int getValue77(); + + void setValue77(int value); + + String getValue78(); + + void setValue78(@MaxUtf8Length(3) String value); + + int getValue79(); + + void setValue79(int value); + + double getValue80(); + + void setValue80(double value); + + byte getValue81(); + + void setValue81(byte value); + + byte getValue82(); + + void setValue82(byte value); + + byte getValue83(); + + void setValue83(byte value); + + byte getValue84(); + + void setValue84(byte value); + + byte getValue85(); + + void setValue85(byte value); + + byte getValue86(); + + void setValue86(byte value); + + byte getValue87(); + + void setValue87(byte value); + + byte getValue88(); + + void setValue88(byte value); + + int getValue89(); + + void setValue89(int value); + + int getValue90(); + + void setValue90(int value); + + int getValue91(); + + void setValue91(int value); + + int getValue92(); + + void setValue92(int value); + + int getValue93(); + + void setValue93(int value); + + int getValue94(); + + void setValue94(int value); + + int getValue95(); + + void setValue95(int value); + + int getValue96(); + + void setValue96(int value); + + int getValue97(); + + void setValue97(int value); + + int getValue98(); + + void setValue98(int value); + + int getValue99(); + + void setValue99(int value); + + int getValue100(); + + void setValue100(int value); + + int getValue101(); + + void setValue101(int value); + + int getValue102(); + + void setValue102(int value); + + int getValue103(); + + void setValue103(int value); + + int getValue104(); + + void setValue104(int value); + + double getValue105(); + + void setValue105(double value); + + double getValue106(); + + void setValue106(double value); + + long getValue107(); + + void setValue107(long value); + + long getValue108(); + + void setValue108(long value); + + long getValue109(); + + void setValue109(long value); + + byte getValue110(); + + void setValue110(byte value); + + byte getValue111(); + + void setValue111(byte value); + + byte getValue112(); + + void setValue112(byte value); + + byte getValue113(); + + void setValue113(byte value); + + byte getValue114(); + + void setValue114(byte value); + + byte getValue115(); + + void setValue115(byte value); + + byte getValue116(); + + void setValue116(byte value); + + byte getValue117(); + + void setValue117(byte value); + + byte getValue118(); + + void setValue118(byte value); + + byte getValue119(); + + void setValue119(byte value); + + byte getValue120(); + + void setValue120(byte value); + + byte getValue121(); + + void setValue121(byte value); + + byte getValue122(); + + void setValue122(byte value); + + byte getValue123(); + + void setValue123(byte value); + + byte getValue124(); + + void setValue124(byte value); + + byte getValue125(); + + void setValue125(byte value); + + int getValue126(); + + void setValue126(int value); + + int getValue127(); + + void setValue127(int value); + + int getValue128(); + + void setValue128(int value); + + int getValue129(); + + void setValue129(int value); + + int getValue130(); + + void setValue130(int value); + + int getValue131(); + + void setValue131(int value); + + int getValue132(); + + void setValue132(int value); + + int getValue133(); + + void setValue133(int value); + + int getValue134(); + + void setValue134(int value); + + int getValue135(); + + void setValue135(int value); + + int getValue136(); + + void setValue136(int value); + + int getValue137(); + + void setValue137(int value); + + int getValue138(); + + void setValue138(int value); + + int getValue139(); + + void setValue139(int value); + + int getValue140(); + + void setValue140(int value); + + int getValue141(); + + void setValue141(int value); + + double getValue142(); + + void setValue142(double value); + + double getValue143(); + + void setValue143(double value); + + byte getValue144(); + + void setValue144(byte value); + + String getValue145(); + + void setValue145(@MaxUtf8Length(3) String value); + + short getValue146(); + + void setValue146(short value); + + byte getValue147(); + + void setValue147(byte value); + + byte getValue148(); + + void setValue148(byte value); + + int getValue149(); + + void setValue149(int value); + + short getValue150(); + + void setValue150(short value); + + boolean getValue151(); + + void setValue151(boolean value); + + boolean getValue152(); + + void setValue152(boolean value); + + short getValue153(); + + void setValue153(short value); + + short getValue154(); + + void setValue154(short value); + + long getValue155(); + + void setValue155(long value); + + long getValue156(); + + void setValue156(long value); + + long getValue157(); + + void setValue157(long value); + + long getValue158(); + + void setValue158(long value); + + long getValue159(); + + void setValue159(long value); + + long getValue160(); + + void setValue160(long value); + + long getValue161(); + + void setValue161(long value); + + short getValue162(); + + void setValue162(short value); + + short getValue163(); + + void setValue163(short value); + + short getValue164(); + + void setValue164(short value); } interface IFacade extends IFacadeBase { - @Array(length=3) + @Array(length = 3) void setDaughterAt(int idx, IFacadeDaughter daughter); + IFacadeDaughter getDaughterAt(int idx); - @Array(length=3) + + @Array(length = 3) void setSonAt(int idx, IFacadeSon son); + IFacadeSon getSonAt(int idx); } } 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 55e478d3b..0c7e57b14 100644 --- a/src/test/java/net/openhft/chronicle/map/perf/MapStress.java +++ b/src/test/java/net/openhft/chronicle/map/perf/MapStress.java @@ -24,6 +24,12 @@ public class MapStress { public MapStress() throws IOException { } + public static void main(String[] args) throws Exception { +// if (file.exists()) +// file.delete(); + new MapStress().stress(); + } + public void stress() throws ExecutionException, InterruptedException { Security[] secs = new Security[5]; secs[0] = new Security(); @@ -91,7 +97,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(() -> { @@ -102,7 +108,7 @@ Future[] futures = new Future[N_WRITE_THREADS + N_READ_THREADS]; final Random random = ThreadLocalRandom.current(); IntStream.range(0, 10).forEach(x -> { final int keyIdx = random.nextInt(N_WRITE_THREADS * 100); - Security sec = secs[x%5]; + Security sec = secs[x % 5]; sec.calculationTimeMillis = time; map.put("valuekdljashjgffkljakljsdffhh" + keyIdx, sec); }); @@ -137,12 +143,6 @@ Future[] futures = new Future[N_WRITE_THREADS + N_READ_THREADS]; executor.shutdown(); } - public static void main(String[] args) throws Exception { -// if (file.exists()) -// file.delete(); - new MapStress().stress(); - } - public static class Security implements Serializable { String securityTicker; 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 f267af595..c959bce46 100755 --- a/src/test/java/net/openhft/chronicle/map/watcher/MapFileManager.java +++ b/src/test/java/net/openhft/chronicle/map/watcher/MapFileManager.java @@ -28,6 +28,7 @@ public class MapFileManager extends JMXFileManager implements MapFileManagerMBea private String name; private long dataStoreSize; private int segments; + private long lastUpdate = 0; public MapFileManager(String basePath, String relativePath) { super(basePath, relativePath); @@ -38,19 +39,17 @@ public class MapFileManager extends JMXFileManager implements MapFileManagerMBea return "maps"; } - private long lastUpdate = 0; - public String getHeader() { update(); return header; } public String getKeyClass() { - return ""+keyClass; + return "" + keyClass; } public String getValueClass() { - return ""+valueClass; + return "" + valueClass; } public long getSize() { @@ -104,7 +103,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(); diff --git a/src/test/java/net/openhft/chronicle/map/watcher/MapWatcherMain.java b/src/test/java/net/openhft/chronicle/map/watcher/MapWatcherMain.java index 745028733..7a2d09de7 100644 --- a/src/test/java/net/openhft/chronicle/map/watcher/MapWatcherMain.java +++ b/src/test/java/net/openhft/chronicle/map/watcher/MapWatcherMain.java @@ -24,7 +24,7 @@ public class MapWatcherMain { System.setProperty("hawtio.authenticationEnabled", "false"); Main main = new Main(); - main.setWar(Jvm.userHome() +"/OpenHFT/hawtio-default-2.7.1.war"); + main.setWar(Jvm.userHome() + "/OpenHFT/hawtio-default-2.7.1.war"); main.run(); } } diff --git a/src/test/java/net/openhft/lang/values/ArrayTest.java b/src/test/java/net/openhft/lang/values/ArrayTest.java index db9178725..815b2414d 100644 --- a/src/test/java/net/openhft/lang/values/ArrayTest.java +++ b/src/test/java/net/openhft/lang/values/ArrayTest.java @@ -33,7 +33,7 @@ import static org.junit.Assert.assertEquals; public class ArrayTest { @Test - public void test0() throws IOException, JSONException{ + public void test0() throws IOException, JSONException { ClassAliasPool.CLASS_ALIASES.addAlias(MovingAverageArray.class); File file = new File(OS.getTarget() + "/pf-PosistionsAndClose-" + Time.uniqueId());