Search in sources :

Example 31 with ClientInvocationFuture

use of com.hazelcast.client.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.

the class ClientPartitionCancellableDelegatingFuture method invokeCancelRequest.

private boolean invokeCancelRequest(boolean mayInterruptIfRunning) throws InterruptedException {
    waitForRequestToBeSend();
    ClientInvocation clientInvocation;
    final HazelcastClientInstanceImpl client = (HazelcastClientInstanceImpl) context.getHazelcastInstance();
    ClientMessage request = ExecutorServiceCancelOnPartitionCodec.encodeRequest(uuid, partitionId, mayInterruptIfRunning);
    clientInvocation = new ClientInvocation(client, request, partitionId);
    try {
        ClientInvocationFuture f = clientInvocation.invoke();
        return ExecutorServiceCancelOnPartitionCodec.decodeResponse(f.get()).response;
    } catch (Exception e) {
        throw rethrow(e);
    }
}
Also used : HazelcastClientInstanceImpl(com.hazelcast.client.impl.HazelcastClientInstanceImpl) ClientInvocation(com.hazelcast.client.spi.impl.ClientInvocation) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) CancellationException(java.util.concurrent.CancellationException) ClientInvocationFuture(com.hazelcast.client.spi.impl.ClientInvocationFuture)

Example 32 with ClientInvocationFuture

use of com.hazelcast.client.spi.impl.ClientInvocationFuture 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);
    }
}
Also used : ClientDelegatingFuture(com.hazelcast.client.util.ClientDelegatingFuture) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) SerializationService(com.hazelcast.spi.serialization.SerializationService) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) HazelcastException(com.hazelcast.core.HazelcastException) ClientInvocationFuture(com.hazelcast.client.spi.impl.ClientInvocationFuture)

Example 33 with ClientInvocationFuture

use of com.hazelcast.client.spi.impl.ClientInvocationFuture 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);
}
Also used : ClientDelegatingFuture(com.hazelcast.client.util.ClientDelegatingFuture) ClientInvocation(com.hazelcast.client.spi.impl.ClientInvocation) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientInvocationFuture(com.hazelcast.client.spi.impl.ClientInvocationFuture)

Example 34 with ClientInvocationFuture

use of com.hazelcast.client.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.

the class ClientExecutorServiceProxy method submitToTargetInternal.

private <T> Future<T> submitToTargetInternal(Callable<T> task, Address address, T defaultValue, boolean preventSync) {
    checkNotNull(task, "task should not be null");
    String uuid = getUUID();
    ClientMessage request = ExecutorServiceSubmitToAddressCodec.encodeRequest(name, uuid, toData(task), address);
    ClientInvocationFuture f = invokeOnTarget(request, address);
    return checkSync(f, uuid, address, preventSync, defaultValue);
}
Also used : ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientInvocationFuture(com.hazelcast.client.spi.impl.ClientInvocationFuture)

Example 35 with ClientInvocationFuture

use of com.hazelcast.client.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.

the class ClientExecutorServiceProxy method submitToKeyOwnerInternal.

private <T> Future<T> submitToKeyOwnerInternal(Callable<T> task, Object key, T defaultValue, boolean preventSync) {
    checkNotNull(task, "task should not be null");
    String uuid = getUUID();
    int partitionId = getPartitionId(key);
    ClientMessage request = ExecutorServiceSubmitToPartitionCodec.encodeRequest(name, uuid, toData(task), partitionId);
    ClientInvocationFuture f = invokeOnPartitionOwner(request, partitionId);
    return checkSync(f, uuid, partitionId, preventSync, defaultValue);
}
Also used : ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientInvocationFuture(com.hazelcast.client.spi.impl.ClientInvocationFuture)

Aggregations

ClientInvocationFuture (com.hazelcast.client.spi.impl.ClientInvocationFuture)36 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)31 ClientInvocation (com.hazelcast.client.spi.impl.ClientInvocation)21 ClientDelegatingFuture (com.hazelcast.client.util.ClientDelegatingFuture)17 Data (com.hazelcast.nio.serialization.Data)9 SerializationService (com.hazelcast.spi.serialization.SerializationService)9 ExecutionException (java.util.concurrent.ExecutionException)9 CacheException (javax.cache.CacheException)7 CacheEventData (com.hazelcast.cache.impl.CacheEventData)6 HazelcastClientInstanceImpl (com.hazelcast.client.impl.HazelcastClientInstanceImpl)6 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)5 HazelcastException (com.hazelcast.core.HazelcastException)3 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)3 StaleSequenceException (com.hazelcast.ringbuffer.StaleSequenceException)3 ClientConnection (com.hazelcast.client.connection.nio.ClientConnection)2 EventHandler (com.hazelcast.client.spi.EventHandler)2 Connection (com.hazelcast.nio.Connection)2 CancellationException (java.util.concurrent.CancellationException)2 AuthenticationException (com.hazelcast.client.AuthenticationException)1 ClientMessageDecoder (com.hazelcast.client.impl.ClientMessageDecoder)1