public class CMap2EngineReplicator extends Object implements EngineReplication, net.openhft.chronicle.hash.replication.EngineReplicationLangBytesConsumer, View
| Modifier and Type | Class and Description |
|---|---|
static class |
CMap2EngineReplicator.VanillaReplicatedEntry |
EngineReplication.EntryCallback, EngineReplication.ModificationIterator, EngineReplication.ModificationNotifier, EngineReplication.ReplicationEntry| Constructor and Description |
|---|
CMap2EngineReplicator(RequestContext context) |
CMap2EngineReplicator(RequestContext requestContext,
Asset asset) |
| Modifier and Type | Method and Description |
|---|---|
EngineReplication.ModificationIterator |
acquireModificationIterator(byte remoteIdentifier)
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 entry)
removes or puts the entry into the map
|
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 |
put(net.openhft.chronicle.bytes.BytesStore key,
net.openhft.chronicle.bytes.BytesStore value,
byte remoteIdentifier,
long timestamp) |
void |
set(net.openhft.chronicle.map.EngineReplicationLangBytes engineReplicationLangBytes) |
void |
setLastModificationTime(byte identifier,
long timestamp) |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEachpublic CMap2EngineReplicator(RequestContext requestContext, @NotNull Asset asset)
public CMap2EngineReplicator(RequestContext context)
public void set(net.openhft.chronicle.map.EngineReplicationLangBytes engineReplicationLangBytes)
set in interface net.openhft.chronicle.hash.replication.EngineReplicationLangBytesConsumerpublic void put(@NotNull
net.openhft.chronicle.bytes.BytesStore key,
@NotNull
net.openhft.chronicle.bytes.BytesStore value,
byte remoteIdentifier,
long timestamp)
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 void applyReplication(@NotNull
EngineReplication.ReplicationEntry entry)
ReplicationapplyReplication in interface Replication@Nullable public EngineReplication.ModificationIterator acquireModificationIterator(byte remoteIdentifier)
EngineReplicationidentifier.acquireModificationIterator in interface EngineReplicationacquireModificationIterator in interface ReplicationremoteIdentifier - the identifier of the remote nodeEngineReplication.identifier()public 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 EngineReplicationCopyright © 2015. All rights reserved.