public final class PNCounter extends java.lang.Object implements ReplicatedData, ReplicatedDataSerialization, RemovedNodePruning
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.
Constructor and Description |
---|
PNCounter(GCounter increments,
GCounter decrements) |
Modifier and Type | Method and Description |
---|---|
static PNCounter |
apply() |
PNCounter |
change(UniqueAddress key,
long delta) |
static PNCounter |
create()
Java API
|
PNCounter |
decrement(Cluster node,
long delta)
Decrement the counter with the delta specified.
|
PNCounter |
decrement(UniqueAddress key) |
PNCounter |
decrement(UniqueAddress key,
long delta)
Decrement the counter with the delta specified.
|
GCounter |
decrements() |
static PNCounter |
empty() |
boolean |
equals(java.lang.Object o) |
java.math.BigInteger |
getValue()
Java API: Current total value of the counter.
|
int |
hashCode() |
PNCounter |
increment(Cluster node,
long delta)
Increment the counter with the delta specified.
|
PNCounter |
increment(UniqueAddress key) |
PNCounter |
increment(UniqueAddress key,
long delta) |
GCounter |
increments() |
PNCounter |
merge(PNCounter that) |
boolean |
needPruningFrom(UniqueAddress removedNode)
Does it have any state changes from a specific node,
which has been removed from the cluster.
|
PNCounter |
prune(UniqueAddress removedNode,
UniqueAddress collapseInto)
When the
removed node has been removed from the cluster the state
changes from that node will be pruned by collapsing the data entries
to another node. |
PNCounter |
pruningCleanup(UniqueAddress removedNode)
Remove data entries from a node that has been removed from the cluster
and already been pruned.
|
java.lang.String |
toString() |
static scala.Option<scala.math.BigInt> |
unapply(PNCounter c)
Extract the
GCounter.value() . |
scala.math.BigInt |
value()
Scala API: Current total value of the counter.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
merge
public static PNCounter empty()
public static PNCounter apply()
public static PNCounter create()
public static scala.Option<scala.math.BigInt> unapply(PNCounter c)
GCounter.value()
.c
- (undocumented)public GCounter increments()
public GCounter decrements()
public scala.math.BigInt value()
public java.math.BigInteger getValue()
public PNCounter increment(Cluster node, long delta)
node
- (undocumented)delta
- (undocumented)public PNCounter decrement(Cluster node, long delta)
node
- (undocumented)delta
- (undocumented)public PNCounter increment(UniqueAddress key, long delta)
public PNCounter increment(UniqueAddress key)
public PNCounter decrement(UniqueAddress key, long delta)
key
- (undocumented)delta
- (undocumented)public PNCounter decrement(UniqueAddress key)
public PNCounter change(UniqueAddress key, long delta)
public boolean needPruningFrom(UniqueAddress removedNode)
RemovedNodePruning
needPruningFrom
in interface RemovedNodePruning
removedNode
- (undocumented)public PNCounter prune(UniqueAddress removedNode, UniqueAddress collapseInto)
RemovedNodePruning
removed
node has been removed from the cluster the state
changes from that node will be pruned by collapsing the data entries
to another node.prune
in interface RemovedNodePruning
removedNode
- (undocumented)collapseInto
- (undocumented)public PNCounter pruningCleanup(UniqueAddress removedNode)
RemovedNodePruning
pruningCleanup
in interface RemovedNodePruning
removedNode
- (undocumented)public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object