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.

@FunctionalInterface public static interface WanConsumer.ConflictResolver
Strategy for resolving conflicts when both local and remote clusters have concurrent writes to the same key.
Since:
2.0
  • Method Summary

    Modifier and Type
    Method
    Description
    Last-write-wins: keep the value with the later timestamp.
    Always keep the local value (ignore remote writes on conflict).
    Always 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 key
      localValue - the local value (may be null)
      remoteValue - the remote value (may be null)
      localTimestamp - epoch millis when local value was written
      remoteTimestamp - epoch millis when remote value was written
      Returns:
      the resolved value to keep (null to delete the key)
    • lastWriteWins

      static @NonNull WanConsumer.ConflictResolver lastWriteWins()
      Last-write-wins: keep the value with the later timestamp. On tie, remote wins (bias toward convergence).
      Returns:
      a LWW conflict resolver
    • localWins

      static @NonNull WanConsumer.ConflictResolver localWins()
      Always keep the local value (ignore remote writes on conflict).
      Returns:
      a local-wins conflict resolver
    • remoteWins

      static @NonNull WanConsumer.ConflictResolver remoteWins()
      Always accept the remote value (overwrite local on conflict).
      Returns:
      a remote-wins conflict resolver