Class GCounter
Implements a 'Growing Counter' CRDT, also called a 'G-Counter'.
It is described in the paper A comprehensive study of Convergent and Commutative Replicated Data Types.
A G-Counter is a increment-only counter (inspired by vector clocks) in which only increment and merge are possible. Incrementing the counter adds 1 to the count for the current node. Divergent histories are resolved by taking the maximum count for each node (like a vector clock merge). The value of the counter is the sum of all node counts.
This class is immutable, i.e. "modifying" methods return a new instance.
Implements
Inherited Members
Namespace: Akka.DistributedData
Assembly: Akka.DistributedData.dll
Syntax
[Serializable]
public sealed class GCounter : FastMerge<GCounter>, IRemovedNodePruning<GCounter>, IRemovedNodePruning, IEquatable<GCounter>, IReplicatedDataSerialization, IDeltaReplicatedData<GCounter, GCounter>, IDeltaReplicatedData, IReplicatedData<GCounter>, IReplicatedDelta, IReplicatedData
Constructors
| Edit this page View SourceGCounter()
TBD
Declaration
public GCounter()
Properties
| Edit this page View SourceDelta
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 GCounter Delta { get; }
Property Value
| Type | Description |
|---|---|
| GCounter |
Empty
TBD
Declaration
public static GCounter Empty { get; }
Property Value
| Type | Description |
|---|---|
| GCounter |
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> |
State
TBD
Declaration
public ImmutableDictionary<UniqueAddress, ulong> State { get; }
Property Value
| Type | Description |
|---|---|
| ImmutableDictionary<UniqueAddress, ulong> |
Value
Current total value of the counter.
Declaration
public ulong Value { get; }
Property Value
| Type | Description |
|---|---|
| ulong |
Methods
| Edit this page View SourceEquals(GCounter)
Declaration
public bool Equals(GCounter other)
Parameters
| Type | Name | Description |
|---|---|---|
| GCounter | other |
Returns
| Type | Description |
|---|---|
| bool |
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
| Edit this page View SourceGetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
Overrides
| Edit this page View SourceIncrement(Cluster, ulong)
Increment the counter with the delta specified. The delta must be zero or positive.
Declaration
public GCounter Increment(Cluster node, ulong delta = 1)
Parameters
| Type | Name | Description |
|---|---|---|
| Cluster | node | |
| ulong | delta |
Returns
| Type | Description |
|---|---|
| GCounter |
Increment(UniqueAddress, ulong)
Increment the counter with the delta specified. The delta must be zero or positive.
Declaration
public GCounter Increment(UniqueAddress node, ulong n = 1)
Parameters
| Type | Name | Description |
|---|---|---|
| UniqueAddress | node | TBD |
| ulong | n | TBD |
Returns
| Type | Description |
|---|---|
| GCounter | TBD |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | This exception is thrown when the specified |
Merge(GCounter)
TBD
Declaration
public override GCounter Merge(GCounter other)
Parameters
| Type | Name | Description |
|---|---|---|
| GCounter | other | TBD |
Returns
| Type | Description |
|---|---|
| GCounter | TBD |
Overrides
| Edit this page View SourceMergeDelta(GCounter)
When delta is merged into the full state this method is used. When the type GCounter of the delta is of the same type as the full state GCounter this method can be implemented by delegating to Merge(T).
Declaration
public GCounter MergeDelta(GCounter delta)
Parameters
| Type | Name | Description |
|---|---|---|
| GCounter | delta |
Returns
| Type | Description |
|---|---|
| GCounter |
NeedPruningFrom(UniqueAddress)
TBD
Declaration
public bool NeedPruningFrom(UniqueAddress removedNode)
Parameters
| Type | Name | Description |
|---|---|---|
| UniqueAddress | removedNode | TBD |
Returns
| Type | Description |
|---|---|
| bool | TBD |
Prune(UniqueAddress, UniqueAddress)
TBD
Declaration
public GCounter Prune(UniqueAddress removedNode, UniqueAddress collapseInto)
Parameters
| Type | Name | Description |
|---|---|---|
| UniqueAddress | removedNode | TBD |
| UniqueAddress | collapseInto | TBD |
Returns
| Type | Description |
|---|---|
| GCounter | TBD |
PruningCleanup(UniqueAddress)
TBD
Declaration
public GCounter PruningCleanup(UniqueAddress removedNode)
Parameters
| Type | Name | Description |
|---|---|---|
| UniqueAddress | removedNode | TBD |
Returns
| Type | Description |
|---|---|
| GCounter | TBD |
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 GCounter ResetDelta()
Returns
| Type | Description |
|---|---|
| GCounter |
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |
Overrides
Operators
| Edit this page View Sourceimplicit operator ulong(GCounter)
Declaration
public static implicit operator ulong(GCounter counter)
Parameters
| Type | Name | Description |
|---|---|---|
| GCounter | counter | The counter to convert |
Returns
| Type | Description |
|---|---|
| ulong | The result of the conversion |
Edit this page