DistributedAtomicInteger, DistributedAtomicLongpublic interface DistributedAtomicNumber<T>
| Modifier and Type | Method | 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 java.lang.Exception
0 is returned.java.lang.Exception - ZooKeeper errorsAtomicValue<T> compareAndSet(T expectedValue, T newValue) throws java.lang.Exception
== the expected value.
Remember to always check AtomicValue.succeeded().expectedValue - the expected valuenewValue - the new value for the counterjava.lang.Exception - ZooKeeper errorsAtomicValue<T> trySet(T newValue) throws java.lang.Exception
AtomicValue.succeeded().newValue - the value to setjava.lang.Exception - ZooKeeper errorsboolean initialize(T value) throws java.lang.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 setjava.lang.Exception - ZooKeeper errorsvoid forceSet(T newValue) throws java.lang.Exception
newValue - the new valuejava.lang.Exception - ZooKeeper errorsAtomicValue<T> increment() throws java.lang.Exception
AtomicValue.succeeded().java.lang.Exception - ZooKeeper errorsAtomicValue<T> decrement() throws java.lang.Exception
AtomicValue.succeeded().java.lang.Exception - ZooKeeper errorsAtomicValue<T> add(T delta) throws java.lang.Exception
AtomicValue.succeeded().delta - amount to addjava.lang.Exception - ZooKeeper errorsAtomicValue<T> subtract(T delta) throws java.lang.Exception
AtomicValue.succeeded().delta - amount to subtractjava.lang.Exception - ZooKeeper errorsCopyright © 2011–2018 The Apache Software Foundation. All rights reserved.