use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientScheduledFutureProxy method get0.
private V get0(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
checkAccessibleHandler();
UUID uuid = handler.getUuid();
String schedulerName = handler.getSchedulerName();
String taskName = handler.getTaskName();
int partitionId = handler.getPartitionId();
if (uuid != null) {
ClientMessage request = ScheduledExecutorGetResultFromMemberCodec.encodeRequest(schedulerName, taskName, uuid);
ClientInvocationFuture future = new ClientInvocation(getClient(), request, schedulerName, uuid).invoke();
ClientMessage response = future.get(timeout, unit);
Data data = ScheduledExecutorGetResultFromMemberCodec.decodeResponse(response);
return toObject(data);
} else {
ClientMessage request = ScheduledExecutorGetResultFromPartitionCodec.encodeRequest(schedulerName, taskName);
ClientInvocationFuture future = new ClientInvocation(getClient(), request, schedulerName, partitionId).invoke();
ClientMessage response = future.get(timeout, unit);
Data data = ScheduledExecutorGetResultFromPartitionCodec.decodeResponse(response);
return toObject(data);
}
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientMapProxy method submitToKeyInternal.
public <R> InternalCompletableFuture<R> submitToKeyInternal(Object key, EntryProcessor<K, V, R> entryProcessor) {
try {
Data keyData = toData(key);
ClientMessage request = MapSubmitToKeyCodec.encodeRequest(name, toData(entryProcessor), keyData, getThreadId());
ClientInvocationFuture future = invokeOnKeyOwner(request, keyData);
SerializationService ss = getSerializationService();
return new ClientDelegatingFuture(future, ss, MapSubmitToKeyCodec::decodeResponse);
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientListenerServiceImpl method invoke.
protected void invoke(ClientListenerRegistration listenerRegistration, Connection connection) throws Exception {
// This method should only be called from registrationExecutor
assert (Thread.currentThread().getName().contains("eventRegistration"));
if (listenerRegistration.getConnectionRegistrations().containsKey(connection)) {
return;
}
ListenerMessageCodec codec = listenerRegistration.getCodec();
ClientMessage request = codec.encodeAddRequest(registersLocalOnly());
EventHandler handler = listenerRegistration.getHandler();
if (logger.isFinestEnabled()) {
logger.finest("Register attempt of " + listenerRegistration + " to " + connection);
}
handler.beforeListenerRegister(connection);
ClientInvocation invocation = new ClientInvocation(client, request, null, connection);
invocation.setEventHandler(handler);
ClientInvocationFuture future = invocation.invokeUrgent();
ClientMessage clientMessage;
try {
clientMessage = future.get();
} catch (Exception e) {
throw ExceptionUtil.rethrow(e, Exception.class);
}
UUID serverRegistrationId = codec.decodeAddResponse(clientMessage);
if (logger.isFinestEnabled()) {
logger.finest("Registered " + listenerRegistration + " to " + connection);
}
handler.onListenerRegister(connection);
long correlationId = request.getCorrelationId();
ClientConnectionRegistration registration = new ClientConnectionRegistration(serverRegistrationId, correlationId);
listenerRegistration.getConnectionRegistrations().put(connection, registration);
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class NearCachedClientMapProxy method getAsync.
@Override
public InternalCompletableFuture<V> getAsync(@Nonnull K key) {
checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
final Object ncKey = toNearCacheKey(key);
Object value = getCachedValue(ncKey, false);
if (value != NOT_CACHED) {
return newCompletedFuture(value, getSerializationService());
}
Data keyData = toData(ncKey);
final long reservationId = nearCache.tryReserveForUpdate(ncKey, keyData, READ_UPDATE);
ClientInvocationFuture invocationFuture;
try {
invocationFuture = super.getAsyncInternal(keyData);
} catch (Throwable t) {
invalidateNearCache(ncKey);
throw rethrow(t);
}
if (reservationId != NOT_RESERVED) {
invocationFuture.whenCompleteAsync((response, t) -> {
if (t == null) {
Object newDecodedResponse = MapGetCodec.decodeResponse(response);
nearCache.tryPublishReserved(ncKey, newDecodedResponse, reservationId, false);
} else {
invalidateNearCache(ncKey);
}
}, getClient().getTaskScheduler());
}
return new ClientDelegatingFuture<>(getAsyncInternal(key), getSerializationService(), MapGetCodec::decodeResponse);
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientMapPartitionIterator method fetchWithoutPrefetchValues.
private List fetchWithoutPrefetchValues(HazelcastClientInstanceImpl client) {
ClientMessage request = MapFetchKeysCodec.encodeRequest(mapProxy.getName(), encodePointers(pointers), fetchSize);
ClientInvocation clientInvocation = new ClientInvocation(client, request, mapProxy.getName(), partitionId);
try {
ClientInvocationFuture f = clientInvocation.invoke();
MapFetchKeysCodec.ResponseParameters responseParameters = MapFetchKeysCodec.decodeResponse(f.get());
IterationPointer[] pointers = decodePointers(responseParameters.iterationPointers);
setIterationPointers(responseParameters.keys, pointers);
return responseParameters.keys;
} catch (Exception e) {
throw ExceptionUtil.rethrow(e);
}
}
Aggregations