Search in sources :

Example 21 with ClientDelegatingFuture

use of com.hazelcast.client.impl.ClientDelegatingFuture in project hazelcast by hazelcast.

the class MCMessageTasksTest method testGetTimedMemberStateMessageTask.

@Test
public void testGetTimedMemberStateMessageTask() throws Exception {
    ClientInvocation invocation = new ClientInvocation(getClientImpl(), MCGetTimedMemberStateCodec.encodeRequest(), null);
    ClientDelegatingFuture<String> future = new ClientDelegatingFuture<>(invocation.invoke(), getClientImpl().getSerializationService(), MCGetTimedMemberStateCodec::decodeResponse);
    assertFalse(isNullOrEmptyAfterTrim(future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS)));
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) MCGetTimedMemberStateCodec(com.hazelcast.client.impl.protocol.codec.MCGetTimedMemberStateCodec) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 22 with ClientDelegatingFuture

use of com.hazelcast.client.impl.ClientDelegatingFuture in project hazelcast by hazelcast.

the class MCMessageTasksTest method testGetMemberConfigMessageTask.

@Test
public void testGetMemberConfigMessageTask() throws Exception {
    ClientInvocation invocation = new ClientInvocation(getClientImpl(), MCGetMemberConfigCodec.encodeRequest(), null);
    ClientDelegatingFuture<String> future = new ClientDelegatingFuture<>(invocation.invoke(), getClientImpl().getSerializationService(), MCGetMemberConfigCodec::decodeResponse);
    assertFalse(isNullOrEmptyAfterTrim(future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS)));
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) MCGetMemberConfigCodec(com.hazelcast.client.impl.protocol.codec.MCGetMemberConfigCodec) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 23 with ClientDelegatingFuture

use of com.hazelcast.client.impl.ClientDelegatingFuture 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 24 with ClientDelegatingFuture

use of com.hazelcast.client.impl.ClientDelegatingFuture 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)

Example 25 with ClientDelegatingFuture

use of com.hazelcast.client.impl.ClientDelegatingFuture 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, getName(), partitionId).invoke();
    return new ClientDelegatingFuture<>(future, getSerializationService(), DurableExecutorRetrieveResultCodec::decodeResponse);
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) DurableExecutorRetrieveResultCodec(com.hazelcast.client.impl.protocol.codec.DurableExecutorRetrieveResultCodec) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Aggregations

ClientDelegatingFuture (com.hazelcast.client.impl.ClientDelegatingFuture)54 ClientInvocation (com.hazelcast.client.impl.spi.impl.ClientInvocation)46 ClientInvocationFuture (com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)32 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)31 Test (org.junit.Test)17 Data (com.hazelcast.internal.serialization.Data)16 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)15 QuickTest (com.hazelcast.test.annotation.QuickTest)15 SerializationService (com.hazelcast.internal.serialization.SerializationService)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ClientConfig (com.hazelcast.client.config.ClientConfig)3 StaleSequenceException (com.hazelcast.ringbuffer.StaleSequenceException)3 Nonnull (javax.annotation.Nonnull)3 AtomicLongAlterCodec (com.hazelcast.client.impl.protocol.codec.AtomicLongAlterCodec)2 AtomicRefSetCodec (com.hazelcast.client.impl.protocol.codec.AtomicRefSetCodec)2 MapGetCodec (com.hazelcast.client.impl.protocol.codec.MapGetCodec)2 SqlMappingDdlCodec (com.hazelcast.client.impl.protocol.codec.SqlMappingDdlCodec)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 IExecutorService (com.hazelcast.core.IExecutorService)2