public class ClientAtomicLongProxy extends ClientProxy implements IAtomicLong
IAtomicLong
.name
Constructor and Description |
---|
ClientAtomicLongProxy(String serviceName,
String objectId,
ClientContext context) |
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.
|
long |
incrementAndGet()
Atomically increments the current value by one.
|
InternalCompletableFuture<Long> |
incrementAndGetAsync()
Atomically increments the current value by one.
|
protected ClientMessage |
invokeOnPartition(ClientMessage req) |
protected <T> T |
invokeOnPartition(ClientMessage clientMessage,
long invocationTimeoutSeconds) |
protected <T> ClientDelegatingFuture<T> |
invokeOnPartitionAsync(ClientMessage clientMessage,
ClientMessageDecoder clientMessageDecoder) |
protected <T> T |
invokeOnPartitionInterruptibly(ClientMessage clientMessage) |
protected <T> T |
invokeOnPartitionInterruptibly(ClientMessage clientMessage,
long invocationTimeoutSeconds) |
protected void |
onInitialize()
Called when proxy is created.
|
void |
set(long newValue)
Atomically sets the given value.
|
InternalCompletableFuture<Void> |
setAsync(long newValue)
Atomically sets the given value.
|
String |
toString() |
deregisterListener, destroy, destroyLocally, destroyRemotely, equals, getClient, getConnectedServerVersion, getContext, getDistributedObjectName, getId, getName, getPartitionKey, getSerializationService, getServiceName, hashCode, invoke, invoke, invokeOnAddress, invokeOnPartition, invokeOnPartitionInterruptibly, onDestroy, onShutdown, postDestroy, preDestroy, registerListener, setContext, toData, toObject
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getName
destroy, getPartitionKey, getServiceName
public ClientAtomicLongProxy(String serviceName, String objectId, ClientContext context)
public <R> R apply(IFunction<Long,R> function)
IAtomicLong
apply
in interface IAtomicLong
function
- the function applied to the value, the value is not changedpublic void alter(IFunction<Long,Long> function)
IAtomicLong
alter
in interface IAtomicLong
function
- the function applied to the currently stored valuepublic long alterAndGet(IFunction<Long,Long> function)
IAtomicLong
alterAndGet
in interface IAtomicLong
function
- the function applied to the currently stored valuepublic long getAndAlter(IFunction<Long,Long> function)
IAtomicLong
getAndAlter
in interface IAtomicLong
function
- the function applied to the currently stored valuepublic long addAndGet(long delta)
IAtomicLong
addAndGet
in interface IAtomicLong
delta
- the value to add to the current valuepublic 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 long decrementAndGet()
IAtomicLong
decrementAndGet
in interface IAtomicLong
public long get()
IAtomicLong
get
in interface IAtomicLong
public long getAndAdd(long delta)
IAtomicLong
getAndAdd
in interface IAtomicLong
delta
- the value to add to the current valuepublic long getAndSet(long newValue)
IAtomicLong
getAndSet
in interface IAtomicLong
newValue
- the new valuepublic long incrementAndGet()
IAtomicLong
incrementAndGet
in interface IAtomicLong
public long getAndIncrement()
IAtomicLong
getAndIncrement
in interface IAtomicLong
public void set(long newValue)
IAtomicLong
set
in interface IAtomicLong
newValue
- the new valuepublic InternalCompletableFuture<Long> addAndGetAsync(long delta)
IAtomicLong
This method will dispatch a request and return immediately an
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 future = atomicLong.addAndGetAsync(13);
// do something else, then read the result
// this method will block until the result is available
Long result = future.get();
ICompletableFuture 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<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 valuepublic InternalCompletableFuture<Long> decrementAndGetAsync()
IAtomicLong
This method will dispatch a request and return immediately an
ICompletableFuture
.
decrementAndGetAsync
in interface IAtomicLong
ICompletableFuture
with the updated valuepublic InternalCompletableFuture<Long> getAsync()
IAtomicLong
ICompletableFuture
.getAsync
in interface IAtomicLong
ICompletableFuture
with the current valuepublic InternalCompletableFuture<Long> getAndAddAsync(long delta)
IAtomicLong
This method will dispatch a request and return immediately an
ICompletableFuture
.
getAndAddAsync
in interface IAtomicLong
delta
- the value to addICompletableFuture
with the old value before the additionpublic InternalCompletableFuture<Long> getAndSetAsync(long newValue)
IAtomicLong
This method will dispatch a request and return immediately an
ICompletableFuture
.
getAndSetAsync
in interface IAtomicLong
newValue
- the new valueICompletableFuture
with the old valuepublic InternalCompletableFuture<Long> incrementAndGetAsync()
IAtomicLong
This method will dispatch a request and return immediately an
ICompletableFuture
.
incrementAndGetAsync
in interface IAtomicLong
ICompletableFuture
with the updated valuepublic InternalCompletableFuture<Long> getAndIncrementAsync()
IAtomicLong
This method will dispatch a request and return immediately an
ICompletableFuture
.
getAndIncrementAsync
in interface IAtomicLong
ICompletableFuture
with the old valuepublic InternalCompletableFuture<Void> setAsync(long newValue)
IAtomicLong
This method will dispatch a request and return immediately an
ICompletableFuture
.
setAsync
in interface IAtomicLong
newValue
- the new valueICompletableFuture
public InternalCompletableFuture<Void> alterAsync(IFunction<Long,Long> function)
IAtomicLong
This method will dispatch a request and return immediately an
ICompletableFuture
.
alterAsync
in interface IAtomicLong
function
- the functionICompletableFuture
with the new valuepublic InternalCompletableFuture<Long> alterAndGetAsync(IFunction<Long,Long> function)
IAtomicLong
This method will dispatch a request and return immediately an
ICompletableFuture
.
alterAndGetAsync
in interface IAtomicLong
function
- the functionICompletableFuture
with the new valuepublic InternalCompletableFuture<Long> getAndAlterAsync(IFunction<Long,Long> function)
IAtomicLong
This method will dispatch a request and return immediately an
ICompletableFuture
.
getAndAlterAsync
in interface IAtomicLong
function
- the functionICompletableFuture
with the old valuepublic <R> InternalCompletableFuture<R> applyAsync(IFunction<Long,R> function)
IAtomicLong
This method will dispatch a request and return immediately an
ICompletableFuture
. For example:
class IsOneFunction implements IFunction {
@Override
public Boolean apply(Long input) {
return input.equals(1L);
}
}
ICompletableFuture future = 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 applicationprotected void onInitialize()
ClientProxy
onInitialize
in class ClientProxy
protected ClientMessage invokeOnPartition(ClientMessage req)
protected <T> T invokeOnPartitionInterruptibly(ClientMessage clientMessage) throws InterruptedException
InterruptedException
protected <T> ClientDelegatingFuture<T> invokeOnPartitionAsync(ClientMessage clientMessage, ClientMessageDecoder clientMessageDecoder)
protected <T> T invokeOnPartition(ClientMessage clientMessage, long invocationTimeoutSeconds)
protected <T> T invokeOnPartitionInterruptibly(ClientMessage clientMessage, long invocationTimeoutSeconds) throws InterruptedException
InterruptedException
Copyright © 2019 Hazelcast, Inc.. All Rights Reserved.