public class AtomicLongProxy extends AbstractDistributedObject<AtomicLongService> implements AsyncAtomicLong
PARTITIONING_STRATEGY
Constructor and Description |
---|
AtomicLongProxy(String name,
NodeEngine nodeEngine,
AtomicLongService service) |
Modifier and Type | Method and Description |
---|---|
long |
addAndGet(long delta)
Atomically adds the given value to the current value.
|
InternalCompletableFuture<Long> |
addAndGetAsync(long delta)
Atomically adds the given value to the current value.
|
void |
alter(IFunction<Long,Long> function)
Alters the currently stored value by applying a function on it.
|
long |
alterAndGet(IFunction<Long,Long> function)
Alters the currently stored value by applying a function on it and gets the result.
|
InternalCompletableFuture<Long> |
alterAndGetAsync(IFunction<Long,Long> function)
Alters the currently stored value by applying a function on it and gets the result.
|
InternalCompletableFuture<Void> |
alterAsync(IFunction<Long,Long> function)
Alters the currently stored value by applying a function on it.
|
<R> R |
apply(IFunction<Long,R> function)
Applies a function on the value, the actual stored value will not change.
|
<R> InternalCompletableFuture<R> |
applyAsync(IFunction<Long,R> function)
Applies a function on the value, the actual stored value will not change.
|
InternalCompletableFuture<Long> |
asyncAddAndGet(long delta)
Atomically adds the given value to the current value.
|
InternalCompletableFuture<Void> |
asyncAlter(IFunction<Long,Long> function)
Alters the currently stored value by applying a function on it.
|
InternalCompletableFuture<Long> |
asyncAlterAndGet(IFunction<Long,Long> function)
Alters the currently stored value by applying a function on it and gets the result.
|
<R> InternalCompletableFuture<R> |
asyncApply(IFunction<Long,R> function)
Applies a function on the value, the actual stored value will not change.
|
InternalCompletableFuture<Boolean> |
asyncCompareAndSet(long expect,
long update)
Atomically sets the value to the given updated value
only if the current value
== the expected value. |
InternalCompletableFuture<Long> |
asyncDecrementAndGet()
Atomically decrements the current value by one.
|
InternalCompletableFuture<Long> |
asyncGet()
Gets the current value.
|
InternalCompletableFuture<Long> |
asyncGetAndAdd(long delta)
Atomically adds the given value to the current value.
|
InternalCompletableFuture<Long> |
asyncGetAndAlter(IFunction<Long,Long> function)
Alters the currently stored value by applying a function on it on and gets the old value.
|
InternalCompletableFuture<Long> |
asyncGetAndIncrement()
Atomically increments the current value by one.
|
InternalCompletableFuture<Long> |
asyncGetAndSet(long newValue)
Atomically sets the given value and returns the old value.
|
InternalCompletableFuture<Long> |
asyncIncrementAndGet()
Atomically increments the current value by one.
|
InternalCompletableFuture<Void> |
asyncSet(long newValue)
Atomically sets the given value.
|
boolean |
compareAndSet(long expect,
long update)
Atomically sets the value to the given updated value
only if the current value
== the expected value. |
InternalCompletableFuture<Boolean> |
compareAndSetAsync(long expect,
long update)
Atomically sets the value to the given updated value
only if the current value
== the expected value. |
long |
decrementAndGet()
Atomically decrements the current value by one.
|
InternalCompletableFuture<Long> |
decrementAndGetAsync()
Atomically decrements the current value by one.
|
long |
get()
Gets the current value.
|
long |
getAndAdd(long delta)
Atomically adds the given value to the current value.
|
InternalCompletableFuture<Long> |
getAndAddAsync(long delta)
Atomically adds the given value to the current value.
|
long |
getAndAlter(IFunction<Long,Long> function)
Alters the currently stored value by applying a function on it on and gets the old value.
|
InternalCompletableFuture<Long> |
getAndAlterAsync(IFunction<Long,Long> function)
Alters the currently stored value by applying a function on it on and gets the old value.
|
long |
getAndIncrement()
Atomically increments the current value by one.
|
InternalCompletableFuture<Long> |
getAndIncrementAsync()
Atomically increments the current value by one.
|
long |
getAndSet(long newValue)
Atomically sets the given value and returns the old value.
|
InternalCompletableFuture<Long> |
getAndSetAsync(long newValue)
Atomically sets the given value and returns the old value.
|
InternalCompletableFuture<Long> |
getAsync()
Gets the current value.
|
String |
getName()
Returns the name of this IAtomicLong instance.
|
int |
getPartitionId() |
String |
getServiceName()
Returns the service name for this object.
|
long |
incrementAndGet()
Atomically increments the current value by one.
|
InternalCompletableFuture<Long> |
incrementAndGetAsync()
Atomically increments the current value by one.
|
void |
set(long newValue)
Atomically sets the given value.
|
InternalCompletableFuture<Void> |
setAsync(long newValue)
Atomically sets the given value.
|
String |
toString() |
destroy, equals, getDistributedObjectName, getNameAsPartitionAwareData, getNodeEngine, getOperationService, getPartitionId, getPartitionKey, getService, hashCode, invalidate, invokeOnPartition, postDestroy, preDestroy, throwNotActiveException, toData
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
destroy, getPartitionKey
public AtomicLongProxy(String name, NodeEngine nodeEngine, AtomicLongService service)
public String getName()
IAtomicLong
getName
in interface DistributedObject
getName
in interface IAtomicLong
public int getPartitionId()
public String getServiceName()
DistributedObject
getServiceName
in interface DistributedObject
getServiceName
in class AbstractDistributedObject<AtomicLongService>
public long addAndGet(long delta)
IAtomicLong
addAndGet
in interface IAtomicLong
delta
- the value to add to the current valuepublic InternalCompletableFuture<Long> addAndGetAsync(long delta)
IAtomicLong
ICompletableFuture
.
The operations result can be obtained in a blocking way, or a
callback can be provided for execution upon completion, as demonstrated in the following examples:
ICompletableFuture<Long> future = atomicLong.addAndGetAsync(13); // do something else, then read the result Long result = future.get(); // this method will block until the result is available
ICompletableFuture<Long> future = atomicLong.addAndGetAsync(13); future.andThen(new ExecutionCallback<Long>() { void onResponse(Long response) { // do something with the result } void onFailure(Throwable t) { // handle failure } });
addAndGetAsync
in interface IAtomicLong
delta
- the value to addICompletableFuture
bearing the responsepublic InternalCompletableFuture<Long> asyncAddAndGet(long delta)
AsyncAtomicLong
asyncAddAndGet
in interface AsyncAtomicLong
delta
- the value to addpublic boolean compareAndSet(long expect, long update)
IAtomicLong
==
the expected value.compareAndSet
in interface IAtomicLong
expect
- the expected valueupdate
- the new valuepublic InternalCompletableFuture<Boolean> compareAndSetAsync(long expect, long update)
IAtomicLong
==
the expected value.
This method will dispatch a request and return immediately an ICompletableFuture
.compareAndSetAsync
in interface IAtomicLong
expect
- the expected valueupdate
- the new valueICompletableFuture
with value true if successful; or false if the actual value
was not equal to the expected value.public InternalCompletableFuture<Boolean> asyncCompareAndSet(long expect, long update)
AsyncAtomicLong
==
the expected value.asyncCompareAndSet
in interface AsyncAtomicLong
expect
- the expected valueupdate
- the new valuepublic void set(long newValue)
IAtomicLong
set
in interface IAtomicLong
newValue
- the new valuepublic InternalCompletableFuture<Void> setAsync(long newValue)
IAtomicLong
ICompletableFuture
.setAsync
in interface IAtomicLong
newValue
- the new valueICompletableFuture
API consumers can use to track execution of this requestpublic InternalCompletableFuture<Void> asyncSet(long newValue)
AsyncAtomicLong
asyncSet
in interface AsyncAtomicLong
newValue
- the new valuepublic long getAndSet(long newValue)
IAtomicLong
getAndSet
in interface IAtomicLong
newValue
- the new valuepublic InternalCompletableFuture<Long> getAndSetAsync(long newValue)
IAtomicLong
ICompletableFuture
.getAndSetAsync
in interface IAtomicLong
newValue
- the new valueICompletableFuture
with the old valuepublic InternalCompletableFuture<Long> asyncGetAndSet(long newValue)
AsyncAtomicLong
asyncGetAndSet
in interface AsyncAtomicLong
newValue
- the new valuepublic long getAndAdd(long delta)
IAtomicLong
getAndAdd
in interface IAtomicLong
delta
- the value to add to the current valuepublic InternalCompletableFuture<Long> getAndAddAsync(long delta)
IAtomicLong
ICompletableFuture
.getAndAddAsync
in interface IAtomicLong
delta
- the value to addICompletableFuture
with the old value before the additionpublic InternalCompletableFuture<Long> asyncGetAndAdd(long delta)
AsyncAtomicLong
asyncGetAndAdd
in interface AsyncAtomicLong
delta
- the value to addpublic long decrementAndGet()
IAtomicLong
decrementAndGet
in interface IAtomicLong
public InternalCompletableFuture<Long> decrementAndGetAsync()
IAtomicLong
ICompletableFuture
.decrementAndGetAsync
in interface IAtomicLong
ICompletableFuture
with the updated value.public InternalCompletableFuture<Long> asyncDecrementAndGet()
AsyncAtomicLong
asyncDecrementAndGet
in interface AsyncAtomicLong
public long get()
IAtomicLong
get
in interface IAtomicLong
public InternalCompletableFuture<Long> getAsync()
IAtomicLong
ICompletableFuture
.getAsync
in interface IAtomicLong
ICompletableFuture
with the current valuepublic InternalCompletableFuture<Long> asyncGet()
AsyncAtomicLong
asyncGet
in interface AsyncAtomicLong
public long incrementAndGet()
IAtomicLong
incrementAndGet
in interface IAtomicLong
public InternalCompletableFuture<Long> incrementAndGetAsync()
IAtomicLong
ICompletableFuture
.incrementAndGetAsync
in interface IAtomicLong
ICompletableFuture
with the updated valuepublic InternalCompletableFuture<Long> asyncIncrementAndGet()
AsyncAtomicLong
asyncIncrementAndGet
in interface AsyncAtomicLong
public long getAndIncrement()
IAtomicLong
getAndIncrement
in interface IAtomicLong
public InternalCompletableFuture<Long> getAndIncrementAsync()
IAtomicLong
ICompletableFuture
.getAndIncrementAsync
in interface IAtomicLong
ICompletableFuture
with the old valuepublic InternalCompletableFuture<Long> asyncGetAndIncrement()
AsyncAtomicLong
asyncGetAndIncrement
in interface AsyncAtomicLong
public void alter(IFunction<Long,Long> function)
IAtomicLong
alter
in interface IAtomicLong
function
- the function applied to the currently stored valuepublic InternalCompletableFuture<Void> alterAsync(IFunction<Long,Long> function)
IAtomicLong
ICompletableFuture
.alterAsync
in interface IAtomicLong
function
- the functionICompletableFuture
API consumers can use to track execution of this requestpublic InternalCompletableFuture<Void> asyncAlter(IFunction<Long,Long> function)
AsyncAtomicLong
asyncAlter
in interface AsyncAtomicLong
function
- the functionpublic long alterAndGet(IFunction<Long,Long> function)
IAtomicLong
alterAndGet
in interface IAtomicLong
function
- the function applied to the currently stored valuepublic InternalCompletableFuture<Long> alterAndGetAsync(IFunction<Long,Long> function)
IAtomicLong
ICompletableFuture
.alterAndGetAsync
in interface IAtomicLong
function
- the functionICompletableFuture
with the new value.public InternalCompletableFuture<Long> asyncAlterAndGet(IFunction<Long,Long> function)
AsyncAtomicLong
asyncAlterAndGet
in interface AsyncAtomicLong
function
- the functionpublic long getAndAlter(IFunction<Long,Long> function)
IAtomicLong
getAndAlter
in interface IAtomicLong
function
- the function applied to the currently stored valuepublic InternalCompletableFuture<Long> getAndAlterAsync(IFunction<Long,Long> function)
IAtomicLong
ICompletableFuture
.getAndAlterAsync
in interface IAtomicLong
function
- the functionICompletableFuture
with the old valuepublic InternalCompletableFuture<Long> asyncGetAndAlter(IFunction<Long,Long> function)
AsyncAtomicLong
asyncGetAndAlter
in interface AsyncAtomicLong
function
- the functionpublic <R> R apply(IFunction<Long,R> function)
IAtomicLong
apply
in interface IAtomicLong
function
- the function applied to the value, the value is not changedpublic <R> InternalCompletableFuture<R> applyAsync(IFunction<Long,R> function)
IAtomicLong
ICompletableFuture
.
Example:
class IsOneFunction implements IFunction<Long, Boolean> { @Override public Boolean apply(Long input) { return input.equals(1L); } } ICompletableFuturefuture = atomicLong.applyAsync(new IsOneFunction()); future.andThen(new ExecutionCallback<Boolean>() { void onResponse(Boolean response) { // do something with the response } void onFailure(Throwable t) { // handle failure } });
applyAsync
in interface IAtomicLong
function
- the functionICompletableFuture
with the result of the function applicationpublic <R> InternalCompletableFuture<R> asyncApply(IFunction<Long,R> function)
AsyncAtomicLong
asyncApply
in interface AsyncAtomicLong
function
- the functionpublic String toString()
toString
in class AbstractDistributedObject<AtomicLongService>
Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.