public class VanillaEngineReplication<Store extends KeyValueStore<?,?,?>> extends Object implements EngineReplication, Closeable
| Modifier and Type | Class and Description |
|---|---|
static interface |
VanillaEngineReplication.ChangeApplier<Store> |
static interface |
VanillaEngineReplication.GetValue<Store> |
static interface |
VanillaEngineReplication.RemoteNodeReplicationState |
static interface |
VanillaEngineReplication.ReplicationData |
static interface |
VanillaEngineReplication.SegmentForKey<Store> |
EngineReplication.EntryCallback, EngineReplication.ModificationIterator, EngineReplication.ModificationNotifier, EngineReplication.ReplicationEntry| Modifier and Type | Field and Description |
|---|---|
static int |
DIRTY_WORD_COUNT |
static int |
MAX_MODIFICATION_ITERATORS |
static int |
RESERVED_MOD_ITER |
| Constructor and Description |
|---|
VanillaEngineReplication(java.util.function.IntFunction<KeyValueStore<net.openhft.chronicle.bytes.BytesStore,VanillaEngineReplication.ReplicationData,VanillaEngineReplication.ReplicationData>> obtainKeyReplicationDataBySegment,
KeyValueStore<net.openhft.chronicle.core.values.IntValue,VanillaEngineReplication.RemoteNodeReplicationState,VanillaEngineReplication.RemoteNodeReplicationState> modIterState,
byte identifier,
Store store,
VanillaEngineReplication.ChangeApplier<Store> changeApplier,
VanillaEngineReplication.GetValue<Store> getValue,
VanillaEngineReplication.SegmentForKey<Store> segmentForKey) |
| Modifier and Type | Method and Description |
|---|---|
EngineReplication.ModificationIterator |
acquireModificationIterator(byte id)
Gets (if it does not exist, creates) an instance of ModificationIterator associated with a
remote node, this weak associated is bound using the
identifier. |
void |
applyReplication(EngineReplication.ReplicationEntry replicatedEntry)
removes or puts the entry into the map
|
void |
close() |
byte |
identifier()
Provides the unique Identifier associated with this instance.
|
long |
lastModificationTime(byte remoteIdentifier)
Returns the timestamp of the last change from the specified remote node, already replicated
to this host.
|
void |
onPut(net.openhft.chronicle.bytes.BytesStore key,
long putTimestamp) |
void |
onRemove(net.openhft.chronicle.bytes.BytesStore key,
long remoteTimestamp) |
void |
setLastModificationTime(byte identifier,
long timestamp) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEachpublic static final int RESERVED_MOD_ITER
public static final int MAX_MODIFICATION_ITERATORS
public static final int DIRTY_WORD_COUNT
public VanillaEngineReplication(java.util.function.IntFunction<KeyValueStore<net.openhft.chronicle.bytes.BytesStore,VanillaEngineReplication.ReplicationData,VanillaEngineReplication.ReplicationData>> obtainKeyReplicationDataBySegment, KeyValueStore<net.openhft.chronicle.core.values.IntValue,VanillaEngineReplication.RemoteNodeReplicationState,VanillaEngineReplication.RemoteNodeReplicationState> modIterState, byte identifier, Store store, VanillaEngineReplication.ChangeApplier<Store> changeApplier, VanillaEngineReplication.GetValue<Store> getValue, VanillaEngineReplication.SegmentForKey<Store> segmentForKey)
public byte identifier()
EngineReplicationAn identifier is used to determine which replicating node made the change.
If two nodes update their map at the same time with different values, we have to deterministically resolve which update wins, because of eventual consistency both nodes should end up locally holding the same data. Although it is rare two remote nodes could receive an update to their maps at exactly the same time for the same key, we have to handle this edge case, its therefore important not to rely on timestamps alone to reconcile the updates. Typically the update with the newest timestamp should win, but in this example both timestamps are the same, and the decision made to one node should be identical to the decision made to the other. We resolve this simple dilemma by using a node identifier, each node will have a unique identifier, the update from the node with the smallest identifier wins.
identifier in interface EngineReplicationpublic long lastModificationTime(byte remoteIdentifier)
EngineReplicationUsed in conjunction with replication, to back fill data from a remote node. This node may have missed updates while it was not been running or connected via TCP.
lastModificationTime in interface EngineReplicationlastModificationTime in interface ReplicationremoteIdentifier - the identifier of the remote node to check last replicated update
time fromEngineReplication.identifier()public void setLastModificationTime(byte identifier,
long timestamp)
setLastModificationTime in interface EngineReplicationpublic void applyReplication(@NotNull
EngineReplication.ReplicationEntry replicatedEntry)
ReplicationapplyReplication in interface Replicationpublic EngineReplication.ModificationIterator acquireModificationIterator(byte id)
EngineReplicationidentifier.acquireModificationIterator in interface EngineReplicationacquireModificationIterator in interface Replicationid - the identifier of the remote nodeEngineReplication.identifier()public void onPut(net.openhft.chronicle.bytes.BytesStore key,
long putTimestamp)
public void onRemove(net.openhft.chronicle.bytes.BytesStore key,
long remoteTimestamp)
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2015. All rights reserved.