public class LongRegisterProxy extends AbstractDistributedObject<LongRegisterService> implements IAtomicLong
IAtomicLong
.PARTITIONING_STRATEGY
Constructor and Description |
---|
LongRegisterProxy(String name,
NodeEngine nodeEngine,
LongRegisterService service) |
Modifier and Type | Method and Description |
---|---|
long |
addAndGet(long delta)
Atomically adds the given value to the current value.
|
InvocationFuture<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.
|
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.
|
InvocationFuture<Void> |
setAsync(long newValue)
Atomically sets the given value.
|
String |
toString() |
destroy, equals, getDistributedObjectName, getNameAsPartitionAwareData, getNodeEngine, getOperationService, getPartitionId, getPartitionKey, getService, hashCode, invalidate, invokeOnPartition, isClusterVersionEqualTo, isClusterVersionGreaterOrEqual, isClusterVersionGreaterThan, isClusterVersionLessOrEqual, isClusterVersionLessThan, isClusterVersionUnknown, isClusterVersionUnknownOrGreaterOrEqual, isClusterVersionUnknownOrGreaterThan, isClusterVersionUnknownOrLessOrEqual, isClusterVersionUnknownOrLessThan, postDestroy, preDestroy, throwNotActiveException, toData
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
destroy, getPartitionKey
public LongRegisterProxy(String name, NodeEngine nodeEngine, LongRegisterService 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<LongRegisterService>
public long addAndGet(long delta)
IAtomicLong
addAndGet
in interface IAtomicLong
delta
- the value to add to the current valuepublic InvocationFuture<Long> addAndGetAsync(long delta)
IAtomicLong
This method will dispatch a request and return immediately a
CompletionStage
.
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:
CompletionStage<Long> stage = atomicLong.addAndGetAsync(13); // do something else, then read the result // this method will block until the result is available Long result = stage.toCompletableFuture().get();
CompletionStage<Long> stage = atomicLong.addAndGetAsync(13); stage.whenCompleteAsync((response, t) -> { if (t == null) { // do something with the result } else { // handle failure } });
addAndGetAsync
in interface IAtomicLong
delta
- the value to addCompletionStage
bearing the responsepublic boolean compareAndSet(long expect, long update)
IAtomicLong
==
the expected value.compareAndSet
in interface IAtomicLong
expect
- the expected valueupdate
- the new valuetrue
if successful; or false
if the actual value
was not equal to the expected value.public InternalCompletableFuture<Boolean> compareAndSetAsync(long expect, long update)
IAtomicLong
==
the expected value.
This method will dispatch a request and return immediately a
CompletionStage
.
compareAndSetAsync
in interface IAtomicLong
expect
- the expected valueupdate
- the new valueCompletionStage
with value true
if successful;
or false
if the actual value was not equal to the expected valuepublic void set(long newValue)
IAtomicLong
set
in interface IAtomicLong
newValue
- the new valuepublic InvocationFuture<Void> setAsync(long newValue)
IAtomicLong
This method will dispatch a request and return immediately a
CompletionStage
.
setAsync
in interface IAtomicLong
newValue
- the new valueCompletionStage
public long getAndSet(long newValue)
IAtomicLong
getAndSet
in interface IAtomicLong
newValue
- the new valuepublic InternalCompletableFuture<Long> getAndSetAsync(long newValue)
IAtomicLong
This method will dispatch a request and return immediately a
CompletionStage
.
getAndSetAsync
in interface IAtomicLong
newValue
- the new valueCompletionStage
with the old 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
This method will dispatch a request and return immediately a
CompletionStage
.
getAndAddAsync
in interface IAtomicLong
delta
- the value to addCompletionStage
with the old value before the additionpublic long decrementAndGet()
IAtomicLong
decrementAndGet
in interface IAtomicLong
public InternalCompletableFuture<Long> decrementAndGetAsync()
IAtomicLong
This method will dispatch a request and return immediately a
CompletionStage
.
decrementAndGetAsync
in interface IAtomicLong
CompletionStage
with the updated valuepublic long get()
IAtomicLong
get
in interface IAtomicLong
public InternalCompletableFuture<Long> getAsync()
IAtomicLong
CompletionStage
.getAsync
in interface IAtomicLong
CompletionStage
with the current valuepublic long incrementAndGet()
IAtomicLong
incrementAndGet
in interface IAtomicLong
public InternalCompletableFuture<Long> incrementAndGetAsync()
IAtomicLong
This method will dispatch a request and return immediately a
CompletionStage
.
incrementAndGetAsync
in interface IAtomicLong
CompletionStage
with the updated valuepublic long getAndIncrement()
IAtomicLong
getAndIncrement
in interface IAtomicLong
public InternalCompletableFuture<Long> getAndIncrementAsync()
IAtomicLong
This method will dispatch a request and return immediately a
CompletionStage
.
getAndIncrementAsync
in interface IAtomicLong
CompletionStage
with the old valuepublic 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
This method will dispatch a request and return immediately a
CompletionStage
.
alterAsync
in interface IAtomicLong
function
- the functionCompletionStage
with the new valuepublic 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
This method will dispatch a request and return immediately a
CompletionStage
.
alterAndGetAsync
in interface IAtomicLong
function
- the functionCompletionStage
with the new valuepublic 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
This method will dispatch a request and return immediately a
CompletionStage
.
getAndAlterAsync
in interface IAtomicLong
function
- the functionCompletionStage
with the old valuepublic <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
This method will dispatch a request and return immediately a
CompletionStage
. For example:
class IsOneFunction implements IFunction<Long, Boolean> { @Override public Boolean apply(Long input) { return input.equals(1L); } } CompletionStage<Boolean> stage = atomicLong.applyAsync(new IsOneFunction()); stage.whenCompleteAsync((response, t) -> { if (t == null) { // do something with the response } else { // handle failure } });
applyAsync
in interface IAtomicLong
function
- the functionCompletionStage
with the result of the function applicationpublic String toString()
toString
in class AbstractDistributedObject<LongRegisterService>
Copyright © 2019 Hazelcast, Inc.. All rights reserved.