use of com.hazelcast.client.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class AbstractClientInternalCacheProxy method getAndRemoveAsyncInternal.
protected <T> ICompletableFuture<T> getAndRemoveAsyncInternal(K key, boolean withCompletionEvent, boolean async) {
final long start = System.nanoTime();
ensureOpen();
validateNotNull(key);
CacheProxyUtil.validateConfiguredTypes(cacheConfig, key);
final Data keyData = toData(key);
final int completionId = withCompletionEvent ? nextCompletionId() : -1;
ClientMessage request = CacheGetAndRemoveCodec.encodeRequest(nameWithPrefix, keyData, 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(), GET_AND_REMOVE_RESPONSE_DECODER);
if (async && statisticsEnabled) {
delegatingFuture.andThenInternal(new ExecutionCallback<T>() {
public void onResponse(T response) {
handleStatisticsOnRemove(true, start, response);
}
public void onFailure(Throwable t) {
}
}, true);
}
return delegatingFuture;
}
use of com.hazelcast.client.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class AbstractClientInternalCacheProxy method putIfAbsentInternal.
protected Object putIfAbsentInternal(K key, V value, ExpiryPolicy expiryPolicy, boolean withCompletionEvent, boolean async) {
long start = System.nanoTime();
ensureOpen();
validateNotNull(key, value);
CacheProxyUtil.validateConfiguredTypes(cacheConfig, key, value);
Data keyData = toData(key);
Data valueData = toData(value);
Data expiryPolicyData = toData(expiryPolicy);
int completionId = withCompletionEvent ? nextCompletionId() : -1;
ClientMessage request = CachePutIfAbsentCodec.encodeRequest(nameWithPrefix, keyData, valueData, expiryPolicyData, completionId);
ClientInvocationFuture future;
try {
future = invoke(request, keyData, completionId);
} catch (Throwable t) {
throw rethrow(t);
}
ClientDelegatingFuture<Boolean> delegatingFuture = new ClientDelegatingFuture<Boolean>(future, clientContext.getSerializationService(), PUT_IF_ABSENT_RESPONSE_DECODER);
if (async) {
return putIfAbsentInternalAsync(value, start, keyData, valueData, delegatingFuture);
}
return putIfAbsentInternalSync(value, start, keyData, valueData, delegatingFuture);
}
use of com.hazelcast.client.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientMapProxy method getAsyncInternal.
protected ICompletableFuture<V> getAsyncInternal(Data keyData) {
SerializationService serializationService = getContext().getSerializationService();
ClientMessage request = MapGetCodec.encodeRequest(name, keyData, getThreadId());
try {
ClientInvocationFuture future = invokeOnKeyOwner(request, keyData);
return new ClientDelegatingFuture<V>(future, serializationService, GET_ASYNC_RESPONSE_DECODER);
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.client.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientMapReduceProxy method invoke.
private ClientMessage invoke(ClientMessage request, String jobId) throws Exception {
ClientTrackableJob trackableJob = trackableJobs.get(jobId);
if (trackableJob != null) {
ClientConnection sendConnection = trackableJob.clientInvocation.getSendConnectionOrWait();
Address runningMember = sendConnection.getEndPoint();
final ClientInvocation clientInvocation = new ClientInvocation(getClient(), request, runningMember);
ClientInvocationFuture future = clientInvocation.invoke();
return future.get();
}
return null;
}
use of com.hazelcast.client.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientScheduledExecutorProxy method getAllScheduledFutures.
@Override
public <V> Map<Member, List<IScheduledFuture<V>>> getAllScheduledFutures() {
ClientMessage request = ScheduledExecutorGetAllScheduledFuturesCodec.encodeRequest(getName());
final ClientInvocationFuture future = new ClientInvocation(getClient(), request).invoke();
ClientMessage response;
try {
response = future.get();
} catch (Exception e) {
throw rethrow(e);
}
Collection<Map.Entry<Member, List<ScheduledTaskHandler>>> urnsPerMember = ScheduledExecutorGetAllScheduledFuturesCodec.decodeResponse(response).handlers;
Map<Member, List<IScheduledFuture<V>>> tasksMap = new HashMap<Member, List<IScheduledFuture<V>>>();
for (Map.Entry<Member, List<ScheduledTaskHandler>> entry : urnsPerMember) {
List<IScheduledFuture<V>> memberTasks = new ArrayList<IScheduledFuture<V>>();
for (ScheduledTaskHandler scheduledTaskHandler : entry.getValue()) {
memberTasks.add(new ClientScheduledFutureProxy(scheduledTaskHandler, getContext()));
}
tasksMap.put(entry.getKey(), memberTasks);
}
return tasksMap;
}
Aggregations