public interface DistributedAtomicNumber<T>
| Modifier and Type | Method and Description |
|---|---|
AtomicValue<T> |
add(T delta)
Add delta to the current value and return the new value information.
|
AtomicValue<T> |
compareAndSet(T expectedValue,
T newValue)
Atomically sets the value to the given updated value
if the current value
== the expected value. |
AtomicValue<T> |
decrement()
Subtract 1 from the current value and return the new value information.
|
void |
forceSet(T newValue)
Forcibly sets the value of the counter without any guarantees of atomicity.
|
AtomicValue<T> |
get()
Returns the current value of the counter.
|
AtomicValue<T> |
increment()
Add 1 to the current value and return the new value information.
|
boolean |
initialize(T value)
Atomic values are initially set to the equivalent of
NULL in a database. |
AtomicValue<T> |
subtract(T delta)
Subtract delta from the current value and return the new value information.
|
AtomicValue<T> |
trySet(T newValue)
Attempt to atomically set the value to the given value.
|
AtomicValue<T> get() throws Exception
0 is returned.Exception - ZooKeeper errorsAtomicValue<T> compareAndSet(T expectedValue, T newValue) throws Exception
== the expected value.
Remember to always check AtomicValue.succeeded().expectedValue - the expected valuenewValue - the new value for the counterException - ZooKeeper errorsAtomicValue<T> trySet(T newValue) throws Exception
AtomicValue.succeeded().newValue - the value to setException - ZooKeeper errorsboolean initialize(T value) throws Exception
NULL in a database.
Use this method to initialize the value. The value will be set if and only iff the node does not exist.value - the initial value to setException - ZooKeeper errorsvoid forceSet(T newValue) throws Exception
newValue - the new valueException - ZooKeeper errorsAtomicValue<T> increment() throws Exception
AtomicValue.succeeded().Exception - ZooKeeper errorsAtomicValue<T> decrement() throws Exception
AtomicValue.succeeded().Exception - ZooKeeper errorsAtomicValue<T> add(T delta) throws Exception
AtomicValue.succeeded().delta - amount to addException - ZooKeeper errorsAtomicValue<T> subtract(T delta) throws Exception
AtomicValue.succeeded().delta - amount to subtractException - ZooKeeper errorsCopyright © 2011–2018 The Apache Software Foundation. All rights reserved.