Package akka.cluster.ddata
Class PNCounter
- java.lang.Object
- 
- akka.cluster.ddata.PNCounter
 
- 
- All Implemented Interfaces:
- DeltaReplicatedData,- RemovedNodePruning,- ReplicatedData,- ReplicatedDataSerialization,- ReplicatedDelta,- java.io.Serializable
 
 public final class PNCounter extends java.lang.Object implements DeltaReplicatedData, ReplicatedDelta, ReplicatedDataSerialization, RemovedNodePruning 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 GCounters. 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. - See Also:
- Serialized Form
 
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PNCounter$colon$plus(long n, SelfUniqueAddress node)Increment the counter with the deltanspecified.PNCounter$colon$plus(scala.math.BigInt n, SelfUniqueAddress node)Increment the counter with the deltanspecified.static PNCounterapply()static PNCountercreate()Java APIPNCounterdecrement(long n, SelfUniqueAddress node)Decrement the counter with the deltanspecified.PNCounterdecrement(SelfUniqueAddress node, long n)Decrement the counter with the deltanspecified.PNCounterdecrement(SelfUniqueAddress node, java.math.BigInteger n)Java API: Decrement the counter with the deltanspecified.PNCounterdecrement(SelfUniqueAddress node, scala.math.BigInt n)Scala API: Decrement the counter with the deltanspecified.PNCounterdecrement(scala.math.BigInt n, SelfUniqueAddress node)Decrement the counter with the deltanspecified.scala.Option<PNCounter>delta()The accumulated delta of mutator operations since previousDeltaReplicatedData.resetDelta().static PNCounterempty()booleanequals(java.lang.Object o)java.math.BigIntegergetValue()Java API: Current total value of the counter.inthashCode()PNCounterincrement(long n, SelfUniqueAddress node)Scala API: Increment the counter with the deltanspecified.PNCounterincrement(SelfUniqueAddress node, long n)Java API: Increment the counter with the deltanspecified.PNCounterincrement(SelfUniqueAddress node, java.math.BigInteger n)Java API: Increment the counter with the deltanspecified.PNCounterincrement(scala.math.BigInt n, SelfUniqueAddress node)Increment the counter with the deltanspecified.PNCountermerge(PNCounter that)PNCountermergeDelta(PNCounter thatDelta)scala.collection.immutable.Set<UniqueAddress>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.booleanneedPruningFrom(UniqueAddress removedNode)Does it have any state changes from a specific node, which has been removed from the cluster.PNCounterprune(UniqueAddress removedNode, UniqueAddress collapseInto)When theremovednode has been removed from the cluster the state changes from that node will be pruned by collapsing the data entries to another node.PNCounterpruningCleanup(UniqueAddress removedNode)Remove data entries from a node that has been removed from the cluster and already been pruned.PNCounterresetDelta()Reset collection of deltas from mutator operations.java.lang.StringtoString()static scala.Option<scala.math.BigInt>unapply(PNCounter c)Extract theGCounter.value().scala.math.BigIntvalue()Scala API: Current total value of the counter.PNCounterzero()The empty full state.- 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface akka.cluster.ddata.DeltaReplicatedDatamergeDelta
 - 
Methods inherited from interface akka.cluster.ddata.ReplicatedDatamerge
 
- 
 
- 
- 
- 
Method Detail- 
emptypublic static PNCounter empty() 
 - 
applypublic static PNCounter apply() 
 - 
createpublic static PNCounter create() Java API
 - 
unapplypublic static scala.Option<scala.math.BigInt> unapply(PNCounter c) Extract theGCounter.value().
 - 
valuepublic scala.math.BigInt value() Scala API: Current total value of the counter.
 - 
getValuepublic java.math.BigInteger getValue() Java API: Current total value of the counter.
 - 
$colon$pluspublic PNCounter $colon$plus(long n, SelfUniqueAddress node) Increment the counter with the deltanspecified. If the delta is negative then it will decrement instead of increment.
 - 
$colon$pluspublic PNCounter $colon$plus(scala.math.BigInt n, SelfUniqueAddress node) Increment the counter with the deltanspecified. If the delta is negative then it will decrement instead of increment.
 - 
