Interface WanConsumer.ConflictResolver
- Enclosing class:
WanConsumer
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Strategy for resolving conflicts when both local and remote clusters
have concurrent writes to the same key.
- Since:
- 2.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull WanConsumer.ConflictResolverLast-write-wins: keep the value with the later timestamp.static @NonNull WanConsumer.ConflictResolverAlways keep the local value (ignore remote writes on conflict).static @NonNull WanConsumer.ConflictResolverAlways accept the remote value (overwrite local on conflict).byte @Nullable []resolve(@NonNull String key, byte @Nullable [] localValue, byte @Nullable [] remoteValue, long localTimestamp, long remoteTimestamp) Resolve a conflict between local and remote values.
-
Method Details
-
resolve
byte @Nullable [] resolve(@NonNull String key, byte @Nullable [] localValue, byte @Nullable [] remoteValue, long localTimestamp, long remoteTimestamp) Resolve a conflict between local and remote values.- Parameters:
key- the conflicting keylocalValue- the local value (may be null)remoteValue- the remote value (may be null)localTimestamp- epoch millis when local value was writtenremoteTimestamp- epoch millis when remote value was written- Returns:
- the resolved value to keep (null to delete the key)
-
lastWriteWins
Last-write-wins: keep the value with the later timestamp. On tie, remote wins (bias toward convergence).- Returns:
- a LWW conflict resolver
-
localWins
Always keep the local value (ignore remote writes on conflict).- Returns:
- a local-wins conflict resolver
-
remoteWins
Always accept the remote value (overwrite local on conflict).- Returns:
- a remote-wins conflict resolver
-