Search in sources :

Example 51 with ClientInvocationFuture

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

the class ClientDynamicClusterConfig method invoke.

private void invoke(ClientMessage request) {
    try {
        ClientInvocation invocation = new ClientInvocation(instance, request, null);
        ClientInvocationFuture future = invocation.invoke();
        future.get();
    } catch (Exception e) {
        throw rethrow(e);
    }
}
Also used : ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 52 with ClientInvocationFuture

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

the class ClientDelegatingFutureTest method setup.

@Before
public void setup() {
    serializationService = new DefaultSerializationServiceBuilder().build();
    key = serializationService.toData("key");
    value = serializationService.toData(DESERIALIZED_VALUE);
    logger = mock(ILogger.class);
    request = MapGetCodec.encodeRequest("test", key, 1L);
    response = MapGetCodec.encodeResponse(value);
    callIdSequence = mock(CallIdSequence.class);
    invocationFuture = new ClientInvocationFuture(mock(ClientInvocation.class), request, logger, callIdSequence);
    delegatingFuture = new ClientDelegatingFuture<>(invocationFuture, serializationService, MapGetCodec::decodeResponse, true);
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) ILogger(com.hazelcast.logging.ILogger) CallIdSequence(com.hazelcast.spi.impl.sequence.CallIdSequence) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture) Before(org.junit.Before)

Example 53 with ClientInvocationFuture

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

the class MCMessageTasksTest method assertFailure.

private void assertFailure(ClientMessage clientMessage, Class<? extends Exception> expectedExceptionType, String expectedExceptionMsg) throws Exception {
    ClientInvocation invocation = new ClientInvocation(getClientImpl(), clientMessage, null);
    ClientInvocationFuture future = invocation.invoke();
    try {
        future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS);
        fail("Execution was successful whereas failure was expected.");
    } catch (ExecutionException e) {
        Throwable cause = e.getCause();
        assertTrue("Cause is of type " + cause.getClass().toString(), cause.getClass().isAssignableFrom(expectedExceptionType));
        assertEquals(expectedExceptionMsg, cause.getMessage());
    }
}
Also used : ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ExecutionException(java.util.concurrent.ExecutionException) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 54 with ClientInvocationFuture

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

the class ClientMapProxy method submitToKeysInternal.

/**
 * @param objectKeys not serialized key
 * @param dataKeys   serialized keys
 */
@Nonnull
protected <R> InternalCompletableFuture<Map<K, R>> submitToKeysInternal(@Nonnull Set<K> objectKeys, @Nonnull Collection<Data> dataKeys, @Nonnull EntryProcessor<K, V, R> entryProcessor) {
    ClientMessage request = MapExecuteOnKeysCodec.encodeRequest(name, toData(entryProcessor), dataKeys);
    ClientInvocationFuture future = new ClientInvocation(getClient(), request, getName()).invoke();
    return new ClientDelegatingFuture<>(future, getSerializationService(), message -> prepareResult(MapExecuteOnKeysCodec.decodeResponse(message)));
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture) Nonnull(javax.annotation.Nonnull)

Example 55 with ClientInvocationFuture

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

the class ClientMapProxy method removeAsyncInternal.

protected InternalCompletableFuture<V> removeAsyncInternal(Object key) {
    try {
        Data keyData = toData(key);
        ClientMessage request = MapRemoveCodec.encodeRequest(name, keyData, getThreadId());
        ClientInvocationFuture future = invokeOnKeyOwner(request, keyData);
        SerializationService ss = getSerializationService();
        return new ClientDelegatingFuture<>(future, ss, MapRemoveCodec::decodeResponse);
    } catch (Exception e) {
        throw rethrow(e);
    }
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) MapRemoveCodec(com.hazelcast.client.impl.protocol.codec.MapRemoveCodec) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data) 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