use of com.hazelcast.client.util.ClientDelegatingFuture in project hazelcast by hazelcast.
the class AbstractClientInternalCacheProxy method putInternalAsync.
private Object putInternalAsync(final V value, final boolean isGet, final long start, final Data keyData, final Data valueData, ClientInvocationFuture future) {
OneShotExecutionCallback<V> oneShotExecutionCallback = null;
if (nearCache != null || statisticsEnabled) {
oneShotExecutionCallback = new OneShotExecutionCallback<V>() {
@Override
protected void onResponseInternal(V responseData) {
if (nearCache != null) {
if (cacheOnUpdate) {
storeInNearCache(keyData, valueData, value, NOT_RESERVED, cacheOnUpdate);
} else {
invalidateNearCache(keyData);
}
}
if (statisticsEnabled) {
handleStatisticsOnPut(isGet, start, responseData);
}
}
@Override
protected void onFailureInternal(Throwable t) {
}
};
}
SerializationService serializationService = clientContext.getSerializationService();
if (oneShotExecutionCallback == null) {
return new ClientDelegatingFuture<V>(future, serializationService, PUT_RESPONSE_DECODER);
}
ClientDelegatingFuture<V> delegatingFuture = new CallbackAwareClientDelegatingFuture<V>(future, serializationService, PUT_RESPONSE_DECODER, oneShotExecutionCallback);
delegatingFuture.andThenInternal(oneShotExecutionCallback, true);
return delegatingFuture;
}
use of com.hazelcast.client.util.ClientDelegatingFuture in project hazelcast by hazelcast.
the class AbstractClientInternalCacheProxy method removeAsyncInternal.
protected <T> ICompletableFuture<T> removeAsyncInternal(K key, V oldValue, boolean hasOldValue, boolean withCompletionEvent, boolean async) {
final long start = System.nanoTime();
ensureOpen();
if (hasOldValue) {
validateNotNull(key, oldValue);
CacheProxyUtil.validateConfiguredTypes(cacheConfig, key, oldValue);
} else {
validateNotNull(key);
CacheProxyUtil.validateConfiguredTypes(cacheConfig, key);
}
Data keyData = toData(key);
Data oldValueData = toData(oldValue);
int completionId = withCompletionEvent ? nextCompletionId() : -1;
ClientMessage request = CacheRemoveCodec.encodeRequest(nameWithPrefix, keyData, oldValueData, completionId);
ClientInvocationFuture future;
try {
future = invoke(request, keyData, completionId);
invalidateNearCache(keyData);
} catch (Exception e) {
throw rethrow(e);
}
ClientDelegatingFuture<T> delegatingFuture = new ClientDelegatingFuture<T>(future, clientContext.getSerializationService(), REMOVE_RESPONSE_DECODER);
if (async && statisticsEnabled) {
delegatingFuture.andThenInternal(new ExecutionCallback<T>() {
public void onResponse(T response) {
handleStatisticsOnRemove(false, start, response);
}
public void onFailure(Throwable t) {
}
}, true);
}
return delegatingFuture;
}
use of com.hazelcast.client.util.ClientDelegatingFuture in project hazelcast by hazelcast.
the class ClientMapProxy method submitToKeyInternal.
public void submitToKeyInternal(Data keyData, EntryProcessor entryProcessor, final ExecutionCallback callback) {
ClientMessage request = MapSubmitToKeyCodec.encodeRequest(name, toData(entryProcessor), keyData, getThreadId());
try {
ClientInvocationFuture future = invokeOnKeyOwner(request, keyData);
SerializationService serializationService = getContext().getSerializationService();
ClientDelegatingFuture clientDelegatingFuture = new ClientDelegatingFuture(future, serializationService, SUBMIT_TO_KEY_RESPONSE_DECODER);
clientDelegatingFuture.andThen(callback);
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.client.util.ClientDelegatingFuture in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceProxy method retrieveResult.
@Override
public <T> Future<T> retrieveResult(long taskId) {
int partitionId = Bits.extractInt(taskId, false);
int sequence = Bits.extractInt(taskId, true);
ClientMessage clientMessage = DurableExecutorRetrieveResultCodec.encodeRequest(name, sequence);
ClientInvocationFuture future = new ClientInvocation(getClient(), clientMessage, partitionId).invoke();
return new ClientDelegatingFuture<T>(future, getSerializationService(), RETRIEVE_RESPONSE_DECODER);
}
use of com.hazelcast.client.util.ClientDelegatingFuture in project hazelcast by hazelcast.
the class ClientExecutorServiceProxy method submitToTargetInternal.
private <T> void submitToTargetInternal(Callable<T> task, Address address, ExecutionCallback<T> callback) {
checkNotNull(task, "task should not be null");
String uuid = getUUID();
ClientMessage request = ExecutorServiceSubmitToAddressCodec.encodeRequest(name, uuid, toData(task), address);
ClientInvocationFuture f = invokeOnTarget(request, address);
SerializationService serializationService = getContext().getSerializationService();
ClientDelegatingFuture<T> delegatingFuture = new ClientDelegatingFuture<T>(f, serializationService, SUBMIT_TO_ADDRESS_DECODER);
delegatingFuture.andThen(callback);
}
Aggregations