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.
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
|
Edit this page
View Source
PNCounter(GCounter, GCounter)
Declaration
public PNCounter(GCounter increments, GCounter decrements)
Parameters
Fields
|
Edit this page
View Source
Empty
Declaration
public static readonly PNCounter Empty
Field Value
Properties
|
Edit this page
View Source
Decrements
Declaration
public GCounter Decrements { get; }
Property Value
|
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
|
Edit this page
View Source
Increments
Declaration
public GCounter Increments { get; }
Property Value
|
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
|
Edit this page
View Source
Value
Declaration
public BigInteger Value { get; }
Property Value
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
Returns
|
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
Returns
|
Edit this page
View Source
Equals(PNCounter)
Declaration
public bool Equals(PNCounter other)
Parameters
Returns
|
Edit this page
View Source
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
object |
obj |
|
Returns
Overrides
|
Edit this page
View Source
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Overrides
|
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
Returns
|
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
Returns
|
Edit this page
View Source
Merge(IReplicatedData)
Declaration
public IReplicatedData Merge(IReplicatedData other)
Parameters
Returns
|
Edit this page
View Source
Merge(PNCounter)
Declaration
public PNCounter Merge(PNCounter other)
Parameters
Returns
|
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
Returns
|
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
Returns
|
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
Returns
|
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
Returns
|
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
|
Edit this page
View Source
ToString()
Declaration
public override string ToString()
Returns
Overrides
Implements
Extension Methods