public class AtomicLongProxy extends ClientProxy implements IAtomicLong
IAtomicLongname| Constructor and Description |
|---|
AtomicLongProxy(ClientContext context,
RaftGroupId groupId,
String proxyName,
String objectName) |
| 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.
|
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.
|
CPGroupId |
getGroupId() |
String |
getPartitionKey()
Returns the key of the partition that this DistributedObject is assigned to.
|
long |
incrementAndGet()
Atomically increments the current value by one.
|
InternalCompletableFuture<Long> |
incrementAndGetAsync()
Atomically increments the current value by one.
|
void |
onDestroy()
Called before proxy is destroyed.
|
void |
set(long newValue)
Atomically sets the given value.
|
InternalCompletableFuture<Void> |
setAsync(long newValue)
Atomically sets the given value.
|
deregisterListener, destroy, destroyLocally, destroyRemotely, equals, getClient, getContext, getDistributedObjectName, getId, getName, getSerializationService, getServiceName, hashCode, invoke, invoke, invokeOnAddress, invokeOnPartition, invokeOnPartitionInterruptibly, onInitialize, onShutdown, postDestroy, preDestroy, registerListener, toData, toObjectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitgetNamedestroy, getServiceNamepublic AtomicLongProxy(ClientContext context, RaftGroupId groupId, String proxyName, String objectName)
public long addAndGet(long delta)
IAtomicLongaddAndGet in interface IAtomicLongdelta - the value to add to the current valuepublic boolean compareAndSet(long expect,
long update)
IAtomicLong== the expected value.compareAndSet in interface IAtomicLongexpect - the expected valueupdate - the new valuetrue if successful; or false if the actual value
was not equal to the expected value.public long decrementAndGet()
IAtomicLongdecrementAndGet in interface IAtomicLongpublic long get()
IAtomicLongget in interface IAtomicLongpublic long getAndAdd(long delta)
IAtomicLonggetAndAdd in interface IAtomicLongdelta - the value to add to the current valuepublic long getAndSet(long newValue)
IAtomicLonggetAndSet in interface IAtomicLongnewValue - the new valuepublic long incrementAndGet()
IAtomicLongincrementAndGet in interface IAtomicLongpublic long getAndIncrement()
IAtomicLonggetAndIncrement in interface IAtomicLongpublic void set(long newValue)
IAtomicLongset in interface IAtomicLongnewValue - the new valuepublic void alter(IFunction<Long,Long> function)
IAtomicLongalter in interface IAtomicLongfunction - the function applied to the currently stored valuepublic long alterAndGet(IFunction<Long,Long> function)
IAtomicLongalterAndGet in interface IAtomicLongfunction - the function applied to the currently stored valuepublic long getAndAlter(IFunction<Long,Long> function)
IAtomicLonggetAndAlter in interface IAtomicLongfunction - the function applied to the currently stored valuepublic <R> R apply(IFunction<Long,R> function)
IAtomicLongapply in interface IAtomicLongfunction - the function applied to the value, the value is not changedpublic InternalCompletableFuture<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 IAtomicLongdelta - the value to addCompletionStage bearing the responsepublic 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 IAtomicLongexpect - the expected valueupdate - the new valueCompletionStage with value true if successful;
or false if the actual value was not equal to the expected valuepublic InternalCompletableFuture<Long> decrementAndGetAsync()
IAtomicLong
This method will dispatch a request and return immediately a
CompletionStage.
decrementAndGetAsync in interface IAtomicLongCompletionStage with the updated valuepublic InternalCompletableFuture<Long> getAsync()
IAtomicLongCompletionStage.getAsync in interface IAtomicLongCompletionStage with the current valuepublic InternalCompletableFuture<Long> getAndAddAsync(long delta)
IAtomicLong
This method will dispatch a request and return immediately a
CompletionStage.
getAndAddAsync in interface IAtomicLongdelta - the value to addCompletionStage with the old value before the additionpublic InternalCompletableFuture<Long> getAndSetAsync(long newValue)
IAtomicLong
This method will dispatch a request and return immediately a
CompletionStage.
getAndSetAsync in interface IAtomicLongnewValue - the new valueCompletionStage with the old valuepublic InternalCompletableFuture<Long> incrementAndGetAsync()
IAtomicLong
This method will dispatch a request and return immediately a
CompletionStage.
incrementAndGetAsync in interface IAtomicLongCompletionStage with the updated valuepublic InternalCompletableFuture<Long> getAndIncrementAsync()
IAtomicLong
This method will dispatch a request and return immediately a
CompletionStage.
getAndIncrementAsync in interface IAtomicLongCompletionStage with the old valuepublic InternalCompletableFuture<Void> setAsync(long newValue)
IAtomicLong
This method will dispatch a request and return immediately a
CompletionStage.
setAsync in interface IAtomicLongnewValue - the new valueCompletionStagepublic InternalCompletableFuture<Void> alterAsync(IFunction<Long,Long> function)
IAtomicLong
This method will dispatch a request and return immediately a
CompletionStage.
alterAsync in interface IAtomicLongfunction - the functionCompletionStage with the new valuepublic InternalCompletableFuture<Long> alterAndGetAsync(IFunction<Long,Long> function)
IAtomicLong
This method will dispatch a request and return immediately a
CompletionStage.
alterAndGetAsync in interface IAtomicLongfunction - the functionCompletionStage with the new valuepublic InternalCompletableFuture<Long> getAndAlterAsync(IFunction<Long,Long> function)
IAtomicLong
This method will dispatch a request and return immediately a
CompletionStage.
getAndAlterAsync in interface IAtomicLongfunction - the functionCompletionStage with the old valuepublic <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 IAtomicLongfunction - the functionCompletionStage with the result of the function applicationpublic String getPartitionKey()
DistributedObjectIAtomicLong. For a partitioned data structure like an IMap,
the returned value will not be null, but otherwise undefined.getPartitionKey in interface DistributedObjectgetPartitionKey in class ClientProxypublic void onDestroy()
ClientProxyonDestroy in class ClientProxypublic CPGroupId getGroupId()
Copyright © 2019 Hazelcast, Inc.. All rights reserved.