Search Results for

    Show / Hide Table of Contents

    Class VectorClock

    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 the 'vlock' VectorClock library by Coda Hale.

    Inheritance
    object
    VectorClock
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Akka.Cluster
    Assembly: Akka.Cluster.dll
    Syntax
    public sealed class VectorClock

    Properties

    | Edit this page View Source

    Versions

    The list of vector clock values for each node.

    Declaration
    public ImmutableSortedDictionary<VectorClock.Node, long> Versions { get; }
    Property Value
    Type Description
    ImmutableSortedDictionary<VectorClock.Node, long>

    Methods

    | Edit this page View Source

    CompareTo(VectorClock)

    Compares the current vector clock with the supplied vector clock. The outcome will be one of the following:

    1. Clock 1 is SAME(==) as Clock 2 iff for all i c1(i) == c2(i)
    2. 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)
    3. 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).
    4. 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

    | Edit this page View Source

    Create()

    Creates a new VectorClock

    Declaration
    public static VectorClock Create()
    Returns
    Type Description
    VectorClock

    A new VectorClock.

    | Edit this page View Source

    Create(ImmutableSortedDictionary<Node, long>)

    Creates a VectorClock from some initial seed values.

    Declaration
    public static VectorClock Create(ImmutableSortedDictionary<VectorClock.Node, long> seedValues)
    Parameters
    Type Name Description
    ImmutableSortedDictionary<VectorClock.Node, long> seedValues

    Preliminary values that will be used by the vectorclock.

    Returns
    Type Description
    VectorClock

    A new VectorClock.

    | Edit this page View Source

    Equals(object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj
    Returns
    Type Description
    bool
    Overrides
    object.Equals(object)
    | Edit this page View Source

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    object.GetHashCode()
    | Edit this page View Source

    Increment(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.

    | Edit this page View Source

    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
    bool

    true if this vectorclock comes after the one we're comparing.

    | Edit this page View Source

    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
    bool

    true if this vectorclock comes before the one we're comparing.

    | Edit this page View Source

    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
    bool

    true if both vector clocks contain concurrent modifications that need to be merged.

    | Edit this page View Source

    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
    bool

    true if this vectorclock is the same as the one we're comparing.

    | Edit this page View Source

    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.

    | Edit this page View Source

    Prune(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.

    | Edit this page View Source

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    object.ToString()

    Operators

    | Edit this page View Source

    operator ==(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
    bool

    true if both vector clocks are equal; otherwise false

    | Edit this page View Source

    operator >(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
    bool

    true if the first vector clock is greater than the other one; otherwise false

    | Edit this page View Source

    operator !=(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
    bool

    true if both vector clocks are not equal; otherwise false

    | Edit this page View Source

    operator <(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
    bool

    true if the first vector clock is less than the other one; otherwise false

    Extension Methods

    ObjectExtensions.IsDefaultForType<T>(T)
    ObjectExtensions.AsOption<T>(T)
    Extensions.AsInstanceOf<T>(object)
    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET