Package akka.cluster.ddata
Class GCounter
- java.lang.Object
-
- akka.cluster.ddata.GCounter
-
- All Implemented Interfaces:
DeltaReplicatedData
,FastMerge
,RemovedNodePruning
,ReplicatedData
,ReplicatedDataSerialization
,ReplicatedDelta
,java.io.Serializable
,scala.Serializable
public final class GCounter extends java.lang.Object implements DeltaReplicatedData, ReplicatedDelta, ReplicatedDataSerialization, RemovedNodePruning, FastMerge
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description GCounter(scala.collection.immutable.Map<UniqueAddress,scala.math.BigInt> state, scala.Option<GCounter> delta)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description GCounter
$colon$plus(long n, SelfUniqueAddress node)
Increment the counter with the deltan
specified.static scala.collection.immutable.Map<UniqueAddress,scala.math.BigInt>
$lessinit$greater$default$1()
Implements a 'Growing Counter' CRDT, also called a 'G-Counter'.static scala.Option<GCounter>
$lessinit$greater$default$2()
GCounter
$plus(long n, Cluster node)
Deprecated.Use `:+` that takes a `SelfUniqueAddress` parameter instead.static GCounter
apply()
static GCounter
create()
Java APIscala.Option<GCounter>
delta()
The accumulated delta of mutator operations since previousDeltaReplicatedData.resetDelta()
.static GCounter
empty()
boolean
equals(java.lang.Object o)
java.math.BigInteger
getValue()
Java API: Current total value of the counter.int
hashCode()
GCounter
increment(Cluster node, long n)
Deprecated.Use `increment` that takes a `SelfUniqueAddress` parameter instead.GCounter
increment(SelfUniqueAddress node, long n)
Increment the counter with the deltan
specified.GCounter
increment(UniqueAddress key)
INTERNAL APIGCounter
increment(UniqueAddress key, scala.math.BigInt n)
INTERNAL APIlong
increment$default$2()
GCounter
merge(GCounter that)
INTERNAL APIGCounter
mergeDelta(GCounter thatDelta)
scala.collection.immutable.Set<UniqueAddress>
modifiedByNodes()
boolean
needPruningFrom(UniqueAddress removedNode)
Does it have any state changes from a specific node, which has been removed from the cluster.GCounter
prune(UniqueAddress removedNode, UniqueAddress collapseInto)
When theremoved
node has been removed from the cluster the state changes from that node will be pruned by collapsing the data entries to another node.GCounter
pruningCleanup(UniqueAddress removedNode)
Remove data entries from a node that has been removed from the cluster and already been pruned.GCounter
resetDelta()
Reset collection of deltas from mutator operations.scala.collection.immutable.Map<UniqueAddress,scala.math.BigInt>
state()
java.lang.String
toString()
static scala.Option<scala.math.BigInt>
unapply(GCounter c)
Extract thevalue()
.scala.math.BigInt
value()
Scala API: Current total value of the counter.GCounter
zero()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface akka.cluster.ddata.DeltaReplicatedData
mergeDelta
-
Methods inherited from interface akka.cluster.ddata.FastMerge
ancestor_$eq, assignAncestor, clearAncestor, isAncestorOf
-
Methods inherited from interface akka.cluster.ddata.ReplicatedData
merge
-
-
-
-
Constructor Detail
-
GCounter
public GCounter(scala.collection.immutable.Map<UniqueAddress,scala.math.BigInt> state, scala.Option<GCounter> delta)
-
-
Method Detail
-
$lessinit$greater$default$1
public static scala.collection.immutable.Map<UniqueAddress,scala.math.BigInt> $lessinit$greater$default$1()
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.
- Returns:
- (undocumented)
-
$lessinit$greater$default$2
public static scala.Option<GCounter> $lessinit$greater$default$2()
-
empty
public static GCounter empty()
-
apply
public static GCounter apply()
-
create
public static GCounter create()
Java API- Returns:
- (undocumented)
-
unapply
public static scala.Option<scala.math.BigInt> unapply(GCounter c)
Extract thevalue()
.- Parameters:
c
- (undocumented)- Returns:
- (undocumented)
-
state
public scala.collection.immutable.Map<UniqueAddress,scala.math.BigInt> state()
-
delta
public scala.Option<GCounter> delta()
Description copied from interface:DeltaReplicatedData
The accumulated delta of mutator operations since previousDeltaReplicatedData.resetDelta()
. When theReplicator
invokes themodify
function of theUpdate
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 theReplicator
with theDeltaReplicatedData.delta()
accessor. Themodify
function shall still return the full state in the same way asReplicatedData
without support for deltas.- Specified by:
delta
in interfaceDeltaReplicatedData
- Returns:
- (undocumented)
-
value
public scala.math.BigInt value()
Scala API: Current total value of the counter.- Returns:
- (undocumented)
-
getValue
public java.math.BigInteger getValue()
Java API: Current total value of the counter.- Returns:
- (undocumented)
-
$colon$plus
public GCounter $colon$plus(long n, SelfUniqueAddress node)
Increment the counter with the deltan
specified. The delta must be zero or positive.- Parameters:
n
- (undocumented)node
- (undocumented)- Returns:
- (undocumented)
-
$plus
public GCounter $plus(long n, Cluster node)
Deprecated.Use `:+` that takes a `SelfUniqueAddress` parameter instead. Since 2.5.20.
-
increment
public GCounter increment(SelfUniqueAddress node, long n)
Increment the counter with the deltan
specified. The deltan
must be zero or positive.- Parameters:
node
- (undocumented)n
- (undocumented)- Returns:
- (undocumented)
-
increment
public GCounter increment(Cluster node, long n)
Deprecated.Use `increment` that takes a `SelfUniqueAddress` parameter instead. Since 2.5.20.
-
increment
public GCounter increment(UniqueAddress key)
INTERNAL API- Parameters:
key
- (undocumented)- Returns:
- (undocumented)
-
increment
public GCounter increment(UniqueAddress key, scala.math.BigInt n)
INTERNAL API- Parameters:
key
- (undocumented)n
- (undocumented)- Returns:
- (undocumented)
-
increment$default$2
public long increment$default$2()
-
merge
public GCounter merge(GCounter that)
INTERNAL API- Parameters:
that
- (undocumented)- Returns:
- (undocumented)
-
zero
public GCounter zero()
- Specified by:
zero
in interfaceReplicatedDelta
-
resetDelta
public GCounter resetDelta()
Description copied from interface:DeltaReplicatedData
Reset collection of deltas from mutator operations. When theReplicator
invokes themodify
function of theUpdate
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 theReplicator
with theDeltaReplicatedData.delta()
accessor. When theReplicator
has grabbed thedelta
it will invoke this method to get a clean data instance without the delta.- Specified by:
resetDelta
in interfaceDeltaReplicatedData
- Returns:
- (undocumented)
-
modifiedByNodes
public scala.collection.immutable.Set<UniqueAddress> modifiedByNodes()
- Specified by:
modifiedByNodes
in interfaceRemovedNodePruning
-
needPruningFrom
public boolean needPruningFrom(UniqueAddress removedNode)
Description copied from interface:RemovedNodePruning
Does it have any state changes from a specific node, which has been removed from the cluster.- Specified by:
needPruningFrom
in interfaceRemovedNodePruning
- Parameters:
removedNode
- (undocumented)- Returns:
- (undocumented)
-
prune
public GCounter prune(UniqueAddress removedNode, UniqueAddress collapseInto)
Description copied from interface:RemovedNodePruning
When theremoved
node has been removed from the cluster the state changes from that node will be pruned by collapsing the data entries to another node.- Specified by:
prune
in interfaceRemovedNodePruning
- Parameters:
removedNode
- (undocumented)collapseInto
- (undocumented)- Returns:
- (undocumented)
-
pruningCleanup
public GCounter pruningCleanup(UniqueAddress removedNode)
Description copied from interface:RemovedNodePruning
Remove data entries from a node that has been removed from the cluster and already been pruned.- Specified by:
pruningCleanup
in interfaceRemovedNodePruning
- Parameters:
removedNode
- (undocumented)- Returns:
- (undocumented)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-