Class VersionVector

java.lang.Object
org.apache.pekko.cluster.ddata.VersionVector
All Implemented Interfaces:
Serializable, RemovedNodePruning, ReplicatedData, ReplicatedDataSerialization
Direct Known Subclasses:
ManyVersionVector, OneVersionVector

public abstract class VersionVector extends Object implements ReplicatedData, ReplicatedDataSerialization, RemovedNodePruning
Representation of a Vector-based clock (counting clock), inspired by Lamport logical clocks.

 Reference:
    1) Leslie Lamport (1978). "Time, clocks, and the ordering of events in a distributed system". Communications of the ACM 21 (7): 558-565.
    2) Friedemann Mattern (1988). "Virtual Time and Global States of Distributed Systems". Workshop on Parallel and Distributed Algorithms: pp. 215-226
 

Based on code from org.apache.pekko.cluster.VectorClock.

This class is immutable, i.e. "modifying" methods return a new instance.

See Also:
  • Constructor Details

    • VersionVector

      public VersionVector()
  • Method Details

    • empty

      public static VersionVector empty()
    • apply

      public static VersionVector apply()
    • apply

      public static VersionVector apply(scala.collection.immutable.TreeMap<UniqueAddress,Object> versions)
    • apply

      public static VersionVector apply(UniqueAddress node, long version)
    • create

      public static VersionVector create()
      Java API
    • AfterInstance

      public static VersionVector.After$ AfterInstance()
      Java API: The VersionVector.After instance
    • BeforeInstance

      public static VersionVector.Before$ BeforeInstance()
      Java API: The VersionVector.Before instance
    • SameInstance

      public static VersionVector.Same$ SameInstance()
      Java API: The VersionVector.Same instance
    • ConcurrentInstance

      public static VersionVector.Concurrent$ ConcurrentInstance()
      Java API: The VersionVector.Concurrent instance
    • $colon$plus

      public VersionVector $colon$plus(SelfUniqueAddress node)
      Increment the version for the node passed as argument. Returns a new VersionVector.
    • increment

      public VersionVector increment(SelfUniqueAddress node)
      Increment the version for the node passed as argument. Returns a new VersionVector.
    • isEmpty

      public abstract boolean isEmpty()
    • $less$greater

      public boolean $less$greater(VersionVector that)
      Returns true if this and that are concurrent else false.
    • $less

      public boolean $less(VersionVector that)
      Returns true if this is before that else false.
    • $greater

      public boolean $greater(VersionVector that)
      Returns true if this is after that else false.
    • $eq$eq

      public boolean $eq$eq(VersionVector that)
      Returns true if this VersionVector has the same history as the 'that' VersionVector else false.
    • compareTo

      public VersionVector.Ordering compareTo(VersionVector that)
      Compare two version vectors. The outcome will be one of the following:

      
         1. Version 1 is SAME (==)       as Version 2 iff for all i c1(i) == c2(i)
         2. Version 1 is BEFORE (<)      Version 2 iff for all i c1(i) <= c2(i) and there exist a j such that c1(j) < c2(j)
         3. Version 1 is AFTER (>)       Version 2 iff for all i c1(i) >= c2(i) and there exist a j such that c1(j) > c2(j).
         4. Version 1 is CONCURRENT (<>) to Version 2 otherwise.
       
    • merge

      public abstract VersionVector merge(VersionVector that)
      Merges this VersionVector with another VersionVector. E.g. merges its versioned history.
    • needPruningFrom

      public abstract boolean needPruningFrom(UniqueAddress removedNode)
      Description copied from interface: RemovedNodePruning
      Does it have any state changes from a specific node, which has been removed from the cluster.
      Specified by:
      needPruningFrom in interface RemovedNodePruning
    • prune

      public abstract VersionVector prune(UniqueAddress removedNode, UniqueAddress collapseInto)
      Description copied from interface: RemovedNodePruning
      When the removed node has been removed from the cluster the state changes from that node will be pruned by collapsing the data entries to another node.
      Specified by:
      prune in interface RemovedNodePruning
    • pruningCleanup

      public abstract VersionVector pruningCleanup(UniqueAddress removedNode)
      Description copied from interface: RemovedNodePruning
      Remove data entries from a node that has been removed from the cluster and already been pruned.
      Specified by:
      pruningCleanup in interface RemovedNodePruning