Search in sources :

Example 11 with ClientDelegatingFuture

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

the class AtomicRefProxy method invokeApply.

private <T2, T3> InternalCompletableFuture<T3> invokeApply(IFunction<T, T2> function, ReturnValueType returnValueType, boolean alter) {
    checkTrue(function != null, "Function cannot be null");
    Data data = getContext().getSerializationService().toData(function);
    ClientMessage request = AtomicRefApplyCodec.encodeRequest(groupId, objectName, data, returnValueType.value(), alter);
    ClientInvocationFuture future = new ClientInvocation(getClient(), request, name).invoke();
    return new ClientDelegatingFuture<>(future, getSerializationService(), AtomicRefApplyCodec::decodeResponse);
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) Data(com.hazelcast.internal.serialization.Data) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) AtomicRefApplyCodec(com.hazelcast.client.impl.protocol.codec.AtomicRefApplyCodec) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 12 with ClientDelegatingFuture

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

the class ClientMapProxy method subscribeToEventJournal.

@Override
public InternalCompletableFuture<EventJournalInitialSubscriberState> subscribeToEventJournal(int partitionId) {
    final ClientMessage request = MapEventJournalSubscribeCodec.encodeRequest(name);
    final ClientInvocationFuture fut = new ClientInvocation(getClient(), request, getName(), partitionId).invoke();
    return new ClientDelegatingFuture<>(fut, getSerializationService(), message -> {
        ResponseParameters resp = MapEventJournalSubscribeCodec.decodeResponse(message);
        return new EventJournalInitialSubscriberState(resp.oldestSequence, resp.newestSequence);
    });
}
Also used : EventJournalInitialSubscriberState(com.hazelcast.internal.journal.EventJournalInitialSubscriberState) ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) ResponseParameters(com.hazelcast.client.impl.protocol.codec.MapEventJournalSubscribeCodec.ResponseParameters) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 13 with ClientDelegatingFuture

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

the class ClientMapProxy method readFromEventJournal.

@Override
public <T> InternalCompletableFuture<ReadResultSet<T>> readFromEventJournal(long startSequence, int minSize, int maxSize, int partitionId, java.util.function.Predicate<? super EventJournalMapEvent<K, V>> predicate, java.util.function.Function<? super EventJournalMapEvent<K, V>, ? extends T> projection) {
    if (maxSize < minSize) {
        throw new IllegalArgumentException("maxSize " + maxSize + " must be greater or equal to minSize " + minSize);
    }
    final SerializationService ss = getSerializationService();
    final ClientMessage request = MapEventJournalReadCodec.encodeRequest(name, startSequence, minSize, maxSize, ss.toData(predicate), ss.toData(projection));
    final ClientInvocationFuture fut = new ClientInvocation(getClient(), request, getName(), partitionId).invoke();
    return new ClientDelegatingFuture<>(fut, ss, message -> {
        MapEventJournalReadCodec.ResponseParameters params = MapEventJournalReadCodec.decodeResponse(message);
        ReadResultSetImpl resultSet = new ReadResultSetImpl<>(params.readCount, params.items, params.itemSeqs, params.nextSeq);
        resultSet.setSerializationService(getSerializationService());
        return resultSet;
    });
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) SerializationService(com.hazelcast.internal.serialization.SerializationService) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) MapEventJournalReadCodec(com.hazelcast.client.impl.protocol.codec.MapEventJournalReadCodec) ReadResultSetImpl(com.hazelcast.ringbuffer.impl.ReadResultSetImpl) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 14 with ClientDelegatingFuture

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

the class ClientDurableExecutorServiceProxy method retrieveAndDisposeResult.

@Override
public <T> Future<T> retrieveAndDisposeResult(long taskId) {
    int partitionId = Bits.extractInt(taskId, false);
    int sequence = Bits.extractInt(taskId, true);
    ClientMessage clientMessage = DurableExecutorRetrieveAndDisposeResultCodec.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)

Example 15 with ClientDelegatingFuture

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

the class MCTrustedInterfacesTest method testGetSystemPropertiesMessageTask_passing.

@Test
public void testGetSystemPropertiesMessageTask_passing() throws Exception {
    HazelcastInstance client = factory.newHazelcastClient(new ClientConfig(), "222.222.222.222");
    HazelcastClientInstanceImpl clientImpl = ((HazelcastClientProxy) client).client;
    ClientInvocation invocation = new ClientInvocation(clientImpl, MCGetSystemPropertiesCodec.encodeRequest(), null);
    ClientDelegatingFuture<List<Map.Entry<String, String>>> future = new ClientDelegatingFuture<>(invocation.invoke(), clientImpl.getSerializationService(), MCGetSystemPropertiesCodec::decodeResponse);
    assertFalse(future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS).isEmpty());
}
Also used : MCGetSystemPropertiesCodec(com.hazelcast.client.impl.protocol.codec.MCGetSystemPropertiesCodec) ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) List(java.util.List) ArrayList(java.util.ArrayList) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) Map(java.util.Map) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

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