From 125577b96e3b74fd4b0cde2a30d98001c5c3ee57 Mon Sep 17 00:00:00 2001 From: Peter Lawrey Date: Mon, 28 Jun 2021 12:49:39 +0100 Subject: [PATCH] Use Jvm.{level}() handlers instead of calling loggers directly, and unit tests cleanup esp use of @After, https://github.com/OpenHFT/Chronicle-Core/issues/233 --- .../hash/ChronicleHashBuilderPrivateAPI.java | 2 - .../impl/ChronicleHashCloseOnExitHook.java | 11 ++-- .../hash/impl/ChronicleHashResources.java | 11 ++-- .../chronicle/hash/impl/TierCountersArea.java | 3 +- .../impl/stage/entry/ChecksumHashing.java | 3 +- .../hash/impl/stage/entry/SegmentStages.java | 5 +- .../hash/impl/stage/hash/LogHolder.java | 1 - .../impl/stage/iter/SegmentsRecovery.java | 4 +- .../hash/impl/stage/iter/TierRecovery.java | 6 +-- .../hash/impl/util/CleanerUtils.java | 8 ++- .../hash/impl/util/jna/PosixFallocate.java | 7 +-- .../chronicle/map/ChronicleMapBuilder.java | 17 ++---- .../openhft/chronicle/map/JsonSerializer.java | 11 ++-- .../map/OldDeletedEntriesCleanupThread.java | 9 ++-- .../chronicle/map/ReplicatedChronicleMap.java | 32 +++++------ .../map/impl/MapIterationContext.java | 2 - .../chronicle/map/impl/MapQueryContext.java | 2 - .../impl/ReplicatedMapIterationContext.java | 2 - .../map/impl/ReplicatedMapQueryContext.java | 2 - .../map/locks/ChronicleStampedLock.java | 54 +++++++++---------- .../chronicle/set/ChronicleSetBuilder.java | 10 +--- .../xstream/converters/ValueConverter.java | 4 +- .../chronicle/map/BuildVersionTest.java | 2 - .../chronicle/map/Issue62ChronicleClient.java | 6 +-- .../chronicle/map/Issue62ChronicleServer.java | 3 +- .../acid/exodus/DirtyReadOffender.java | 3 +- .../fromdocs/acid/exodus/DirtyReadVictim.java | 3 +- .../acid/genesis/DirtyReadOffender.java | 3 +- .../acid/genesis/DirtyReadVictim.java | 3 +- .../revelations/ChronicleStampedLock.java | 3 +- .../acid/revelations/DirtyReadIntolerant.java | 3 +- .../acid/revelations/DirtyReadOffender.java | 3 +- .../acid/revelations/DirtyReadVictimTest.java | 3 +- .../chronicle/map/ipc/StateMachineData.java | 12 ----- .../map/ipc/StateMachineProcessor.java | 21 +++----- .../chronicle/map/ipc/StateMachineState.java | 2 - .../map/locks/DirtyReadOffenderIPCTest.java | 3 +- .../map/locks/DirtyReadOffenderTest.java | 3 +- .../map/locks/DirtyReadVictimIPCTest.java | 7 +-- .../map/utility/ProcessInstanceLimiter.java | 1 - 40 files changed, 110 insertions(+), 180 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/hash/ChronicleHashBuilderPrivateAPI.java b/src/main/java/net/openhft/chronicle/hash/ChronicleHashBuilderPrivateAPI.java index 339b0d666..0450f7eb7 100644 --- a/src/main/java/net/openhft/chronicle/hash/ChronicleHashBuilderPrivateAPI.java +++ b/src/main/java/net/openhft/chronicle/hash/ChronicleHashBuilderPrivateAPI.java @@ -59,7 +59,6 @@ public interface ChronicleHashBuilderPrivateAPI { *

