mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Reduce visibility of ChannelProvider and OldDeletedEntriesCleanup classes, make AcceptanceDecision enum nested in DefaultEventualConsistencyStrategy, minor Javadoc fixes
This commit is contained in:
@@ -29,8 +29,9 @@ public interface ChecksumEntry {
|
||||
* Re-computes and stores checksum for the entry. This method <i>shouldn't</i> be called before
|
||||
* or after ordinary operations like {@link MapAbsentEntry#doInsert(Data)}, {@link
|
||||
* MapEntry#doReplaceValue(Data)}: it is performed automatically underneath. Call this method,
|
||||
* only when value bytes was updated directly, for example though Chronicle-Value-generated
|
||||
* interface.
|
||||
* only when value bytes was updated directly, for example though flyweight implementation of
|
||||
* a <a href="https://github.com/OpenHFT/Chronicle-Values#value-interface-specification">value
|
||||
* interface</a>.
|
||||
*/
|
||||
void updateChecksum();
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ import java.util.concurrent.locks.Lock;
|
||||
* thread is beneficial form performance point-of-view, e. g. fields of the on-heap
|
||||
* {@code InterProcessLock} object shouldn't be {@code volatile}.
|
||||
*
|
||||
* <p>Locks is inter-process, hence it cannot afford to wait for acquisition infinitely, because
|
||||
* <p>Lock is inter-process, hence it cannot afford to wait for acquisition infinitely, because
|
||||
* it would be too dead-lock prone. {@link #lock()} throws {@code RuntimeException} after some
|
||||
* finite time.
|
||||
*
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 higherfrequencytrading.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.openhft.chronicle.hash.replication;
|
||||
|
||||
import net.openhft.chronicle.hash.ChronicleHash;
|
||||
import net.openhft.chronicle.hash.replication.DefaultEventualConsistencyStrategy;
|
||||
import net.openhft.chronicle.map.replication.MapRemoteOperations;
|
||||
import net.openhft.chronicle.set.replication.SetRemoteOperations;
|
||||
|
||||
/**
|
||||
* Decision, if {@link MapRemoteOperations remote modification operation} should be accepted
|
||||
* or discarded. Used in {@link DefaultEventualConsistencyStrategy}.
|
||||
*/
|
||||
public enum AcceptanceDecision {
|
||||
/**
|
||||
* Acceptance decision -- the remote modification operation is applied to the local
|
||||
* {@link ChronicleHash} state.
|
||||
*/
|
||||
ACCEPT,
|
||||
|
||||
/**
|
||||
* Discard decision -- the remote modification operation is rejected.
|
||||
*/
|
||||
DISCARD
|
||||
}
|
||||
+18
-4
@@ -21,9 +21,6 @@ import net.openhft.chronicle.hash.ChronicleHashBuilder;
|
||||
import net.openhft.chronicle.map.replication.MapRemoteOperations;
|
||||
import net.openhft.chronicle.set.replication.SetRemoteOperations;
|
||||
|
||||
import static net.openhft.chronicle.hash.replication.AcceptanceDecision.ACCEPT;
|
||||
import static net.openhft.chronicle.hash.replication.AcceptanceDecision.DISCARD;
|
||||
|
||||
/**
|
||||
* Specifies the default eventual consistency strategy for {@link ChronicleHashBuilder#replication(
|
||||
* byte) replicated} {@link ChronicleHash}es:
|
||||
@@ -53,8 +50,25 @@ public final class DefaultEventualConsistencyStrategy {
|
||||
boolean shouldAccept = remoteTimestamp > originTimestamp ||
|
||||
(remoteTimestamp == originTimestamp &&
|
||||
context.remoteIdentifier() <= entry.originIdentifier());
|
||||
return shouldAccept ? ACCEPT : DISCARD;
|
||||
return shouldAccept ? AcceptanceDecision.ACCEPT : AcceptanceDecision.DISCARD;
|
||||
}
|
||||
|
||||
private DefaultEventualConsistencyStrategy() {}
|
||||
|
||||
/**
|
||||
* Decision, if {@link MapRemoteOperations remote modification operation} should be accepted
|
||||
* or discarded. Used in {@link DefaultEventualConsistencyStrategy}.
|
||||
*/
|
||||
public enum AcceptanceDecision {
|
||||
/**
|
||||
* Acceptance decision -- the remote modification operation is applied to the local
|
||||
* {@link ChronicleHash} state.
|
||||
*/
|
||||
ACCEPT,
|
||||
|
||||
/**
|
||||
* Discard decision -- the remote modification operation is rejected.
|
||||
*/
|
||||
DISCARD
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public interface StatefulCopyable<T extends StatefulCopyable<T>> {
|
||||
/**
|
||||
* Creates a copy of this marshaller, with independent state. The current state itself shouldn't
|
||||
* be copied (it could be "clear" in the copy), only "configuration" of the instance, on which
|
||||
* {@code copy()} is called, should be inherited in the copy (e. g. the class of object
|
||||
* {@code copy()} is called, should be inherited in the copy (e. g. the class of objects
|
||||
* serialized). So, {@code copy()} should be transitive, i. e. {@code marshaller.copy()} and
|
||||
* {@code marshaller.copy().copy()} should result to identical instances.
|
||||
*
|
||||
|
||||
@@ -48,7 +48,7 @@ import static net.openhft.chronicle.map.Replica.ModificationIterator;
|
||||
/**
|
||||
* @author Rob Austin.
|
||||
*/
|
||||
public final class ChannelProvider implements Closeable {
|
||||
final class ChannelProvider implements Closeable {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ChannelProvider.class.getName());
|
||||
|
||||
static final Map<ReplicationHub, ChannelProvider> implMapping = new IdentityHashMap<>();
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.LockSupport;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class OldDeletedEntriesCleanup implements Runnable, Closeable, Predicate<ReplicableEntry> {
|
||||
class OldDeletedEntriesCleanup implements Runnable, Closeable, Predicate<ReplicableEntry> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(OldDeletedEntriesCleanup.class);
|
||||
|
||||
private final ReplicatedChronicleMap<?, ?, ?> map;
|
||||
|
||||
@@ -24,8 +24,8 @@ import net.openhft.chronicle.map.ChronicleMapBuilder;
|
||||
import net.openhft.chronicle.map.MapAbsentEntry;
|
||||
import net.openhft.chronicle.map.MapEntryOperations;
|
||||
|
||||
import static net.openhft.chronicle.hash.replication.AcceptanceDecision.ACCEPT;
|
||||
import static net.openhft.chronicle.hash.replication.AcceptanceDecision.DISCARD;
|
||||
import static net.openhft.chronicle.hash.replication.DefaultEventualConsistencyStrategy.AcceptanceDecision.ACCEPT;
|
||||
import static net.openhft.chronicle.hash.replication.DefaultEventualConsistencyStrategy.AcceptanceDecision.DISCARD;
|
||||
import static net.openhft.chronicle.hash.replication.DefaultEventualConsistencyStrategy.decideOnRemoteModification;
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,8 +19,8 @@ package net.openhft.chronicle.set.replication;
|
||||
import net.openhft.chronicle.hash.replication.ReplicableEntry;
|
||||
import net.openhft.chronicle.set.SetAbsentEntry;
|
||||
|
||||
import static net.openhft.chronicle.hash.replication.AcceptanceDecision.ACCEPT;
|
||||
import static net.openhft.chronicle.hash.replication.AcceptanceDecision.DISCARD;
|
||||
import static net.openhft.chronicle.hash.replication.DefaultEventualConsistencyStrategy.AcceptanceDecision.ACCEPT;
|
||||
import static net.openhft.chronicle.hash.replication.DefaultEventualConsistencyStrategy.AcceptanceDecision.DISCARD;
|
||||
import static net.openhft.chronicle.hash.replication.DefaultEventualConsistencyStrategy.decideOnRemoteModification;
|
||||
|
||||
public interface SetRemoteOperations<K, R> {
|
||||
|
||||
Reference in New Issue
Block a user