E - the type of object referred to by this referencepublic interface IAtomicReference<E> extends DistributedObject
AtomicReference.
Asynchronous variants have been introduced in version 3.7.
Async methods return immediately an ICompletableFuture from which
the operation's result can be obtained either in a blocking manner or by
registering a callback to be executed upon completion. For example:
ICompletableFuture future = atomicRef.getAsync();
future.andThen(new ExecutionCallback() {
void onResponse(Long response) {
// do something with the result
}
void onFailure(Throwable t) {
// handle failure
}
});
During a network partition event it is possible for the
IAtomicReference to exist in each of the partitioned clusters or to
not exist at all. Under these circumstances the values held in the
IAtomicReference may diverge. Once the network partition heals,
Hazelcast will use the configured split-brain merge policy to resolve
conflicting values.
Supports Quorum QuorumConfig since 3.10 in
cluster versions 3.10 and higher.
IAtomicLong| Modifier and Type | Method and Description |
|---|---|
void |
alter(IFunction<E,E> function)
Alters the currently stored reference by applying a function on it.
|
E |
alterAndGet(IFunction<E,E> function)
Alters the currently stored reference by applying a function on it and
gets the result.
|
ICompletableFuture<E> |
alterAndGetAsync(IFunction<E,E> function)
Alters the currently stored reference by applying a function on it and
gets the result.
|
ICompletableFuture<Void> |
alterAsync(IFunction<E,E> function)
Alters the currently stored reference by applying a function on it.
|
<R> R |
apply(IFunction<E,R> function)
Applies a function on the value, the actual stored value will not
change.
|
<R> ICompletableFuture<R> |
applyAsync(IFunction<E,R> function)
Applies a function on the value, the actual stored value will not
change.
|
void |
clear()
Clears the current stored reference.
|
ICompletableFuture<Void> |
clearAsync()
Clears the current stored reference.
|
boolean |
compareAndSet(E expect,
E update)
Atomically sets the value to the given updated value
only if the current value
== the expected value. |
ICompletableFuture<Boolean> |
compareAndSetAsync(E expect,
E update)
Atomically sets the value to the given updated value only if the
current value
== the expected value. |
boolean |
contains(E value)
Checks if the reference contains the value.
|
ICompletableFuture<Boolean> |
containsAsync(E expected)
Checks if the reference contains the value.
|
E |
get()
Gets the current value.
|
E |
getAndAlter(IFunction<E,E> function)
Alters the currently stored reference by applying a function on it on
and gets the old value.
|
ICompletableFuture<E> |
getAndAlterAsync(IFunction<E,E> function)
Alters the currently stored reference by applying a function on it on
and gets the old value.
|
E |
getAndSet(E newValue)
Gets the old value and sets the new value.
|
ICompletableFuture<E> |
getAndSetAsync(E newValue)
Gets the value and sets the new value.
|
ICompletableFuture<E> |
getAsync()
Gets the current value.
|
boolean |
isNull()
Checks if the stored reference is
null. |
ICompletableFuture<Boolean> |
isNullAsync()
Checks if the stored reference is
null. |
void |
set(E newValue)
Atomically sets the given value.
|
E |
setAndGet(E update)
Deprecated.
will be removed from Hazelcast 3.4 since it doesn't really serve a purpose
|
ICompletableFuture<Void> |
setAsync(E newValue)
Atomically sets the given value.
|
destroy, getName, getPartitionKey, getServiceNameboolean compareAndSet(E expect, E update)
== the expected value.expect - the expected valueupdate - the new valuetrue if successful; or false if the actual value
was not equal to the expected valueE get()
void set(E newValue)
newValue - the new valueE getAndSet(E newValue)
newValue - the new valueE setAndGet(E update)
update - the new valueboolean isNull()
null.true if null, false otherwisevoid clear()
boolean contains(E value)
value - the value to check (is allowed to be null)true if the value is found, false otherwisevoid alter(IFunction<E,E> function)
function - the function that alters the currently stored referenceIllegalArgumentException - if function is nullE alterAndGet(IFunction<E,E> function)
function - the function that alters the currently stored referenceIllegalArgumentException - if function is nullE getAndAlter(IFunction<E,E> function)
function - the function that alters the currently stored referenceIllegalArgumentException - if function is null<R> R apply(IFunction<E,R> function)
function - the function applied on the value, the stored value does not changeIllegalArgumentException - if function is nullICompletableFuture<Boolean> compareAndSetAsync(E expect, E update)
== the expected value.expect - the expected valueupdate - the new valuetrue if successful; or false if the actual value
was not equal to the expected valueICompletableFuture<E> getAsync()
ICompletableFuture<Void> setAsync(E newValue)
newValue - the new valueICompletableFuture<E> getAndSetAsync(E newValue)
newValue - the new valueICompletableFuture<Boolean> isNullAsync()
null.true if null, false otherwiseICompletableFuture<Void> clearAsync()
ICompletableFuture<Boolean> containsAsync(E expected)
expected - the value to check (is allowed to be null)true if the value is found, false otherwiseICompletableFuture<Void> alterAsync(IFunction<E,E> function)
function - the functionIllegalArgumentException - if function is nullICompletableFuture<E> alterAndGetAsync(IFunction<E,E> function)
function - the functionIllegalArgumentException - if function is nullICompletableFuture<E> getAndAlterAsync(IFunction<E,E> function)
function - the functionIllegalArgumentException - if function is null<R> ICompletableFuture<R> applyAsync(IFunction<E,R> function)
function - the functionIllegalArgumentException - if function is nullCopyright © 2019 Hazelcast, Inc.. All Rights Reserved.