public class PNCounterImpl extends Object implements CRDT<PNCounterImpl>, IdentifiedDataSerializable
Constructor and Description |
---|
PNCounterImpl() |
Modifier and Type | Method and Description |
---|---|
CRDTTimestampedLong |
addAndGet(long delta,
VectorClock observedTimestamps)
Adds the given value to the current value.
|
CRDTTimestampedLong |
get(VectorClock observedTimestamps)
Returns the current value of the counter.
|
CRDTTimestampedLong |
getAndAdd(long delta,
VectorClock observedTimestamps)
Adds the given value to the current value.
|
CRDTTimestampedLong |
getAndSubtract(long delta,
VectorClock observedTimestamps)
Subtracts the given value from the current value.
|
VectorClock |
getCurrentVectorClock()
Returns the current vector clock which reflects the current CRDT state.
|
int |
getFactoryId()
Returns DataSerializableFactory factory ID for this class.
|
int |
getId()
Returns type identifier for this class.
|
void |
markMigrated()
Unconditionally marks this CRDT as migrated.
|
boolean |
markMigrated(VectorClock vectorClock)
Marks this CRDT as migrated.
|
void |
merge(PNCounterImpl other)
Merges the state of a different replica into this CRDT.
|
void |
readData(ObjectDataInput in)
Reads fields from the input stream
|
CRDTTimestampedLong |
subtractAndGet(long delta,
VectorClock observedTimestamps)
Subtracts the given value from the current value.
|
void |
writeData(ObjectDataOutput out)
Writes object fields to output stream
|
public CRDTTimestampedLong get(VectorClock observedTimestamps)
The method can throw a ConsistencyLostException
when the state
of this CRDT is not causally related to the observed timestamps. This
means that it cannot provide the session guarantees of RYW (read your
writes) and monotonic read.
observedTimestamps
- the vector clock last observed by the client of
this counterConsistencyLostException
- if this replica cannot provide the
session guaranteespublic CRDTTimestampedLong getAndAdd(long delta, VectorClock observedTimestamps)
The method can throw a ConsistencyLostException
when the state
of this CRDT is not causally related to the observed timestamps. This
means that it cannot provide the session guarantees of RYW (read your
writes) and monotonic read.
delta
- the value to addobservedTimestamps
- the vector clock last observed by the client of
this counterConsistencyLostException
- if this replica cannot provide the
session guaranteespublic CRDTTimestampedLong addAndGet(long delta, VectorClock observedTimestamps)
The method can throw a ConsistencyLostException
when the state
of this CRDT is not causally related to the observed timestamps. This
means that it cannot provide the session guarantees of RYW (read your
writes) and monotonic read.
delta
- the value to addobservedTimestamps
- the vector clock last observed by the client of
this counterConsistencyLostException
- if this replica cannot provide the
session guaranteespublic CRDTTimestampedLong getAndSubtract(long delta, VectorClock observedTimestamps)
The method can throw a ConsistencyLostException
when the state
of this CRDT is not causally related to the observed timestamps. This
means that it cannot provide the session guarantees of RYW (read your
writes) and monotonic read.
delta
- the value to addobservedTimestamps
- the vector clock last observed by the client of
this counterConsistencyLostException
- if this replica cannot provide the
session guaranteespublic CRDTTimestampedLong subtractAndGet(long delta, VectorClock observedTimestamps)
The method can throw a ConsistencyLostException
when the state
of this CRDT is not causally related to the observed timestamps. This
means that it cannot provide the session guarantees of RYW (read your
writes) and monotonic read.
delta
- the value to subtractobservedTimestamps
- the vector clock last observed by the client of
this counterConsistencyLostException
- if this replica cannot provide the
session guaranteespublic void merge(PNCounterImpl other)
CRDT
merge
in interface CRDT<PNCounterImpl>
other
- the CRDT to merge into this CRDTpublic VectorClock getCurrentVectorClock()
CRDT
getCurrentVectorClock
in interface CRDT<PNCounterImpl>
public int getFactoryId()
IdentifiedDataSerializable
getFactoryId
in interface IdentifiedDataSerializable
public int getId()
IdentifiedDataSerializable
getId
in interface IdentifiedDataSerializable
public void writeData(ObjectDataOutput out) throws IOException
DataSerializable
writeData
in interface DataSerializable
out
- outputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
output stream has been closed.public void readData(ObjectDataInput in) throws IOException
DataSerializable
readData
in interface DataSerializable
in
- inputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
input stream has been closed.public boolean markMigrated(VectorClock vectorClock)
vectorClock
must be equal to the current vector clock.vectorClock
- a vector clock to compare the current clock totrue
if this CRDT has been marked as migrated,
false
otherwisepublic void markMigrated()
Copyright © 2020 Hazelcast, Inc.. All Rights Reserved.