public class OpCounter extends OperationBasedCRDT
| Modifier and Type | Field and Description |
|---|---|
static pt.unl.fct.di.novasys.network.ISerializer<OpCounter> |
serializer
A serializer that serializes the CRDT into (and from) a ByteBuf.
|
static CRDTsTypes |
TYPE |
crtdID| Constructor and Description |
|---|
OpCounter()
Creates a operation-based counter.
|
OpCounter(int value)
Creates a operation-based counter.
|
OpCounter(String crdtID)
Creates a operation-based counter by passing the CRDT identifier.
|
OpCounter(String crdtID,
int value)
Creates a operation-based counter by passing the CRDT identifier and a
initialization value.
|
| Modifier and Type | Method and Description |
|---|---|
void |
applyRemoteOperation(Operation op)
Applies a remote operation into the local state of the CRDT
|
GenericCRDT |
copy()
Creates a copy of the CRDT.
|
CounterOperation |
decrement(int amount)
Decrements the value of the counter, and returns an operation to be
propagated to other replicas.
|
CounterOperation |
increment(int amount)
Increments the value of the counter, and returns an operation to be
propagated to other replicas.
|
void |
installRemoteState(OperationBasedCRDT crdt)
Installs the remote state into the local the CRDT.
|
void |
serialize(io.netty.buffer.ByteBuf in)
Serializes the CRDT into a ByteBuf
|
int |
value()
Gets the value of the counter
|
getCrtdIDclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdeserializeDataType, getTypepublic static final CRDTsTypes TYPE
public static pt.unl.fct.di.novasys.network.ISerializer<OpCounter> serializer
public OpCounter()
public OpCounter(int value)
value - the initial value of the counterpublic OpCounter(String crdtID)
crdtID - the CRDT identifier.public OpCounter(String crdtID, int value)
crdtID - the CRDT indentifiervalue - the initial value of the counterpublic GenericCRDT copy()
GenericCRDTpublic int value()
public CounterOperation increment(int amount)
amount - amount to be incrementedpublic CounterOperation decrement(int amount)
amount - amount to be decrementedpublic void applyRemoteOperation(Operation op)
OperationCRDTapplyRemoteOperation in interface OperationCRDTapplyRemoteOperation in class OperationBasedCRDTop - operation to be appliedpublic void installRemoteState(OperationBasedCRDT crdt)
OperationCRDTinstallRemoteState in interface OperationCRDTinstallRemoteState in class OperationBasedCRDTcrdt - the CRDT to be installedpublic 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.