Search Results for

    Show / Hide Table of Contents

    Class PNCounter

    Implements a 'Increment/Decrement Counter' CRDT, also called a 'PN-Counter'.

    It is described in the paper A comprehensive study of Convergent and Commutative Replicated Data Types.

    PN-Counters allow the counter to be incremented by tracking the increments (P) separate from the decrements (N). Both P and N are represented as two internal [[GCounter]]s. Merge is handled by merging the internal P and N counters. The value of the counter is the value of the P _counter minus the value of the N counter.

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

    Inheritance
    object
    PNCounter
    Implements
    IDeltaReplicatedData<PNCounter, PNCounter>
    IDeltaReplicatedData
    IRemovedNodePruning<PNCounter>
    IRemovedNodePruning
    IReplicatedData<PNCounter>
    IReplicatedDataSerialization
    IEquatable<PNCounter>
    IReplicatedDelta
    IReplicatedData
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Akka.DistributedData
    Assembly: Akka.DistributedData.dll
    Syntax
    [Serializable]
    public sealed class PNCounter : IDeltaReplicatedData<PNCounter, PNCounter>, IDeltaReplicatedData, IRemovedNodePruning<PNCounter>, IRemovedNodePruning, IReplicatedData<PNCounter>, IReplicatedDataSerialization, IEquatable<PNCounter>, IReplicatedDelta, IReplicatedData

    Constructors

    | Edit this page View Source

    PNCounter()

    Declaration
    public PNCounter()
    | Edit this page View Source

    PNCounter(GCounter, GCounter)

    Declaration
    public PNCounter(GCounter increments, GCounter decrements)
    Parameters
    Type Name Description
    GCounter increments
    GCounter decrements

    Fields

    | Edit this page View Source

    Empty

    Declaration
    public static readonly PNCounter Empty
    Field Value
    Type Description
    PNCounter

    Properties

    | Edit this page View Source

    Decrements

    Declaration
    public GCounter Decrements { get; }
    Property Value
    Type Description
    GCounter
    | Edit this page View Source

    Delta

    The accumulated delta of mutator operations since previous ResetDelta(). When the Akka.DistributedData.Replicator invokes the modify function of the Update message and the user code is invoking one or more mutator operations the data is collecting the delta of the operations and makes it available for the Akka.DistributedData.Replicator with the Delta accessor. The modify function shall still return the full state in the same way as IReplicatedData<T> without support for deltas.

    Declaration
    public PNCounter Delta { get; }
    Property Value
    Type Description
    PNCounter
    | Edit this page View Source

    Increments

    Declaration
    public GCounter Increments { get; }
    Property Value
    Type Description
    GCounter
    | Edit this page View Source

    ModifiedByNodes

    The nodes that have changed the state for this data and would need pruning when such node is no longer part of the cluster.

    Declaration
    public ImmutableHashSet<UniqueAddress> ModifiedByNodes { get; }
    Property Value
    Type Description
    ImmutableHashSet<UniqueAddress>
    | Edit this page View Source

    Value

    Declaration
    public BigInteger Value { get; }
    Property Value
    Type Description
    BigInteger

    Methods

    | Edit this page View Source

    Decrement(Cluster, long)

    Decrement the counter with the delta specified. If the delta is negative then it will increment instead of decrement.

    Declaration
    public PNCounter Decrement(Cluster node, long delta = 1)
    Parameters
    Type Name Description
    Cluster node
    long delta
    Returns
    Type Description
    PNCounter
    | Edit this page View Source

    Decrement(UniqueAddress, long)

    Decrement the counter with the delta specified. If the delta is negative then it will increment instead of decrement.

    Declaration
    public PNCounter Decrement(UniqueAddress address, long delta = 1)
    Parameters
    Type Name Description
    UniqueAddress address
    long delta
    Returns
    Type Description
    PNCounter
    | Edit this page View Source

    Equals(PNCounter)

    Declaration
    public bool Equals(PNCounter other)
    Parameters
    Type Name Description
    PNCounter other
    Returns
    Type Description
    bool
    | 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(Cluster, long)

    Increment the counter with the delta specified. If the delta is negative then it will decrement instead of increment.

    Declaration
    public PNCounter Increment(Cluster node, long delta = 1)
    Parameters
    Type Name Description
    Cluster node
    long delta
    Returns
    Type Description
    PNCounter
    | Edit this page View Source

    Increment(UniqueAddress, long)

    Increment the counter with the delta specified. If the delta is negative then it will decrement instead of increment.

    Declaration
    public PNCounter Increment(UniqueAddress address, long delta = 1)
    Parameters
    Type Name Description
    UniqueAddress address
    long delta
    Returns
    Type Description
    PNCounter
    | Edit this page View Source

    Merge(IReplicatedData)

    Declaration
    public IReplicatedData Merge(IReplicatedData other)
    Parameters
    Type Name Description
    IReplicatedData other
    Returns
    Type Description
    IReplicatedData
    | Edit this page View Source

    Merge(PNCounter)

    Monotonic merge method.

    Declaration
    public PNCounter Merge(PNCounter other)
    Parameters
    Type Name Description
    PNCounter other
    Returns
    Type Description
    PNCounter
    | Edit this page View Source

    MergeDelta(PNCounter)

    When delta is merged into the full state this method is used. When the type PNCounter of the delta is of the same type as the full state PNCounter this method can be implemented by delegating to Merge(T).

    Declaration
    public PNCounter MergeDelta(PNCounter delta)
    Parameters
    Type Name Description
    PNCounter delta
    Returns
    Type Description
    PNCounter
    | Edit this page View Source

    NeedPruningFrom(UniqueAddress)

    Does it have any state changes from a specific node, which has been removed from the cluster.

    Declaration
    public bool NeedPruningFrom(UniqueAddress removedNode)
    Parameters
    Type Name Description
    UniqueAddress removedNode
    Returns
    Type Description
    bool
    | Edit this page View Source

    Prune(UniqueAddress, UniqueAddress)

    When the removedNode node has been removed from the cluster the state changes from that node will be pruned by collapsing the data entries to another node.

    Declaration
    public PNCounter Prune(UniqueAddress removedNode, UniqueAddress collapseInto)
    Parameters
    Type Name Description
    UniqueAddress removedNode
    UniqueAddress collapseInto
    Returns
    Type Description
    PNCounter
    | Edit this page View Source

    PruningCleanup(UniqueAddress)

    Remove data entries from a node that has been removed from the cluster and already been pruned.

    Declaration
    public PNCounter PruningCleanup(UniqueAddress removedNode)
    Parameters
    Type Name Description
    UniqueAddress removedNode
    Returns
    Type Description
    PNCounter
    | Edit this page View Source

    ResetDelta()

    Reset collection of deltas from mutator operations. When the Akka.DistributedData.Replicator invokes the modify function of the Update message the delta is always "reset" and when the user code is invoking one or more mutator operations the data is collecting the delta of the operations and makes it available for the Akka.DistributedData.Replicator with the Delta accessor. When the Akka.DistributedData.Replicator has grabbed the Delta it will invoke this method to get a clean data instance without the delta.

    Declaration
    public PNCounter ResetDelta()
    Returns
    Type Description
    PNCounter
    | Edit this page View Source

    ToString()

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

    Implements

    IDeltaReplicatedData<T, TDelta>
    IDeltaReplicatedData
    IRemovedNodePruning<T>
    IRemovedNodePruning
    IReplicatedData<T>
    IReplicatedDataSerialization
    IEquatable<T>
    IReplicatedDelta
    IReplicatedData

    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