public class StatePNCounter extends StateBasedCRDT
| Modifier and Type | Field and Description |
|---|---|
protected ConcurrentMap<ReplicaID,ValueTsPair<IntegerType>> |
decs |
protected ConcurrentMap<ReplicaID,ValueTsPair<IntegerType>> |
incs |
static pt.unl.fct.di.novasys.network.ISerializer<StatePNCounter> |
serializer
A serializer that serializes the CRDT into (and from) a ByteBuf.
|
static CRDTsTypes |
TYPE |
state| Constructor and Description |
|---|
StatePNCounter(ReplicaID replicaID)
Creates a state-based counter by passing the replica identifier.
|
StatePNCounter(ReplicaID replicaID,
int initialValue)
Creates a delta-based counter by passing the replica identifier.
|
StatePNCounter(VVState state)
Creates a state-based counter by passing the current replica state.
|
StatePNCounter(VVState state,
int initialValue)
Creates a delta-based counter by passing the current replica state.
|
| Modifier and Type | Method and Description |
|---|---|
GenericCRDT |
copy()
Creates a copy of the CRDT.
|
void |
decrement(int amount)
Decrements the value of the counter.
|
void |
increment(int amount)
Increments the value of the counter.
|
StateBasedCRDT |
merge(StateBasedCRDT crdt)
Handles the merging of this CRDT with other state-based CRDT received from the network.
|
void |
serialize(io.netty.buffer.ByteBuf in)
Serializes the CRDT into a ByteBuf
|
int |
value()
Gets the value of the counter
|
getReplicaID, getReplicaStateclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdeserializeDataType, getTypepublic static final CRDTsTypes TYPE
protected ConcurrentMap<ReplicaID,ValueTsPair<IntegerType>> incs
protected ConcurrentMap<ReplicaID,ValueTsPair<IntegerType>> decs
public static pt.unl.fct.di.novasys.network.ISerializer<StatePNCounter> serializer
public StatePNCounter(ReplicaID replicaID)
replicaID - replica identifierpublic StatePNCounter(VVState state)
state - replica statepublic StatePNCounter(ReplicaID replicaID, int initialValue)
replicaID - replica identifierinitialValue - the initial value of the counterpublic StatePNCounter(VVState state, int initialValue)
state - replica stateinitialValue - the initial value of the counterpublic GenericCRDT copy()
GenericCRDTpublic int value()
public void increment(int amount)
amount - amount to be incrementedpublic void decrement(int amount)
amount - amount to be incrementedpublic StateBasedCRDT merge(StateBasedCRDT crdt)
StateCRDTmerge in interface StateCRDTmerge in class StateBasedCRDTcrdt - the CRDT to mergepublic void serialize(io.netty.buffer.ByteBuf in)
throws IOException
GenericCRDTin - ByteBuf to serialize the CRDT toIOException - if an error occurs while serializingCopyright © 2024. All rights reserved.