use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientCacheProxySupport method doPutIfAbsentOnServer.
private InternalCompletableFuture<Boolean> doPutIfAbsentOnServer(Data keyData, Data valueData, Data expiryPolicyData, boolean withCompletionEvent) {
int completionId = withCompletionEvent ? nextCompletionId() : -1;
ClientMessage request = CachePutIfAbsentCodec.encodeRequest(nameWithPrefix, keyData, valueData, expiryPolicyData, completionId);
ClientInvocationFuture future = invoke(request, keyData, completionId);
return newDelegatingFuture(future, CachePutIfAbsentCodec::decodeResponse);
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientCacheProxySupport method invoke.
protected ClientInvocationFuture invoke(ClientMessage req, int partitionId, int completionId) {
boolean completionOperation = completionId != -1;
if (completionOperation) {
listenerCompleter.registerCompletionLatch(completionId, 1);
}
try {
ClientInvocation clientInvocation = new ClientInvocation(getClient(), req, name, partitionId);
ClientInvocationFuture future = clientInvocation.invoke();
if (completionOperation) {
listenerCompleter.waitCompletionLatch(completionId, future);
}
return future;
} catch (Throwable e) {
if (e instanceof IllegalStateException) {
close();
}
if (completionOperation) {
listenerCompleter.deregisterCompletionLatch(completionId);
}
throw rethrowAllowedTypeFirst(e, CacheException.class);
}
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientCacheProxySupport method doGetAndReplaceOnServer.
private <T> CompletableFuture<T> doGetAndReplaceOnServer(Data keyData, Data newValueData, Data expiryPolicyData, boolean withCompletionEvent, BiConsumer<T, Throwable> statsCallback) {
int completionId = withCompletionEvent ? nextCompletionId() : -1;
ClientMessage request = CacheGetAndReplaceCodec.encodeRequest(nameWithPrefix, keyData, newValueData, expiryPolicyData, completionId);
ClientInvocationFuture future = invoke(request, keyData, completionId);
ClientDelegatingFuture<T> delegatingFuture = newDelegatingFuture(future, CacheGetAndReplaceCodec::decodeResponse);
return addCallback(delegatingFuture, statsCallback);
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientCacheProxySupport method doRemoveOnServer.
@Nonnull
private InternalCompletableFuture<Boolean> doRemoveOnServer(Data keyData, Data oldValueData, boolean withCompletionEvent) {
int completionId = withCompletionEvent ? nextCompletionId() : -1;
ClientMessage request = CacheRemoveCodec.encodeRequest(nameWithPrefix, keyData, oldValueData, completionId);
ClientInvocationFuture future = invoke(request, keyData, completionId);
return newDelegatingFuture(future, CacheRemoveCodec::decodeResponse);
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class SqlClientService method fetchAsync.
public void fetchAsync(Connection connection, QueryId queryId, int cursorBufferSize, SqlClientResult res) {
ClientMessage requestMessage = SqlFetchCodec.encodeRequest(queryId, cursorBufferSize);
ClientInvocationFuture future = invokeAsync(requestMessage, connection);
future.whenComplete(withTryCatch(logger, (message, error) -> handleFetchResponse(connection, res, message, error)));
}
Aggregations