mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Tidy code
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -555,7 +555,7 @@ public interface ChronicleHashBuilder<K, H extends ChronicleHash<K, ?, ?, ?>,
|
||||
* provided {@code file} during recovery across all JVMs/threads/processes or else
|
||||
* the behavior is unspecified including the possibility that the Map file gets
|
||||
* <em>completely corrupted and/or is silently returning stale or otherwise erroneous data.</em>
|
||||
*
|
||||
* <p>
|
||||
* 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<K, H extends ChronicleHash<K, ?, ?, ?>,
|
||||
* provided {@code file} during recovery across all JVMs/threads/processes or else
|
||||
* the behavior is unspecified including the possibility that the Map file gets
|
||||
* <em>completely corrupted and/or is silently returning stale or otherwise erroneous data.</em>
|
||||
*
|
||||
* <p>
|
||||
* 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<K, H extends ChronicleHash<K, ?, ?, ?>,
|
||||
* provided {@code file} during recovery across all JVMs/threads/processes or else
|
||||
* the behavior is unspecified including the possibility that the Map file gets
|
||||
* <em>completely corrupted and/or is silently returning stale or otherwise erroneous data.</em>
|
||||
*
|
||||
* <p>
|
||||
* 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<K, H extends ChronicleHash<K, ?, ?, ?>,
|
||||
* provided {@code file} during recovery across all JVMs/threads/processes or else
|
||||
* the behavior is unspecified including the possibility that the Map file gets
|
||||
* <em>completely corrupted and/or is silently returning stale or otherwise erroneous data.</em>
|
||||
*
|
||||
* <p>
|
||||
* 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<K, H extends ChronicleHash<K, ?, ?, ?>,
|
||||
* provided {@code file} during recovery across all JVMs/threads/processes or else
|
||||
* the behavior is unspecified including the possibility that the Map file gets
|
||||
* <em>completely corrupted and/or is silently returning stale or otherwise erroneous data.</em>
|
||||
*
|
||||
* <p>
|
||||
* 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.
|
||||
* </p>
|
||||
*
|
||||
* @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
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -68,8 +68,8 @@ import static net.openhft.chronicle.map.ChronicleHashCorruptionImpl.format;
|
||||
import static net.openhft.chronicle.map.ChronicleHashCorruptionImpl.report;
|
||||
|
||||
public abstract class VanillaChronicleHash<K,
|
||||
C extends HashEntry<K>, SC extends HashSegmentContext<K, ?>,
|
||||
ECQ extends ExternalHashQueryContext<K>>
|
||||
C extends HashEntry<K>, SC extends HashSegmentContext<K, ?>,
|
||||
ECQ extends ExternalHashQueryContext<K>>
|
||||
implements ChronicleHash<K, C, SC, ECQ>, Marshallable {
|
||||
|
||||
public static final long TIER_COUNTERS_AREA_SIZE = 64;
|
||||
@@ -158,7 +158,8 @@ public abstract class VanillaChronicleHash<K,
|
||||
* The fileLock is used to prevent recover actions
|
||||
* from accessing the mapped file concurrently.
|
||||
*/
|
||||
@Nullable private transient FileLock fileLock;
|
||||
@Nullable
|
||||
private transient FileLock fileLock;
|
||||
|
||||
public VanillaChronicleHash(@NotNull final ChronicleMapBuilder<K, ?> builder) {
|
||||
// Version
|
||||
@@ -633,7 +634,7 @@ public abstract class VanillaChronicleHash<K,
|
||||
public String persistedDataVersion() {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
return dataFileVersion;
|
||||
return dataFileVersion;
|
||||
}
|
||||
|
||||
private long segmentHeadersOffset() {
|
||||
@@ -701,7 +702,7 @@ public abstract class VanillaChronicleHash<K,
|
||||
public boolean isOpen() {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
return !resources.closed();
|
||||
return !resources.closed();
|
||||
}
|
||||
|
||||
public final void checkKey(final Object key) {
|
||||
@@ -918,7 +919,7 @@ public abstract class VanillaChronicleHash<K,
|
||||
public long tierIndexToBaseAddr(final long tierIndex) {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
// tiers are 1-counted, to allow tierIndex = 0 to be un-initialized in off-heap memory,
|
||||
// tiers are 1-counted, to allow tierIndex = 0 to be un-initialized in off-heap memory,
|
||||
// convert into 0-based form
|
||||
final long tierIndexMinusOne = tierIndex - 1;
|
||||
if (tierIndexMinusOne < actualSegments)
|
||||
|
||||
@@ -57,7 +57,7 @@ public abstract class HashSegmentIteration<K, E extends HashEntry<K>>
|
||||
public long tierEntriesForIteration() {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
return s.tierEntries();
|
||||
return s.tierEntries();
|
||||
}
|
||||
|
||||
abstract boolean entryRemovedOnThisIterationInit();
|
||||
@@ -71,7 +71,7 @@ public abstract class HashSegmentIteration<K, E extends HashEntry<K>>
|
||||
public void initHashLookupEntry(long entry) {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
hashLookupEntry = entry;
|
||||
hashLookupEntry = entry;
|
||||
}
|
||||
|
||||
abstract void closeHashLookupEntry();
|
||||
@@ -80,7 +80,7 @@ public abstract class HashSegmentIteration<K, E extends HashEntry<K>>
|
||||
public boolean forEachSegmentEntryWhile(Predicate<? super E> predicate) {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
s.innerUpdateLock.lock();
|
||||
return innerForEachSegmentEntryWhile(predicate);
|
||||
}
|
||||
@@ -182,13 +182,13 @@ public abstract class HashSegmentIteration<K, E extends HashEntry<K>>
|
||||
public void hookAfterEachIteration() {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachSegmentEntry(Consumer<? super E> action) {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
forEachSegmentEntryWhile(e -> {
|
||||
forEachSegmentEntryWhile(e -> {
|
||||
action.accept(e);
|
||||
return true;
|
||||
});
|
||||
@@ -197,7 +197,7 @@ public abstract class HashSegmentIteration<K, E extends HashEntry<K>>
|
||||
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<K, E extends HashEntry<K>>
|
||||
public void doRemove() {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
s.innerWriteLock.lock();
|
||||
try {
|
||||
iterationRemove();
|
||||
@@ -220,7 +220,7 @@ public abstract class HashSegmentIteration<K, E extends HashEntry<K>>
|
||||
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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -30,7 +30,8 @@ public final class CanonicalRandomAccessFiles {
|
||||
|
||||
private static final ConcurrentHashMap<File, RafReference> 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) -> {
|
||||
|
||||
@@ -40,6 +40,7 @@ public final class TimeProvider {
|
||||
|
||||
private static final AtomicLong lastTimeHolder = new AtomicLong();
|
||||
private static LongSupplier millisecondSupplier = System::currentTimeMillis;
|
||||
|
||||
private TimeProvider() {
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ public final class SetMarshaller<T>
|
||||
* Cache field
|
||||
*/
|
||||
private transient Deque<T> orderedElements;
|
||||
|
||||
/**
|
||||
* Constructs a {@code SetMarshaller} with the given set elements' serializers.
|
||||
* <p>
|
||||
|
||||
+2
-2
@@ -14,12 +14,12 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class BytesMarshallableReaderWriter<V extends BytesMarshallable>
|
||||
extends CachingCreatingMarshaller<V> {
|
||||
private static final ThreadLocal<VanillaBytes> VANILLA_BYTES_TL = ThreadLocal.withInitial(() -> new VanillaBytes<>(BytesStore.empty()));
|
||||
|
||||
public BytesMarshallableReaderWriter(Class<V> vClass) {
|
||||
super(vClass);
|
||||
}
|
||||
|
||||
private static final ThreadLocal<VanillaBytes> VANILLA_BYTES_TL = ThreadLocal.withInitial(() -> new VanillaBytes<>(BytesStore.empty()));
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public V read(Bytes in, long size, @Nullable V using) {
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ public abstract class InstanceCreatingMarshaller<T> implements Marshallable {
|
||||
}
|
||||
|
||||
protected Type tType() {
|
||||
return tClass;
|
||||
return tClass;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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() {
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ public class TypedMarshallableReaderWriter<V extends Marshallable>
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>,
|
||||
* @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.
|
||||
*
|
||||
* <p>
|
||||
* see also {@see net.openhft.chronicle.map.ChronicleMap#remainingAutoResizes} as these operations are related.
|
||||
*/
|
||||
default short percentageFreeSpace() {
|
||||
@@ -230,7 +230,7 @@ public interface ChronicleMap<K, V> extends ConcurrentMap<K, V>,
|
||||
* 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}.
|
||||
*/
|
||||
|
||||
@@ -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!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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(
|
||||
|
||||
@@ -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<String> keys );
|
||||
void writeExternalEntry(ReplicableEntry entry, Bytes payload, @NotNull Bytes destination, int chronicleId, ArrayList<String> keys);
|
||||
|
||||
/**
|
||||
* The map implements this method to restore its contents. This method must read the values
|
||||
|
||||
@@ -101,7 +101,7 @@ public class ReplicatedChronicleMap<K, V, R> extends VanillaChronicleMap<K, V, R
|
||||
static final byte ENTRY_HUNK = 1;
|
||||
static final byte BOOTSTRAP_TIME_HUNK = 2;
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ReplicatedChronicleMap.class);
|
||||
|
||||
|
||||
public transient boolean cleanupRemovedEntries;
|
||||
public transient long cleanupTimeout;
|
||||
public transient TimeUnit cleanupTimeoutUnit;
|
||||
|
||||
@@ -333,7 +333,7 @@ public class VanillaChronicleMap<K, V, R>
|
||||
public boolean equals(final Object obj) {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
return mapEquals(obj);
|
||||
return mapEquals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -773,7 +773,7 @@ public class VanillaChronicleMap<K, V, R>
|
||||
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<K, V, R> q = queryContext(key)) {
|
||||
|
||||
@@ -39,7 +39,7 @@ public enum ZeroBytesStore implements BytesStore<ZeroBytesStore, Void> {
|
||||
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<ZeroBytesStore, Void> {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void reserve(ReferenceOwner id) throws IllegalStateException {
|
||||
}
|
||||
|
||||
|
||||
@@ -42,14 +42,14 @@ public abstract class MapSegmentIteration<K, V, R> extends HashSegmentIteration<
|
||||
public void hookAfterEachIteration() {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
wrappedValueInstanceDataHolder.closeValue();
|
||||
wrappedValueInstanceDataHolder.closeValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doReplaceValue(Data<V> newValue) {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
try {
|
||||
entry.innerDefaultReplaceValue(newValue);
|
||||
} finally {
|
||||
|
||||
+11
-11
@@ -62,28 +62,28 @@ public abstract class ReplicatedMapSegmentIteration<K, V, R> 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<V> newValue) {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
try {
|
||||
entry.innerDefaultReplaceValue(newValue);
|
||||
e.updatedReplicationStateOnPresentEntry();
|
||||
@@ -97,7 +97,7 @@ public abstract class ReplicatedMapSegmentIteration<K, V, R> extends MapSegmentI
|
||||
public boolean forEachSegmentEntryWhile(Predicate<? super MapEntry<K, V>> predicate) {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
initEntriesToTest(PRESENT);
|
||||
s.innerUpdateLock.lock();
|
||||
return innerForEachSegmentEntryWhile(predicate);
|
||||
@@ -108,7 +108,7 @@ public abstract class ReplicatedMapSegmentIteration<K, V, R> extends MapSegmentI
|
||||
Predicate<? super ReplicableEntry> predicate) {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
initEntriesToTest(ALL);
|
||||
s.innerUpdateLock.lock();
|
||||
return innerForEachSegmentEntryWhile(predicate);
|
||||
@@ -118,7 +118,7 @@ public abstract class ReplicatedMapSegmentIteration<K, V, R> extends MapSegmentI
|
||||
public void forEachSegmentReplicableEntry(Consumer<? super ReplicableEntry> action) {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
forEachSegmentReplicableEntryWhile(e -> {
|
||||
forEachSegmentReplicableEntryWhile(e -> {
|
||||
action.accept(e);
|
||||
return true;
|
||||
});
|
||||
@@ -128,7 +128,7 @@ public abstract class ReplicatedMapSegmentIteration<K, V, R> 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<K, V, R> 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<K, V, R> extends MapSegmentI
|
||||
public void doInsert(Data<V> value) {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
if (e.entryDeleted()) {
|
||||
try {
|
||||
s.tierDeleted(s.tierDeleted() - 1);
|
||||
@@ -177,7 +177,7 @@ public abstract class ReplicatedMapSegmentIteration<K, V, R> 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<V>) DummyValueData.INSTANCE);
|
||||
|
||||
@@ -53,37 +53,37 @@ class SetFromMap<E> extends AbstractSet<E> implements ChronicleSet<E> {
|
||||
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<E> extends AbstractSet<E> implements ChronicleSet<E> {
|
||||
public Object[] toArray() {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
return s.toArray();
|
||||
return s.toArray();
|
||||
}
|
||||
|
||||
public <T> T[] toArray(T[] a) {
|
||||
@@ -122,13 +122,13 @@ class SetFromMap<E> extends AbstractSet<E> implements ChronicleSet<E> {
|
||||
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<E> extends AbstractSet<E> implements ChronicleSet<E> {
|
||||
public long longSize() {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
return m.longSize();
|
||||
return m.longSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long offHeapMemoryUsed() {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
return m.offHeapMemoryUsed();
|
||||
return m.offHeapMemoryUsed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<E> 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<E> extends AbstractSet<E> implements ChronicleSet<E> {
|
||||
public int segments() {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
return m.segments();
|
||||
return m.segments();
|
||||
}
|
||||
|
||||
// TODO test forEach methods
|
||||
@@ -220,7 +220,7 @@ class SetFromMap<E> extends AbstractSet<E> implements ChronicleSet<E> {
|
||||
public boolean forEachEntryWhile(Predicate<? super SetEntry<E>> predicate) {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
Objects.requireNonNull(predicate);
|
||||
Objects.requireNonNull(predicate);
|
||||
return m.forEachEntryWhile(e -> predicate.test(((SetEntry<E>) e)));
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ class SetFromMap<E> extends AbstractSet<E> implements ChronicleSet<E> {
|
||||
public void forEachEntry(Consumer<? super SetEntry<E>> action) {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
Objects.requireNonNull(action);
|
||||
Objects.requireNonNull(action);
|
||||
m.forEachEntry(e -> action.accept(((SetEntry<E>) e)));
|
||||
}
|
||||
|
||||
@@ -236,14 +236,14 @@ class SetFromMap<E> extends AbstractSet<E> implements ChronicleSet<E> {
|
||||
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<E> extends AbstractSet<E> implements ChronicleSet<E> {
|
||||
public boolean isOpen() {
|
||||
throwExceptionIfClosed();
|
||||
|
||||
return m.isOpen();
|
||||
return m.isOpen();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user