public interface EngineReplicationLangBytes extends Closeable
*** PLEASE DON'T REFACTOR THIS WITHOUT FIRST CHANGING THE ENGINE CODE ***
Modifier and Type | Interface and Description |
---|---|
static interface |
EngineReplicationLangBytes.EngineEntryCallback
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 |
EngineReplicationLangBytes.EngineModificationIterator
Holds a record of which entries have modification.
|
static interface |
EngineReplicationLangBytes.EngineReplicationModificationNotifier
notifies when there is a changed to the modification iterator
|
Modifier and Type | Method and Description |
---|---|
EngineReplicationLangBytes.EngineModificationIterator |
acquireEngineModificationIterator(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 instance.
|
long |
lastModificationTime(byte remoteIdentifier)
Returns the timestamp of the last change from the specified remote node, already replicated
to this host.
|
void |
put(Bytes key,
Bytes value,
byte remoteIdentifier,
long timestamp)
inserts or updates the entry
|
void |
remove(Bytes key,
byte remoteIdentifier,
long timestamp)
marks the entry as removed
|
void |
setLastModificationTime(byte identifier,
long timestamp) |
void put(Bytes key, Bytes value, byte remoteIdentifier, long timestamp)
key
- the key of the entryvalue
- the value of the entryremoteIdentifier
- the identifier of the remote servertimestamp
- the timestamp send from the remote server, this time stamp was the
time the entry was removedvoid remove(Bytes key, byte remoteIdentifier, long timestamp)
key
- the key of the entryremoteIdentifier
- the identifier of the remote servertimestamp
- the timestamp send from the remote server, this time stamp was the
time the entry was removedbyte 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.
EngineReplicationLangBytes.EngineModificationIterator acquireEngineModificationIterator(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.
remoteIdentifier
- the identifier of the remote node to check last replicated update
time fromidentifier()
void setLastModificationTime(byte identifier, long timestamp)
Copyright © 2016. All rights reserved.