Search in sources :

Example 6 with ClientInvocationFuture

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);
}
Also used : ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) CachePutIfAbsentCodec(com.hazelcast.client.impl.protocol.codec.CachePutIfAbsentCodec) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 7 with ClientInvocationFuture

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);
    }
}
Also used : CacheException(javax.cache.CacheException) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 8 with ClientInvocationFuture

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);
}
Also used : CacheGetAndReplaceCodec(com.hazelcast.client.impl.protocol.codec.CacheGetAndReplaceCodec) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 9 with ClientInvocationFuture

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);
}
Also used : CacheRemoveCodec(com.hazelcast.client.impl.protocol.codec.CacheRemoveCodec) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture) Nonnull(javax.annotation.Nonnull)

Example 10 with ClientInvocationFuture

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)));
}
Also used : HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) ClientConnection(com.hazelcast.client.impl.connection.ClientConnection) Member(com.hazelcast.cluster.Member) SqlStatement(com.hazelcast.sql.SqlStatement) CompletableFuture(java.util.concurrent.CompletableFuture) ConnectionType(com.hazelcast.internal.nio.ConnectionType) SqlFetchCodec(com.hazelcast.client.impl.protocol.codec.SqlFetchCodec) SqlRowMetadata(com.hazelcast.sql.SqlRowMetadata) ArrayList(java.util.ArrayList) ILogger(com.hazelcast.logging.ILogger) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) QueryUtils(com.hazelcast.sql.impl.QueryUtils) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) Nonnull(javax.annotation.Nonnull) QueryException(com.hazelcast.sql.impl.QueryException) SqlService(com.hazelcast.sql.SqlService) HazelcastSqlException(com.hazelcast.sql.HazelcastSqlException) Connection(com.hazelcast.internal.nio.Connection) Data(com.hazelcast.internal.serialization.Data) SqlCloseCodec(com.hazelcast.client.impl.protocol.codec.SqlCloseCodec) SqlMappingDdlCodec(com.hazelcast.client.impl.protocol.codec.SqlMappingDdlCodec) UUID(java.util.UUID) QueryId(com.hazelcast.sql.impl.QueryId) Preconditions.checkNotNull(com.hazelcast.internal.util.Preconditions.checkNotNull) List(java.util.List) ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture) SqlResult(com.hazelcast.sql.SqlResult) AccessControlException(java.security.AccessControlException) ExceptionUtil.withTryCatch(com.hazelcast.internal.util.ExceptionUtil.withTryCatch) SqlExecuteCodec(com.hazelcast.client.impl.protocol.codec.SqlExecuteCodec) SqlErrorCode(com.hazelcast.sql.impl.SqlErrorCode) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Aggregations

ClientInvocationFuture (com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)65 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)54 ClientInvocation (com.hazelcast.client.impl.spi.impl.ClientInvocation)44 ClientDelegatingFuture (com.hazelcast.client.impl.ClientDelegatingFuture)34 Data (com.hazelcast.internal.serialization.Data)22 UUID (java.util.UUID)11 Nonnull (javax.annotation.Nonnull)6 ILogger (com.hazelcast.logging.ILogger)5 InternalCompletableFuture (com.hazelcast.spi.impl.InternalCompletableFuture)5 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)5 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)4 IterationPointer (com.hazelcast.internal.iteration.IterationPointer)4 SerializationService (com.hazelcast.internal.serialization.SerializationService)4 CachePutCodec (com.hazelcast.client.impl.protocol.codec.CachePutCodec)3 DurableExecutorRetrieveResultCodec (com.hazelcast.client.impl.protocol.codec.DurableExecutorRetrieveResultCodec)3 Member (com.hazelcast.cluster.Member)3 ExecutionCallbackAdapter (com.hazelcast.executor.impl.ExecutionCallbackAdapter)3 StaleSequenceException (com.hazelcast.ringbuffer.StaleSequenceException)3 AccessControlException (java.security.AccessControlException)3 List (java.util.List)3