Interface ReplicatedRegister<T>

  • Type Parameters:
    T -
    All Superinterfaces:
    ReplicatedData

    public interface ReplicatedRegister<T>
    extends ReplicatedData
    A Last-Write-Wins Register.

    This uses a clock value to determine which of two concurrent writes should win. When both clock values are the same, an ordering defined over the node addresses is used to break the tie.

    By default, the clock used is the clock of the node that set the value. This can be affected by clock skew, which means two successive writes delegated to two separate nodes could result in the first one winning. This can be avoided by using a custom clock with a domain specific clock value, if such a causally ordered value is available.

    • Method Detail

      • get

        T get()
        Get the current value of the register.
        Returns:
        the current value of the register
      • set

        default ReplicatedRegister<T> set​(T value)
        Set the value of the register, using the default clock.
        Parameters:
        value - the new value of the register
        Returns:
        a new register with updated value
      • set

        ReplicatedRegister<T> set​(T value,
                                  ReplicatedRegister.Clock clock,
                                  long customClockValue)
        Set the current value of the register, using the given custom clock and clock value if required.
        Parameters:
        value - the new value of the register
        clock - the clock to use for replication
        customClockValue - the custom clock value to use, only if it's a custom clock
        Returns:
        a new register with updated value