Default value is {@code true} -- old removed entries are erased with 1 second timeout. * * @param cleanupRemovedEntries if stale removed entries should be purged from Chronicle Hash - * @return this builder back * @see #removedEntryCleanupTimeout(long, TimeUnit) * @see ReplicableEntry#doRemoveCompletely() */ @@ -81,7 +80,6 @@ public interface ChronicleHashBuilderPrivateAPI { * @param removedEntryCleanupTimeout timeout, after which stale removed entries could be erased * from Chronicle Hash data store completely * @param unit time unit, in which the timeout is given - * @return this builder back * @throws IllegalArgumentException is the specified timeout is less than 1 millisecond * @see #cleanupRemovedEntries(boolean) * @see ReplicableEntry#doRemoveCompletely() diff --git a/src/main/java/net/openhft/chronicle/hash/impl/ChronicleHashCloseOnExitHook.java b/src/main/java/net/openhft/chronicle/hash/impl/ChronicleHashCloseOnExitHook.java index ca4d5633f..9dc248aa1 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/ChronicleHashCloseOnExitHook.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/ChronicleHashCloseOnExitHook.java @@ -16,6 +16,7 @@ package net.openhft.chronicle.hash.impl; +import net.openhft.chronicle.core.Jvm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,7 +24,6 @@ import java.util.TreeMap; import java.util.WeakHashMap; final class ChronicleHashCloseOnExitHook { - private static final Logger LOG = LoggerFactory.getLogger(ChronicleHashCloseOnExitHook.class); private static WeakHashMap maps = new WeakHashMap<>(); private static long order = 0; @@ -66,7 +66,8 @@ final class ChronicleHashCloseOnExitHook { preShutdownAction.run(); } catch (Throwable throwable) { try { - LOG.error("Error running pre-shutdown action for " + h.toIdentityString() + + Jvm.error().on(ChronicleHashCloseOnExitHook.class, + "Error running pre-shutdown action for " + h.toIdentityString() + " :", throwable); } catch (Throwable t2) { throwable.addSuppressed(t2); @@ -77,7 +78,8 @@ final class ChronicleHashCloseOnExitHook { h.close(); } catch (Throwable throwable) { try { - LOG.error("Error while closing " + h.toIdentityString() + + Jvm.error().on(ChronicleHashCloseOnExitHook.class, + "Error while closing " + h.toIdentityString() + " during shutdown hook:", throwable); } catch (Throwable t2) { // This may occur if the log service has already been shut down. Try to fall @@ -89,7 +91,8 @@ final class ChronicleHashCloseOnExitHook { }); } catch (Throwable throwable) { try { - LOG.error("Error while closing maps during shutdown hook:", throwable); + Jvm.error().on(ChronicleHashCloseOnExitHook.class, + "Error while closing maps during shutdown hook:", throwable); } catch (Throwable t2) { throwable.addSuppressed(t2); throwable.printStackTrace(); diff --git a/src/main/java/net/openhft/chronicle/hash/impl/ChronicleHashResources.java b/src/main/java/net/openhft/chronicle/hash/impl/ChronicleHashResources.java index 4efd6c785..a114edeae 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/ChronicleHashResources.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/ChronicleHashResources.java @@ -16,6 +16,7 @@ package net.openhft.chronicle.hash.impl; +import net.openhft.chronicle.core.Jvm; import net.openhft.chronicle.hash.ChronicleHashClosedException; import net.openhft.chronicle.hash.impl.stage.hash.ChainingInterface; import net.openhft.chronicle.hash.impl.util.Throwables; @@ -32,7 +33,6 @@ import java.util.List; * ChronicleHashResources is Runnable to be passed as "hunk" to {@link sun.misc.Cleaner}. */ public abstract class ChronicleHashResources implements Runnable { - private static final Logger LOG = LoggerFactory.getLogger(ChronicleHashResources.class); private static final int OPEN = 0; private static final int PARTIALLY_CLOSED = 1; @@ -123,22 +123,21 @@ public abstract class ChronicleHashResources implements Runnable { if (state == COMPLETELY_CLOSED) return; try { - LOG.error("{} is not closed manually, cleaned up from Cleaner", - chronicleHashIdentityString); + Jvm.error().on(getClass(), chronicleHashIdentityString+" is not closed manually, cleaned up from Cleaner" ); } catch (Throwable t) { thrown = t; } finally { synchronized (this) { if (state == COMPLETELY_CLOSED) { - LOG.error("Somebody closed {} while it is processed by Cleaner, " + - "this should be impossible", chronicleHashIdentityString); + Jvm.error().on(getClass(), "Somebody closed "+chronicleHashIdentityString+" while it is processed by Cleaner, " + + "this should be impossible"); } else { thrown = Throwables.returnOrSuppress(thrown, releaseEverything(true)); } } if (thrown != null) { try { - LOG.error("Error on releasing resources of " + chronicleHashIdentityString, + Jvm.error().on(getClass(), "Error on releasing resources of " + chronicleHashIdentityString, thrown); } catch (Throwable t) { // This may occur if we are in shutdown hooks, and the log service has diff --git a/src/main/java/net/openhft/chronicle/hash/impl/TierCountersArea.java b/src/main/java/net/openhft/chronicle/hash/impl/TierCountersArea.java index 51c530647..c7cb7d073 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/TierCountersArea.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/TierCountersArea.java @@ -25,8 +25,7 @@ import net.openhft.chronicle.core.OS; * are stateful - so need to keep an instance in thread local that seems to be overall more pain * than gain. */ -public enum TierCountersArea { - ; +public enum TierCountersArea {; public static final long NEXT_TIER_INDEX_OFFSET = 0L; public static final long PREV_TIER_INDEX_OFFSET = NEXT_TIER_INDEX_OFFSET + 8L; diff --git a/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/ChecksumHashing.java b/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/ChecksumHashing.java index 72243a8f8..f20e8f454 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/ChecksumHashing.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/ChecksumHashing.java @@ -16,8 +16,7 @@ package net.openhft.chronicle.hash.impl.stage.entry; -public enum ChecksumHashing { - ; +public enum ChecksumHashing {; /** * A smart procedure copied from CityHash/FarmHash, see the full implementation in diff --git a/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/SegmentStages.java b/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/SegmentStages.java index bad6ebe10..2a448f4b1 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/SegmentStages.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/stage/entry/SegmentStages.java @@ -22,6 +22,7 @@ import net.openhft.chronicle.algo.bytes.Access; import net.openhft.chronicle.bytes.Bytes; import net.openhft.chronicle.bytes.PointerBytesStore; import net.openhft.chronicle.bytes.VanillaBytes; +import net.openhft.chronicle.core.Jvm; import net.openhft.chronicle.core.io.IOTools; import net.openhft.chronicle.hash.Data; import net.openhft.chronicle.hash.SegmentLock; @@ -97,8 +98,6 @@ public abstract class SegmentStages implements SegmentLock, LocksInterface { @Stage("Segment") public long entrySpaceOffset = 0; @StageRef - LogHolder log; - @StageRef Chaining chaining; // chain @Stage("Locks") @@ -607,7 +606,7 @@ public abstract class SegmentStages implements SegmentLock, LocksInterface { VanillaChronicleHash h = hh.h(); long nextTierIndex = nextTierIndex(); if (nextTierIndex == 0) { - log.LOG.debug("Allocate tier for segment # {}, tier {}", segmentIndex, tier + 1); + Jvm.debug().on(getClass(), "Allocate tier for segment # " + segmentIndex + " tier " +( tier + 1)); nextTierIndex = h.allocateTier(); nextTierIndex(nextTierIndex); long prevTierIndex = tierIndex; diff --git a/src/main/java/net/openhft/chronicle/hash/impl/stage/hash/LogHolder.java b/src/main/java/net/openhft/chronicle/hash/impl/stage/hash/LogHolder.java index eef568a95..fcfa2748f 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/stage/hash/LogHolder.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/stage/hash/LogHolder.java @@ -22,5 +22,4 @@ import org.slf4j.LoggerFactory; @Staged public class LogHolder { - public static final Logger LOG = LoggerFactory.getLogger(LogHolder.class); } 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 b651ec0bb..3505a1d28 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 @@ -96,7 +96,7 @@ public abstract class SegmentsRecovery implements IterationContext { long finalActualExtraTiersInUse = actualExtraTiersInUse; report(corruptionListener, corruption, -1, () -> format("wrong number of actual tiers in use in global mutable state, stored: {}, " + - "should be: {}", storedExtraTiersInUse, finalActualExtraTiersInUse) + "should be: " + storedExtraTiersInUse, finalActualExtraTiersInUse) ); globalMutableState.setExtraTiersInUse(actualExtraTiersInUse); } @@ -119,7 +119,7 @@ public abstract class SegmentsRecovery implements IterationContext { if (storedFirstFreeTierIndex != firstFreeTierIndex) { report(corruptionListener, corruption, -1, () -> format("wrong first free tier index in global mutable state, stored: {}, " + - "should be: {}", storedFirstFreeTierIndex, firstFreeTierIndex) + "should be: " + storedFirstFreeTierIndex, firstFreeTierIndex) ); globalMutableState.setFirstFreeTierIndex(firstFreeTierIndex); } diff --git a/src/main/java/net/openhft/chronicle/hash/impl/stage/iter/TierRecovery.java b/src/main/java/net/openhft/chronicle/hash/impl/stage/iter/TierRecovery.java index 450208baa..c184e5458 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/stage/iter/TierRecovery.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/stage/iter/TierRecovery.java @@ -233,7 +233,7 @@ public class TierRecovery { if (s.tierEntries() != entries) { report(corruptionListener, corruption, s.segmentIndex, () -> format("Wrong number of entries counter for tier with index {}, " + - "stored: {}, should be: {}", s.tierIndex, s.tierEntries(), entries) + "stored: {}, should be: " + s.tierIndex, s.tierEntries(), entries) ); s.tierEntries(entries); } @@ -277,7 +277,7 @@ public class TierRecovery { } if (e.keyEnd() > s.segmentBytes.capacity()) { report(corruptionListener, corruption, segmentIndex, () -> - format("Wrong key size: {}", e.keySize) + format("Wrong key size: " + e.keySize) ); return -1; } @@ -309,7 +309,7 @@ public class TierRecovery { long entryAndChecksumEnd = e.entryEnd() + e.checksumStrategy.extraEntryBytes(); if (entryAndChecksumEnd > s.segmentBytes.capacity()) { report(corruptionListener, corruption, segmentIndex, () -> - format("Wrong value size: {}, key: {}", e.valueSize, e.key()) + format("Wrong value size: {}, key: " + e.valueSize, e.key()) ); return -1; } diff --git a/src/main/java/net/openhft/chronicle/hash/impl/util/CleanerUtils.java b/src/main/java/net/openhft/chronicle/hash/impl/util/CleanerUtils.java index ae7b46883..e94ef6042 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/util/CleanerUtils.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/util/CleanerUtils.java @@ -25,8 +25,6 @@ import java.lang.reflect.Method; public class CleanerUtils { - private static final Logger LOGGER = LoggerFactory.getLogger(CleanerUtils.class); - private static final Method CREATE_METHOD; private static final Method CLEAN_METHOD; @@ -38,7 +36,7 @@ public class CleanerUtils { CLEAN_METHOD = cleanerClass.getDeclaredMethod("clean"); Jvm.setAccessible(CLEAN_METHOD); } catch (ClassNotFoundException | NoSuchMethodException e) { - LOGGER.error("Unable to initialise CleanerUtils", e); + Jvm.error().on(CleanerUtils.class, "Unable to initialise CleanerUtils", e); throw new RuntimeException(e); } } @@ -48,7 +46,7 @@ public class CleanerUtils { Object cleanerInstance = CREATE_METHOD.invoke(null, ob, thunk); return () -> doClean(cleanerInstance); } catch (IllegalAccessException | InvocationTargetException e) { - LOGGER.error("Unable to create cleaner", e); + Jvm.error().on(CleanerUtils.class, "Unable to create cleaner", e); throw new RuntimeException(e); } } @@ -57,7 +55,7 @@ public class CleanerUtils { try { CLEAN_METHOD.invoke(cleanerInstance); } catch (IllegalAccessException | InvocationTargetException e) { - LOGGER.warn("Failed to clean buffer", e); + Jvm.warn().on(CleanerUtils.class, "Failed to clean buffer", e); } } } diff --git a/src/main/java/net/openhft/chronicle/hash/impl/util/jna/PosixFallocate.java b/src/main/java/net/openhft/chronicle/hash/impl/util/jna/PosixFallocate.java index a3eaff4dd..c477ad56e 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/util/jna/PosixFallocate.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/util/jna/PosixFallocate.java @@ -11,9 +11,6 @@ import java.lang.reflect.Field; public final class PosixFallocate { - private static final Logger LOG = - LoggerFactory.getLogger(PosixFallocate.class.getName()); - static { Native.register(Platform.C_LIBRARY_NAME); } @@ -26,7 +23,7 @@ public final class PosixFallocate { if (fd != -1) { int ret = posix_fallocate(getNativeFileDescriptor(descriptor), offset, length); if (ret != 0) { - LOG.warn("posix_fallocate() returned {}", ret); + Jvm.warn().on(PosixFallocate.class, "posix_fallocate() returned " + ret); } } } @@ -39,7 +36,7 @@ public final class PosixFallocate { Jvm.setAccessible(field); return (int) field.get(descriptor); } catch (final Exception e) { - LOG.warn("unsupported FileDescriptor implementation: e={}", e.getLocalizedMessage()); + Jvm.warn().on(PosixFallocate.class, "unsupported FileDescriptor implementation: e=" + e.getLocalizedMessage()); return -1; } } diff --git a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java index ac78fd126..48744360e 100644 --- a/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java +++ b/src/main/java/net/openhft/chronicle/map/ChronicleMapBuilder.java @@ -155,18 +155,12 @@ public final class ChronicleMapBuilder implements * Anyway, unlikely anyone ever need more than 1 billion segments. */ private static final int MAX_SEGMENTS = (1 << 30); - private static final Logger LOG = LoggerFactory.getLogger(ChronicleMapBuilder.class.getName()); private static final double UNDEFINED_DOUBLE_CONFIG = Double.NaN; private static final ConcurrentHashMap FILE_LOCKING_CONTROL = new ConcurrentHashMap<>(128); - private static final Logger CHRONICLE_MAP_LOGGER = LoggerFactory.getLogger(ChronicleMap.class); private static final ChronicleHashCorruption.Listener DEFAULT_CHRONICLE_MAP_CORRUPTION_LISTENER = corruption -> { - if (corruption.exception() != null) { - CHRONICLE_MAP_LOGGER.error(corruption.message(), corruption.exception()); - } else { - CHRONICLE_MAP_LOGGER.error(corruption.message()); - } + Jvm.error().on(ChronicleMapBuilder.class, corruption.message(), corruption.exception()); }; private static final int MAX_BOOTSTRAPPING_HEADER_SIZE = (int) MemoryUnit.KILOBYTES.toBytes(16); private static final boolean MAP_CREATION_DEBUG = Jvm.getBoolean("chronicle.map.creation.debug"); @@ -678,7 +672,7 @@ public final class ChronicleMapBuilder implements if (BytesMarshallable.class.isAssignableFrom(valueClass) && (valueBuilder.tClass.isInterface() && valueBuilder.tClass != Marshallable.class)) { if (Serializable.class.isAssignableFrom(valueClass)) - LOG.warn("BytesMarshallable " + valueClass + " will be serialized as Serializable as the value class is an interface"); + Jvm.warn().on(getClass(), "BytesMarshallable " + valueClass + " will be serialized as Serializable as the value class is an interface"); else throw new IllegalArgumentException("Using BytesMarshallable and an interface value type not supported"); } @@ -1714,9 +1708,8 @@ public final class ChronicleMapBuilder implements else { try { pauser.pause(10, TimeUnit.SECONDS); - } - catch (TimeoutException e) { - LOG.warn("Failed to write header: can't acquire exclusive file lock on empty file [" + canonicalFile + "] for 10 seconds", e); + } catch (TimeoutException e) { + Jvm.warn().on(getClass(), "Failed to write header: can't acquire exclusive file lock on empty file [" + canonicalFile + "] for 10 seconds", e); Jvm.rethrow(e); } @@ -1874,7 +1867,7 @@ public final class ChronicleMapBuilder implements if (MAP_CREATION_DEBUG) { Jvm.warn().on(getClass(), " Read header from file [canonizedMapDataFile=" + - file.getAbsolutePath() + "]: " + wire.toString()); + file.getAbsolutePath() + "]: " + wire); } final VanillaChronicleMap map = wire.getValueIn().typedMarshallable(); diff --git a/src/main/java/net/openhft/chronicle/map/JsonSerializer.java b/src/main/java/net/openhft/chronicle/map/JsonSerializer.java index 5edd6eac0..3236d0ffa 100644 --- a/src/main/java/net/openhft/chronicle/map/JsonSerializer.java +++ b/src/main/java/net/openhft/chronicle/map/JsonSerializer.java @@ -18,6 +18,7 @@ package net.openhft.chronicle.map; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.converters.Converter; import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; +import net.openhft.chronicle.core.Jvm; import net.openhft.xstream.converters.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,7 +50,6 @@ final class JsonSerializer { " jettison\n" + " 1.3.6\n" + "\n"; - private static final Logger LOG = LoggerFactory.getLogger(JsonSerializer.class); static synchronized void getAll(final File toFile, final Map map, @@ -57,7 +57,7 @@ final class JsonSerializer { final XStream xstream = xStream(map, jsonConverters); try (OutputStream outputStream = createOutputStream(toFile)) { - xstream.toXML(map, outputStream); + xstream.toXML(map, outputStream); } } @@ -101,9 +101,10 @@ final class JsonSerializer { if (c instanceof Converter) { xstream.registerConverter((Converter) c); } else { - LOG.warn("Skipping Converter of type class=" + c.getClass().getName() + " as " + - " expecting an object of type com.thoughtworks.xstream.converters" + - ".Converter"); + Jvm.warn().on(JsonSerializer.class, + "Skipping Converter of type class=" + c.getClass().getName() + " as " + + " expecting an object of type com.thoughtworks.xstream.converters" + + ".Converter"); } } diff --git a/src/main/java/net/openhft/chronicle/map/OldDeletedEntriesCleanupThread.java b/src/main/java/net/openhft/chronicle/map/OldDeletedEntriesCleanupThread.java index cce6ebb51..c36c91c95 100644 --- a/src/main/java/net/openhft/chronicle/map/OldDeletedEntriesCleanupThread.java +++ b/src/main/java/net/openhft/chronicle/map/OldDeletedEntriesCleanupThread.java @@ -16,6 +16,7 @@ package net.openhft.chronicle.map; +import net.openhft.chronicle.core.Jvm; import net.openhft.chronicle.hash.ChronicleHashBuilderPrivateAPI; import net.openhft.chronicle.hash.ReplicatedHashSegmentContext; import net.openhft.chronicle.hash.replication.ReplicableEntry; @@ -33,7 +34,6 @@ import static net.openhft.chronicle.hash.replication.TimeProvider.systemTimeInte class OldDeletedEntriesCleanupThread extends Thread implements MapClosable, Predicate { - private static final Logger LOG = LoggerFactory.getLogger(OldDeletedEntriesCleanupThread.class); /** * Don't store a strong ref to a map in order to avoid it's leaking, if the user forgets to close() map, from where this thread is shut down @@ -134,7 +134,7 @@ class OldDeletedEntriesCleanupThread extends Thread long currentTime = currentTime(); long mapScanTime = systemTimeIntervalBetween( prevSegment0ScanStart, currentTime, cleanupTimeoutUnit); - LOG.debug("Old deleted entries scan time: {} {}", mapScanTime, cleanupTimeoutUnit); + Jvm.debug().on(getClass(), "Old deleted entries scan time: " + mapScanTime + " " + cleanupTimeoutUnit); if (mapScanTime < cleanupTimeout) { long timeToSleep = cleanupTimeoutUnit.toMillis(cleanupTimeout - mapScanTime); if (timeToSleep > 0) { @@ -162,8 +162,9 @@ class OldDeletedEntriesCleanupThread extends Thread removedCompletely = 0; if (((ReplicatedHashSegmentContext) context) .forEachSegmentReplicableEntryWhile(this)) { - LOG.debug("Removed {} old deleted entries in the segment {}", - removedCompletely, segmentIndex); + Jvm.debug().on(getClass(), + "Removed " + removedCompletely + " old deleted entries " + + "in the segment " + segmentIndex); nextSegmentIndex = nextSegmentIndex(segmentIndex); map.globalMutableState().setCurrentCleanupSegmentIndex(nextSegmentIndex); return nextSegmentIndex; diff --git a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java index 7b1345af1..ebfc91bcd 100644 --- a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java @@ -19,6 +19,7 @@ package net.openhft.chronicle.map; import net.openhft.chronicle.algo.bitset.BitSetFrame; import net.openhft.chronicle.algo.bitset.SingleThreadedFlatBitSetFrame; import net.openhft.chronicle.bytes.Bytes; +import net.openhft.chronicle.core.Jvm; import net.openhft.chronicle.core.threads.EventHandler; import net.openhft.chronicle.core.threads.EventLoop; import net.openhft.chronicle.core.threads.HandlerPriority; @@ -107,7 +108,6 @@ public class ReplicatedChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap extends VanillaChronicleMap { if (debugEnabled) { - LOG.debug("Bootstrap entry: id {}, key {}, value {}", localIdentifier, - iterationContext.key(), iterationContext.value()); + Jvm.debug().on(getClass(), "Bootstrap entry: " + + "id " + localIdentifier + ", " + + "key " + iterationContext.key() + ", " + + "value " + iterationContext.value()); } // Bizarrely the next line line cause NPE in JDT compiler //assert re.originTimestamp() > 0L; if (debugEnabled) { - LOG.debug("Bootstrap decision: bs ts: {}, entry ts: {}, " + - "entry id: {}, local id: {}", - fromTimeStamp, e.originTimestamp(), - e.originIdentifier(), localIdentifier); + Jvm.debug().on(getClass(), "Bootstrap decision: " + + "bs ts: " + fromTimeStamp + ", " + + "entry ts: " + e.originTimestamp() + ", " + + "entry id: " + e.originIdentifier() + ", " + + "local id: " + localIdentifier); } // TODO currently, all entries, originating not from the current node, // are bootstrapped. This could be optimized, but requires to generate @@ -1060,10 +1063,9 @@ public class ReplicatedChronicleMap extends VanillaChronicleMap chm; //custody of StampedLock semantics ChronicleMap chmR; //Chronicle AtomicLong re: Reader set custody ChronicleMap chmW; //Chronicle AtomicLong re: Reader set custody @@ -55,7 +53,7 @@ public class ChronicleStampedLock extends StampedLock { chm.acquireUsing("LastWriterTime ", lastWriterT); //needed for validate chmR.acquireUsing("ReaderCount ", readLockHolderCount); chmW.acquireUsing("WriterCount ", readLockHolderCount); - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock constructed" + "," @@ -104,7 +102,7 @@ public class ChronicleStampedLock extends StampedLock { (offHeapLock = chm.get("Stamp ")).setEntryLockState(0L); long t = System.currentTimeMillis(); chm.put("Stamp ", offHeapLock); - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock saw stamp=[" + 0L + "]" + " tryOptmisticRead() returning stamp=" + @@ -119,7 +117,7 @@ public class ChronicleStampedLock extends StampedLock { offHeapLock = chm.get("Stamp "); lastWriterT = chm.get("LastWriterTime "); boolean ret = false; - /** + /* * If *any* Writer interacted with the offHeapLock, * since event=tryOptimisticRead(), * then FAIL the validate() invoke. @@ -134,14 +132,14 @@ public class ChronicleStampedLock extends StampedLock { } else { ret = Boolean.TRUE; } - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock validate(" + stamp + ") returned =[" + ret + "] " + "," ); - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock LastWriterT=[" + lastWriterT.getEntryLockState() + "] " + @@ -186,7 +184,7 @@ public class ChronicleStampedLock extends StampedLock { return 0L; do { - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock tryWriteLock() ?WAITING " + " on offHeapLock.unlock(" + @@ -218,13 +216,13 @@ public class ChronicleStampedLock extends StampedLock { writeLockHolderCount.addAtomicValue(+1); chmW.put("WriterCount ", writeLockHolderCount); - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock trywriteLock() ++ writeSeekers=[" + +writeLockHolderCount.getVolatileValue() + "] " + "..," ); - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock tryWriteLock() PROCEEDING " + " ," @@ -234,7 +232,7 @@ public class ChronicleStampedLock extends StampedLock { lastWriterT.setEntryLockState(t); chm.put("Stamp ", offHeapLock); chm.put("LastWriterTime ", lastWriterT); - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + t + " ChronicleStampedLock tryWriteLock() returned stamp=" + offHeapLock.getEntryLockState() + @@ -254,7 +252,7 @@ public class ChronicleStampedLock extends StampedLock { if (l < 0L) return (0); do { - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock tryReadLock() ?WAITING " + " on offHeapLock.unlock(" + @@ -274,7 +272,7 @@ public class ChronicleStampedLock extends StampedLock { } } while (l < 0L); - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock tryReadLock() PROCEEDING " + //" readerCount=[" + readerCount.getReaderCount() + "]" + @@ -292,7 +290,7 @@ public class ChronicleStampedLock extends StampedLock { ); // assign the Lock to most-recent Reader chm.put("Stamp ", offHeapLock); // make it IPC visible - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock tryReadLock() returned stamp=" + offHeapLock.getEntryLockState() + @@ -312,7 +310,7 @@ public class ChronicleStampedLock extends StampedLock { writeLockHolderCount = chmW.get("WriterCount "); do { - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock writeLock() ?WAITING " + " on offHeapLock.unlock(" + @@ -343,14 +341,14 @@ public class ChronicleStampedLock extends StampedLock { writeLockHolderCount.addAtomicValue(+1); chmW.put("WriterCount ", writeLockHolderCount); - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock writeLock() ++ writeSeekers=[" + +writeLockHolderCount.getVolatileValue() + "] " + "..," ); - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock writeLock() PROCEEDING " + " ," @@ -360,7 +358,7 @@ public class ChronicleStampedLock extends StampedLock { lastWriterT.setEntryLockState(t); chm.put("Stamp ", offHeapLock); chm.put("LastWriterTime ", lastWriterT); - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + t + " ChronicleStampedLock writeLock() returned stamp=" + offHeapLock.getEntryLockState() + @@ -377,7 +375,7 @@ public class ChronicleStampedLock extends StampedLock { readLockHolderCount = chmR.get("ReaderCount "); do { - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock readLock() ?WAITING " + " on offHeapLock.unlock(" + @@ -397,7 +395,7 @@ public class ChronicleStampedLock extends StampedLock { } } while (l < 0L); - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock readLock() PROCEEDING " + //" readerCount=[" + Count.getReaderCount() + "]" + @@ -416,7 +414,7 @@ public class ChronicleStampedLock extends StampedLock { chm.put("Stamp ", offHeapLock); // make it IPC visible - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock readLock() returned stamp=" + offHeapLock.getEntryLockState() + @@ -443,7 +441,7 @@ public class ChronicleStampedLock extends StampedLock { offHeapLock = chm.get("Stamp "); readLockHolderCount = chmR.get("ReaderCount "); - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock unlockRead(" + stamp + ") unlocking.." + "ReaderCount=[" + @@ -453,7 +451,7 @@ public class ChronicleStampedLock extends StampedLock { ); readLockHolderCount.addAtomicValue(-1); // DECREMENT the cardinality of the Reader set chmR.put("ReaderCount ", readLockHolderCount); // make it IPC visible - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock unlockRead(" + stamp + ") unlocking.." + "ReaderCount=[" + @@ -464,7 +462,7 @@ public class ChronicleStampedLock extends StampedLock { offHeapLock.setEntryLockState( (readLockHolderCount = chmR.get("ReaderCount ")).getVolatileValue() ); - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + "offHeapLock=[" + offHeapLock.getEntryLockState() + "]" + "," @@ -475,7 +473,7 @@ public class ChronicleStampedLock extends StampedLock { @Override public void unlockWrite(long stamp) { - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock unlockWrite(" + stamp + ") unlocking..," ); @@ -486,14 +484,14 @@ public class ChronicleStampedLock extends StampedLock { writeLockHolderCount = chmW.get("WriterCount "); writeLockHolderCount.addAtomicValue(-1); chmW.put("WriterCount ", writeLockHolderCount); - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock unlockWrite(" + stamp + ") -- writeSeekers=[" + +writeLockHolderCount.getVolatileValue() + "] " + "..," ); - lg.log(Level.FINE, + Jvm.debug().on(getClass(), " ,@t=" + System.currentTimeMillis() + " ChronicleStampedLock unlockWrite(" + (offHeapLock = chm.get("Stamp ")).getEntryLockState() + diff --git a/src/main/java/net/openhft/chronicle/set/ChronicleSetBuilder.java b/src/main/java/net/openhft/chronicle/set/ChronicleSetBuilder.java index 5c9d422ed..b76234e7c 100644 --- a/src/main/java/net/openhft/chronicle/set/ChronicleSetBuilder.java +++ b/src/main/java/net/openhft/chronicle/set/ChronicleSetBuilder.java @@ -16,6 +16,7 @@ package net.openhft.chronicle.set; +import net.openhft.chronicle.core.Jvm; import net.openhft.chronicle.hash.ChronicleHashBuilder; import net.openhft.chronicle.hash.ChronicleHashBuilderPrivateAPI; import net.openhft.chronicle.hash.ChronicleHashCorruption; @@ -44,15 +45,8 @@ import java.io.IOException; public final class ChronicleSetBuilder implements ChronicleHashBuilder, ChronicleSetBuilder> { - private static final Logger chronicleSetLogger = LoggerFactory.getLogger(ChronicleSet.class); private static final ChronicleHashCorruption.Listener defaultChronicleSetCorruptionListener = - corruption -> { - if (corruption.exception() != null) { - chronicleSetLogger.error(corruption.message(), corruption.exception()); - } else { - chronicleSetLogger.error(corruption.message()); - } - }; + corruption -> Jvm.error().on(ChronicleSetBuilder.class, corruption.message(), corruption.exception()); private ChronicleMapBuilder chronicleMapBuilder; private final ChronicleSetBuilderPrivateAPI privateAPI; diff --git a/src/main/java/net/openhft/xstream/converters/ValueConverter.java b/src/main/java/net/openhft/xstream/converters/ValueConverter.java index dd1fb9abd..2a308eb69 100644 --- a/src/main/java/net/openhft/xstream/converters/ValueConverter.java +++ b/src/main/java/net/openhft/xstream/converters/ValueConverter.java @@ -21,6 +21,7 @@ import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.converters.UnmarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamReader; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import net.openhft.chronicle.core.Jvm; import net.openhft.chronicle.values.ArrayFieldModel; import net.openhft.chronicle.values.FieldModel; import net.openhft.chronicle.values.ValueModel; @@ -36,7 +37,6 @@ import java.lang.reflect.Method; */ public class ValueConverter implements Converter { - private static final Logger LOG = LoggerFactory.getLogger(ValueConverter.class); @Override public void marshal(Object o, HierarchicalStreamWriter writer, MarshallingContext context) { @@ -77,7 +77,7 @@ public class ValueConverter implements Converter { writer.endNode(); } catch (Exception e) { - LOG.error("class=" + fieldModel.name(), e); + Jvm.error().on(getClass(), "class=" + fieldModel.name(), e); } }); diff --git a/src/test/java/net/openhft/chronicle/map/BuildVersionTest.java b/src/test/java/net/openhft/chronicle/map/BuildVersionTest.java index 2be5ca0fc..355782d24 100644 --- a/src/test/java/net/openhft/chronicle/map/BuildVersionTest.java +++ b/src/test/java/net/openhft/chronicle/map/BuildVersionTest.java @@ -36,8 +36,6 @@ public class BuildVersionTest { /** * check that the map records the version * - * @throws IOException - * @throws InterruptedException */ @Test public void testVersion() throws IOException, InterruptedException { diff --git a/src/test/java/net/openhft/chronicle/map/Issue62ChronicleClient.java b/src/test/java/net/openhft/chronicle/map/Issue62ChronicleClient.java index 0f6840c96..a7ee1c5da 100644 --- a/src/test/java/net/openhft/chronicle/map/Issue62ChronicleClient.java +++ b/src/test/java/net/openhft/chronicle/map/Issue62ChronicleClient.java @@ -28,8 +28,6 @@ import static net.openhft.chronicle.map.Issue62ChronicleServer.prepare; public class Issue62ChronicleClient { - private final static Logger LOGGER = LoggerFactory.getLogger(Issue62ChronicleClient.class); - public static void main(String[] args) throws Exception { prepare(MAP_FILE_B); @@ -45,11 +43,11 @@ public class Issue62ChronicleClient { try (ChronicleMap map = cityPostalCodesMapBuilder.createPersistedTo(MAP_FILE_B)) { - LOGGER.info("Starting"); + System.out.println( "Starting"); Jvm.pause(3000); for (Entry entry : map.entrySet()) { - LOGGER.info("{} : {}", entry.getKey(), entry.getValue()); + System.out.println(entry); } } } diff --git a/src/test/java/net/openhft/chronicle/map/Issue62ChronicleServer.java b/src/test/java/net/openhft/chronicle/map/Issue62ChronicleServer.java index 7bd6d1c98..1a382ef13 100644 --- a/src/test/java/net/openhft/chronicle/map/Issue62ChronicleServer.java +++ b/src/test/java/net/openhft/chronicle/map/Issue62ChronicleServer.java @@ -33,7 +33,6 @@ public class Issue62ChronicleServer { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; final static File MAP_FILE_B = 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(); @@ -63,7 +62,7 @@ public class Issue62ChronicleServer { cityPostalCodes.put(STR + i, (long) i); } - LOGGER.info("Map created"); + System.out.println("Map created"); Jvm.pause(15000); } 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 9cd5135a5..b3cd15cd8 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 @@ -42,8 +42,7 @@ public class DirtyReadOffender implements Runnable { " @t=" + System.currentTimeMillis() + " DirtyReadOffender ACQUIRING offHeapLock.writeLock();" ); - while ((stamp = this.offHeapLock.writeLock()) == 0) { - ; + while ((stamp = this.offHeapLock.writeLock()) == 0) {; } System.out.println( " @t=" + System.currentTimeMillis() + 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 5cf7d2240..7308ad2f4 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 @@ -36,8 +36,7 @@ public class DirtyReadVictim implements Runnable { " ,,@t=" + System.currentTimeMillis() + " DirtyReadVictim CALLING offHeapLock.tryOptimisticRead()" ); - while ((stamp = this.offHeapLock.tryOptimisticRead()) == 0) { - ; + while ((stamp = this.offHeapLock.tryOptimisticRead()) == 0) {; } System.out.println( " ,,@t=" + System.currentTimeMillis() + 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 d43157c0d..90f3fc93a 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 @@ -42,8 +42,7 @@ public class DirtyReadOffender implements Runnable { " @t=" + System.currentTimeMillis() + " DirtyReadOffender ACQUIRING offHeapLock.writeLock();" ); - while ((stamp = this.offHeapLock.writeLock()) == 0) { - ; + while ((stamp = this.offHeapLock.writeLock()) == 0) {; } System.out.println( " @t=" + System.currentTimeMillis() + 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 ab176e0a2..c76b06634 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 @@ -36,8 +36,7 @@ public class DirtyReadVictim implements Runnable { " ,,@t=" + System.currentTimeMillis() + " DirtyReadVictim CALLING offHeapLock.tryOptimisticRead()" ); - while ((stamp = this.offHeapLock.tryOptimisticRead()) == 0) { - ; + while ((stamp = this.offHeapLock.tryOptimisticRead()) == 0) {; } System.out.println( " ,,@t=" + System.currentTimeMillis() + 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 3be87f9d5..10f92abda 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 @@ -368,8 +368,7 @@ public class ChronicleStampedLock extends StampedLock { unlockWrite(stamp); } else if (stamp > 0L) { unlockRead(stamp); - } else { - ;// lock available + } else {;// lock available } } 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 90b846c7d..b4372fcc4 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 @@ -39,8 +39,7 @@ public class DirtyReadIntolerant { " DirtyReadIntolerant sleeping " + sleepMock + " seconds" ); Thread.sleep(sleepMock * 1_000); - while ((stamp = offHeapLock.readLock()) < 0) { - ; + while ((stamp = offHeapLock.readLock()) < 0) {; } System.out.println( " ,,@t=" + System.currentTimeMillis() + diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadOffender.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadOffender.java index 0790e4cb4..8fc2d4e68 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadOffender.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadOffender.java @@ -56,8 +56,7 @@ public class DirtyReadOffender { " @t=" + System.currentTimeMillis() + " DirtyReadOffender ACQUIRING offHeapLock.writeLock();" ); - while ((stamp = offHeapLock.writeLock()) == 0) { - ; + while ((stamp = offHeapLock.writeLock()) == 0) {; } System.out.println( " @t=" + System.currentTimeMillis() + 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 2aad1ab17..6b842b2c1 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 @@ -43,8 +43,7 @@ public class DirtyReadVictimTest { OS.getTarget() + "/OPERAND_ChronicleStampedLock" /*"C:\\Users\\buddy\\dev\\shm\\OPERAND_ChronicleStampedLock"*/ ); - while ((stamp = offHeapLock.tryOptimisticRead()) == 0) { - ; + while ((stamp = offHeapLock.tryOptimisticRead()) == 0) {; } System.out.println( " ,,@t=" + System.currentTimeMillis() + diff --git a/src/test/java/net/openhft/chronicle/map/ipc/StateMachineData.java b/src/test/java/net/openhft/chronicle/map/ipc/StateMachineData.java index ee860b462..fbcbb1367 100644 --- a/src/test/java/net/openhft/chronicle/map/ipc/StateMachineData.java +++ b/src/test/java/net/openhft/chronicle/map/ipc/StateMachineData.java @@ -39,8 +39,6 @@ public class StateMachineData implements Byteable { // ************************************************************************* /** - * @param states - * @return */ public boolean stateIn(StateMachineState... states) { StateMachineState currentState = getState(); @@ -54,8 +52,6 @@ public class StateMachineData implements Byteable { } /** - * @param from - * @param to */ public boolean setState(StateMachineState from, StateMachineState to) { if (this.bs == null) throw new NullPointerException("Byteable is not set to off heap"); @@ -64,7 +60,6 @@ public class StateMachineData implements Byteable { } /** - * @return */ public StateMachineState getState() { if (this.bs == null) throw new NullPointerException("Byteable is not set to off heap"); @@ -74,7 +69,6 @@ public class StateMachineData implements Byteable { } /** - * @param state */ public void setState(StateMachineState state) { if (this.bs == null) throw new NullPointerException("Byteable is not set to off heap"); @@ -86,8 +80,6 @@ public class StateMachineData implements Byteable { * Wait for a state and make a transition. * It spins initially (1000 iterations), then uses a Thread.yield() . * - * @param from - * @param to */ public void waitForState(StateMachineState from, StateMachineState to) { if (this.bs == null) throw new NullPointerException("Byteable is not set to off heap"); @@ -105,7 +97,6 @@ public class StateMachineData implements Byteable { // ************************************************************************* /** - * @return */ public int getStateData() { if (this.bs != null) { @@ -116,7 +107,6 @@ public class StateMachineData implements Byteable { } /** - * @param data */ public void setStateData(int data) { if (this.bs != null) { @@ -125,7 +115,6 @@ public class StateMachineData implements Byteable { } /** - * @return */ public int incStateData() { if (this.bs != null) { @@ -136,7 +125,6 @@ public class StateMachineData implements Byteable { } /** - * @return */ public boolean done() { if (this.bs != null) { diff --git a/src/test/java/net/openhft/chronicle/map/ipc/StateMachineProcessor.java b/src/test/java/net/openhft/chronicle/map/ipc/StateMachineProcessor.java index ddd109d14..b08d69cae 100644 --- a/src/test/java/net/openhft/chronicle/map/ipc/StateMachineProcessor.java +++ b/src/test/java/net/openhft/chronicle/map/ipc/StateMachineProcessor.java @@ -16,6 +16,7 @@ package net.openhft.chronicle.map.ipc; +import net.openhft.chronicle.core.Jvm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,12 +28,8 @@ public class StateMachineProcessor implements Runnable { private final StateMachineState from; private final StateMachineState transition; private final StateMachineState to; - private final Logger logger; /** - * @param smd - * @param from - * @param to */ public StateMachineProcessor(final StateMachineData smd, StateMachineState from, StateMachineState transition, StateMachineState to) { this.smd = smd; @@ -40,14 +37,9 @@ public class StateMachineProcessor implements Runnable { this.transition = transition; this.to = to; - this.logger = LoggerFactory.getLogger(from + " => " + transition + " => " + to); } /** - * @param smd - * @param from - * @param transition - * @param to */ public static void runProcessor(final StateMachineData smd, StateMachineState from, StateMachineState transition, StateMachineState to) { new StateMachineProcessor(smd, from, transition, to).run(); @@ -60,7 +52,7 @@ public class StateMachineProcessor implements Runnable { doProcess(); } - logger.info("Wait for {}", from); + Jvm.debug().on(getClass(), "Wait for " + from); smd.waitForState(from, transition); doProcess(); @@ -70,11 +62,10 @@ public class StateMachineProcessor implements Runnable { private void doProcess() { smd.incStateData(); - logger.info("Status {}, Next {}, Data {}", - from, - to, - smd.getStateData() - ); + Jvm.debug().on(getClass(), + "Status " + from + ", " + + "Next " + to + ", " + + "Data " + smd.getStateData()); smd.setState(transition, to); } diff --git a/src/test/java/net/openhft/chronicle/map/ipc/StateMachineState.java b/src/test/java/net/openhft/chronicle/map/ipc/StateMachineState.java index 59d95dcc8..9df1a981e 100644 --- a/src/test/java/net/openhft/chronicle/map/ipc/StateMachineState.java +++ b/src/test/java/net/openhft/chronicle/map/ipc/StateMachineState.java @@ -35,7 +35,6 @@ public enum StateMachineState { /** * c-tor * - * @param state */ StateMachineState(int state) { this.state = state; @@ -52,7 +51,6 @@ public enum StateMachineState { } /** - * @return */ public int value() { return this.state; diff --git a/src/test/java/net/openhft/chronicle/map/locks/DirtyReadOffenderIPCTest.java b/src/test/java/net/openhft/chronicle/map/locks/DirtyReadOffenderIPCTest.java index af4c29c7f..d10092d8b 100644 --- a/src/test/java/net/openhft/chronicle/map/locks/DirtyReadOffenderIPCTest.java +++ b/src/test/java/net/openhft/chronicle/map/locks/DirtyReadOffenderIPCTest.java @@ -63,8 +63,7 @@ public class DirtyReadOffenderIPCTest implements Runnable { "..... @t=" + System.currentTimeMillis() + " DirtyReadOffender ACQUIRING offHeapLock.writeLock();" ); - while ((stamp = offHeapLock.writeLock()) == 0) { - ; + while ((stamp = offHeapLock.writeLock()) == 0) {; } System.out.println( "..... @t=" + System.currentTimeMillis() + diff --git a/src/test/java/net/openhft/chronicle/map/locks/DirtyReadOffenderTest.java b/src/test/java/net/openhft/chronicle/map/locks/DirtyReadOffenderTest.java index 45461d996..9a929238c 100644 --- a/src/test/java/net/openhft/chronicle/map/locks/DirtyReadOffenderTest.java +++ b/src/test/java/net/openhft/chronicle/map/locks/DirtyReadOffenderTest.java @@ -52,8 +52,7 @@ class DirtyReadOffenderTest implements Runnable { "..... @t=" + System.currentTimeMillis() + " DirtyReadOffender ACQUIRING offHeapLock.writeLock();" ); - while ((stamp = offHeapLock.writeLock()) == 0) { - ; + while ((stamp = offHeapLock.writeLock()) == 0) {; } System.out.println( "..... @t=" + System.currentTimeMillis() + diff --git a/src/test/java/net/openhft/chronicle/map/locks/DirtyReadVictimIPCTest.java b/src/test/java/net/openhft/chronicle/map/locks/DirtyReadVictimIPCTest.java index 35f02ad62..5df266406 100644 --- a/src/test/java/net/openhft/chronicle/map/locks/DirtyReadVictimIPCTest.java +++ b/src/test/java/net/openhft/chronicle/map/locks/DirtyReadVictimIPCTest.java @@ -31,7 +31,6 @@ public class DirtyReadVictimIPCTest { *

