Package org.apache.pekko.cluster.ddata
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic interfacestatic classstatic classINTERNAL API -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription$colon$plus(SelfUniqueAddress node) Increment the version for the node passed as argument.boolean$eq$eq(VersionVector that) Returns true if this VersionVector has the same history as the 'that' VersionVector else false.boolean$greater(VersionVector that) Returns true ifthisis afterthatelse false.boolean$less(VersionVector that) Returns true ifthisis beforethatelse false.boolean$less$greater(VersionVector that) Returns true ifthisandthatare concurrent else false.static VersionVector.After$Java API: TheVersionVector.Afterinstancestatic VersionVectorapply()static VersionVectorapply(UniqueAddress node, long version) static VersionVectorapply(scala.collection.immutable.TreeMap<UniqueAddress, Object> versions) static VersionVector.Before$Java API: TheVersionVector.BeforeinstancecompareTo(VersionVector that) Compare two version vectors.static VersionVector.Concurrent$Java API: TheVersionVector.Concurrentinstancestatic VersionVectorcreate()Java APIstatic VersionVectorempty()increment(SelfUniqueAddress node) Increment the version for the node passed as argument.abstract booleanisEmpty()abstract VersionVectormerge(VersionVector that) Merges this VersionVector with another VersionVector.abstract booleanneedPruningFrom(UniqueAddress removedNode) Does it have any state changes from a specific node, which has been removed from the cluster.abstract VersionVectorprune(UniqueAddress removedNode, UniqueAddress collapseInto) When theremovednode has been removed from the cluster the state changes from that node will be pruned by collapsing the data entries to another node.abstract VersionVectorpruningCleanup(UniqueAddress removedNode) Remove data entries from a node that has been removed from the cluster and already been pruned.static VersionVector.Same$Java API: TheVersionVector.SameinstanceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.pekko.cluster.ddata.RemovedNodePruning
modifiedByNodesMethods inherited from interface org.apache.pekko.cluster.ddata.ReplicatedData
merge
-
Constructor Details
-
VersionVector
public VersionVector()
-
-
Method Details
-
empty
-
apply
-
apply
public static VersionVector apply(scala.collection.immutable.TreeMap<UniqueAddress, Object> versions) -
apply
-
create
Java API -
AfterInstance
Java API: TheVersionVector.Afterinstance -
BeforeInstance
Java API: TheVersionVector.Beforeinstance -
SameInstance
Java API: TheVersionVector.Sameinstance -
ConcurrentInstance
Java API: TheVersionVector.Concurrentinstance -
$colon$plus
Increment the version for the node passed as argument. Returns a new VersionVector. -
increment
Increment the version for the node passed as argument. Returns a new VersionVector. -
isEmpty
public abstract boolean isEmpty() -
$less$greater
Returns true ifthisandthatare concurrent else false. -
$less
Returns true ifthisis beforethatelse false. -
$greater
Returns true ifthisis afterthatelse false. -
$eq$eq
Returns true if this VersionVector has the same history as the 'that' VersionVector else false. -
compareTo
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
Merges this VersionVector with another VersionVector. E.g. merges its versioned history. -
needPruningFrom
Description copied from interface:RemovedNodePruningDoes it have any state changes from a specific node, which has been removed from the cluster.- Specified by:
needPruningFromin interfaceRemovedNodePruning
-
prune
Description copied from interface:RemovedNodePruningWhen theremovednode 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:
prunein interfaceRemovedNodePruning
-
pruningCleanup
Description copied from interface:RemovedNodePruningRemove data entries from a node that has been removed from the cluster and already been pruned.- Specified by:
pruningCleanupin interfaceRemovedNodePruning
-