incrementpublic PNCounter increment(long n, SelfUniqueAddress node) Scala API: Increment the counter with the deltanspecified. If the delta is negative then it will decrement instead of increment.
 - 
incrementpublic PNCounter increment(scala.math.BigInt n, SelfUniqueAddress node) Increment the counter with the deltanspecified. If the delta is negative then it will decrement instead of increment.
 - 
incrementpublic PNCounter increment(SelfUniqueAddress node, java.math.BigInteger n) Java API: Increment the counter with the deltanspecified. If the delta is negative then it will decrement instead of increment.
 - 
incrementpublic PNCounter increment(SelfUniqueAddress node, long n) Java API: Increment the counter with the deltanspecified. If the delta is negative then it will decrement instead of increment.
 - 
decrementpublic PNCounter decrement(long n, SelfUniqueAddress node) Decrement the counter with the deltanspecified. If the delta is negative then it will increment instead of decrement.
 - 
decrementpublic PNCounter decrement(scala.math.BigInt n, SelfUniqueAddress node) Decrement the counter with the deltanspecified. If the delta is negative then it will increment instead of decrement.
 - 
decrementpublic PNCounter decrement(SelfUniqueAddress node, long n) Decrement the counter with the deltanspecified. If the deltanis negative then it will increment instead of decrement.
 - 
decrementpublic PNCounter decrement(SelfUniqueAddress node, scala.math.BigInt n) Scala API: Decrement the counter with the deltanspecified. If the deltanis negative then it will increment instead of decrement.
 - 
decrementpublic PNCounter decrement(SelfUniqueAddress node, java.math.BigInteger n) Java API: Decrement the counter with the deltanspecified. If the deltanis negative then it will increment instead of decrement.
 - 
deltapublic scala.Option<PNCounter> delta() Description copied from interface:DeltaReplicatedDataThe accumulated delta of mutator operations since previousDeltaReplicatedData.resetDelta(). When theReplicatorinvokes themodifyfunction of theUpdatemessage 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 theReplicatorwith theDeltaReplicatedData.delta()accessor. Themodifyfunction shall still return the full state in the same way asReplicatedDatawithout support for deltas.- Specified by:
- deltain interface- DeltaReplicatedData
 
 - 
zeropublic PNCounter zero() Description copied from interface:ReplicatedDeltaThe empty full state. This is used when a delta is received and no existing full state exists on the receiving side. Then the delta is merged into thezeroto create the initial full state.- Specified by:
- zeroin interface- ReplicatedDelta
 
 - 
resetDeltapublic PNCounter resetDelta() Description copied from interface:DeltaReplicatedDataReset collection of deltas from mutator operations. When theReplicatorinvokes themodifyfunction of theUpdatemessage 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 theReplicatorwith theDeltaReplicatedData.delta()accessor. When theReplicatorhas grabbed thedeltait will invoke this method to get a clean data instance without the delta.- Specified by:
- resetDeltain interface- DeltaReplicatedData
 
 - 
modifiedByNodespublic scala.collection.immutable.Set<UniqueAddress> modifiedByNodes() Description copied from interface:RemovedNodePruningThe nodes that have changed the state for this data and would need pruning when such node is no longer part of the cluster.- Specified by:
- modifiedByNodesin interface- RemovedNodePruning
 
 - 
needPruningFrompublic boolean needPruningFrom(UniqueAddress removedNode) Description copied from interface:RemovedNodePruningDoes it have any state changes from a specific node, which has been removed from the cluster.- Specified by:
- needPruningFromin interface- RemovedNodePruning
 
 - 
prunepublic PNCounter prune(UniqueAddress removedNode, UniqueAddress collapseInto) Description copied from interface:RemovedNodePruningWhen theremovednode 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:
- prunein interface- RemovedNodePruning
 
 - 
pruningCleanuppublic PNCounter pruningCleanup(UniqueAddress removedNode) Description copied from interface:RemovedNodePruningRemove data entries from a node that has been removed from the cluster and already been pruned.- Specified by:
- pruningCleanupin interface- RemovedNodePruning
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
equalspublic boolean equals(java.lang.Object o) - Overrides:
- equalsin class- java.lang.Object
 
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- java.lang.Object
 
 
- 
 
-