public interface Replica extends Closeable, EngineReplicationLangBytes
Modifier and Type | Interface and Description |
---|---|
static class |
Replica.EntryCallback
Implemented typically by a replicator, This interface provides the event, which will get
called whenever a put() or remove() has occurred to the map
|
static interface |
Replica.EntryExternalizable
supports reading and writing serialize entries
|
static interface |
Replica.EntryResolver<K,V>
provides a key and value from NativeBytes, this can be used in conjunction with the
modification iterator to get the key and value out of the NativeBytes
|
static interface |
Replica.ModificationIterator
Holds a record of which entries have modification.
|
static interface |
Replica.ModificationNotifier
notifies when there is a changed to the modification iterator
|
EngineReplicationLangBytes.EngineEntryCallback, EngineReplicationLangBytes.EngineModificationIterator, EngineReplicationLangBytes.EngineReplicationModificationNotifier
Modifier and Type | Method and Description |
---|---|
Replica.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 . |
byte |
identifier()
Provides the unique Identifier associated with this map instance.
|
long |
lastModificationTime(byte remoteIdentifier)
Returns the timestamp of the last change from the specified remote node, already replicated
to this Replica.
|
void |
setLastModificationTime(byte identifier,
long timestamp) |
acquireEngineModificationIterator, put, remove
byte identifier()
An 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 EngineReplicationLangBytes
Replica.ModificationIterator acquireModificationIterator(byte remoteIdentifier)
identifier
.remoteIdentifier
- the identifier of the remote nodeidentifier()
long lastModificationTime(byte remoteIdentifier)
Used 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 EngineReplicationLangBytes
remoteIdentifier
- the identifier of the remote node to check last replicated update
time fromidentifier()
void setLastModificationTime(byte identifier, long timestamp)
setLastModificationTime
in interface EngineReplicationLangBytes
Copyright © 2016. All rights reserved.