* this belief is STRICTLY conjecture. * - * @throws IOException */ @Test @@ -85,8 +84,7 @@ public class DirtyReadVictimIPCTest { OS.getTarget() + "/shm-" + "OPERAND_ChronicleStampedLock" ); - while ((stamp = offHeapLock.tryOptimisticRead()) == 0) { - ; + while ((stamp = offHeapLock.tryOptimisticRead()) == 0) {; } System.out.println( " ,,@t=" + System.currentTimeMillis() + @@ -180,8 +178,7 @@ public class DirtyReadVictimIPCTest { OS.getTarget() + "/shm-" + "OPERAND_ChronicleStampedLock" ); - while ((stamp = offHeapLock.tryOptimisticRead()) == 0) { - ; + while ((stamp = offHeapLock.tryOptimisticRead()) == 0) {; } System.out.println( " ,,@t=" + System.currentTimeMillis() + diff --git a/src/test/java/net/openhft/chronicle/map/utility/ProcessInstanceLimiter.java b/src/test/java/net/openhft/chronicle/map/utility/ProcessInstanceLimiter.java index fff0a0a44..339ff22b9 100644 --- a/src/test/java/net/openhft/chronicle/map/utility/ProcessInstanceLimiter.java +++ b/src/test/java/net/openhft/chronicle/map/utility/ProcessInstanceLimiter.java @@ -323,7 +323,6 @@ public class ProcessInstanceLimiter implements Runnable { * slot, it will callback thisProcessOfTypeHasStartedAtSlot(), otherwise one * of the other callback interface methods will be called. * - * @param processType */ public void startingProcessOfType(String processType) { Data data = this.timedata.get(processType);