Class VectorClock
Representation of a Vector-based clock (counting clock), inspired by Lamport logical clocks.
Reference:
- Leslie Lamport (1978). "Time, clocks, and the ordering of events in a distributed system". Communications of the ACM 21 (7): 558-565.
- Friedemann Mattern (1988). "Virtual Time and Global States of Distributed Systems". Workshop on Parallel and Distributed Algorithms: pp. 215-226
Based on code from the 'vlock' VectorClock library by Coda Hale.
Inherited Members
Namespace: Akka.Cluster
Assembly: Akka.Cluster.dll
Syntax
public sealed class VectorClock
Properties
| Improve this Doc View SourceVersions
The list of vector clock values for each node.
Declaration
public ImmutableSortedDictionary<VectorClock.Node, long> Versions { get; }
Property Value
Type | Description |
---|---|
System.Collections.Immutable.ImmutableSortedDictionary<VectorClock.Node, Int64> |
Methods
| Improve this Doc View SourceCompareTo(VectorClock)
Compares the current vector clock with the supplied vector clock. The outcome will be one of the following:
- Clock 1 is SAME(==) as Clock 2 iff for all i c1(i) == c2(i)
- Clock 1 is BEFORE(<) Clock 2 iff for all i c1(i) <= c2(i) and there exist a j such that c1(j) < c2(j)
- Clock 1 is AFTER(>) Clock 2 iff for all i c1(i) >= c2(i) and there exist a j such that c1(j) > c2(j).
- Clock 1 is CONCURRENT(<>) to Clock 2 otherwise.
Declaration
public VectorClock.Ordering CompareTo(VectorClock that)
Parameters
Type | Name | Description |
---|---|---|
VectorClock | that | The vector clock used to compare against. |
Returns
Type | Description |
---|---|
VectorClock.Ordering | TBD |
Create()
Creates a new VectorClock
Declaration
public static VectorClock Create()
Returns
Type | Description |
---|---|
VectorClock | A new VectorClock. |
Create(ImmutableSortedDictionary<VectorClock.Node, Int64>)
Creates a VectorClock from some initial seed values.
Declaration
public static VectorClock Create(ImmutableSortedDictionary<VectorClock.Node, long> seedValues)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Immutable.ImmutableSortedDictionary<VectorClock.Node, Int64> | seedValues | Preliminary values that will be used by the vectorclock. |
Returns
Type | Description |
---|---|
VectorClock | A new VectorClock. |
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj |
Returns
Type | Description |
---|---|
Boolean |
Overrides
| Improve this Doc View SourceGetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
Overrides
| Improve this Doc View SourceIncrement(VectorClock.Node)
Increment the version for the node passed as argument. Returns a new VectorClock.
Declaration
public VectorClock Increment(VectorClock.Node node)
Parameters
Type | Name | Description |
---|---|---|
VectorClock.Node | node | Increment the vector clock value for a particular node. |
Returns
Type | Description |
---|---|
VectorClock | An updated VectorClock instance. |
IsAfter(VectorClock)
Returns true if
this
is after that
else false.
Declaration
public bool IsAfter(VectorClock that)
Parameters
Type | Name | Description |
---|---|---|
VectorClock | that | The other VectorClock to check. |
Returns
Type | Description |
---|---|
Boolean |
|
IsBefore(VectorClock)
Returns true if
this
is before that
else false.
Declaration
public bool IsBefore(VectorClock that)
Parameters
Type | Name | Description |
---|---|---|
VectorClock | that | The other VectorClock to check. |
Returns
Type | Description |
---|---|
Boolean |
|
IsConcurrentWith(VectorClock)
Returns true if
this
and that
are concurrent else false.
Declaration
public bool IsConcurrentWith(VectorClock that)
Parameters
Type | Name | Description |
---|---|---|
VectorClock | that | The other VectorClock to check. |
Returns
Type | Description |
---|---|
Boolean |
|
IsSameAs(VectorClock)
Returns true if this VectorClock has the same history as the 'that' VectorClock else false.
Declaration
public bool IsSameAs(VectorClock that)
Parameters
Type | Name | Description |
---|---|---|
VectorClock | that | The other VectorClock to check. |
Returns
Type | Description |
---|---|
Boolean |
|
Merge(VectorClock)
Merges the vector clock with another VectorClock (e.g. merges its versioned history).
Declaration
public VectorClock Merge(VectorClock that)
Parameters
Type | Name | Description |
---|---|---|
VectorClock | that | The vector clock to merge into the current clock. |
Returns
Type | Description |
---|---|
VectorClock | A newly created VectorClock with the current vector clock and the given vector clock merged. |
Prune(VectorClock.Node)
Removes the specified node from the current vector clock.
Declaration
public VectorClock Prune(VectorClock.Node removedNode)
Parameters
Type | Name | Description |
---|---|---|
VectorClock.Node | removedNode | The node that is being removed. |
Returns
Type | Description |
---|---|
VectorClock | A newly created VectorClock that has the given node removed. |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |
Overrides
Operators
| Improve this Doc View SourceEquality(VectorClock, VectorClock)
Compares two specified vector clocks for equality.
Declaration
public static bool operator ==(VectorClock left, VectorClock right)
Parameters
Type | Name | Description |
---|---|---|
VectorClock | left | The first vector clock used for comparison |
VectorClock | right | The second vector clock used for comparison |
Returns
Type | Description |
---|---|
Boolean |
|
GreaterThan(VectorClock, VectorClock)
Compares two specified vector clocks to see if the first one is greater than the other one.
Declaration
public static bool operator>(VectorClock left, VectorClock right)
Parameters
Type | Name | Description |
---|---|---|
VectorClock | left | The first vector clock used for comparison |
VectorClock | right | The second vector clock used for comparison |
Returns
Type | Description |
---|---|
Boolean |
|
Inequality(VectorClock, VectorClock)
Compares two specified vector clocks for inequality.
Declaration
public static bool operator !=(VectorClock left, VectorClock right)
Parameters
Type | Name | Description |
---|---|---|
VectorClock | left | The first vector clock used for comparison |
VectorClock | right | The second vector clock used for comparison |
Returns
Type | Description |
---|---|
Boolean |
|
LessThan(VectorClock, VectorClock)
Compares two specified vector clocks to see if the first one is less than the other one.
Declaration
public static bool operator <(VectorClock left, VectorClock right)
Parameters
Type | Name | Description |
---|---|---|
VectorClock | left | The first vector clock used for comparison |
VectorClock | right | The second vector clock used for comparison |
Returns
Type | Description |
---|---|
Boolean |
|