Search in sources :

Example 21 with ClientInvocationFuture

use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture 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 22 with ClientInvocationFuture

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

the class ClientMapQueryPartitionIterator method fetch.

@Override
protected List<Data> fetch() {
    HazelcastClientInstanceImpl client = (HazelcastClientInstanceImpl) context.getHazelcastInstance();
    ClientMessage request = MapFetchWithQueryCodec.encodeRequest(mapProxy.getName(), encodePointers(pointers), fetchSize, getSerializationService().toData(query.getProjection()), getSerializationService().toData(query.getPredicate()));
    ClientInvocation clientInvocation = new ClientInvocation(client, request, mapProxy.getName(), partitionId);
    try {
        ClientInvocationFuture f = clientInvocation.invoke();
        MapFetchWithQueryCodec.ResponseParameters responseParameters = MapFetchWithQueryCodec.decodeResponse(f.get());
        List<Data> results = responseParameters.results;
        IterationPointer[] pointers = decodePointers(responseParameters.iterationPointers);
        setLastTableIndex(results, pointers);
        return results;
    } catch (Exception e) {
        throw ExceptionUtil.rethrow(e);
    }
}
Also used : IterationPointer(com.hazelcast.internal.iteration.IterationPointer) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) Data(com.hazelcast.internal.serialization.Data) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) MapFetchWithQueryCodec(com.hazelcast.client.impl.protocol.codec.MapFetchWithQueryCodec) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 23 with ClientInvocationFuture

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

the class ClientMapPartitionIterator method fetchWithPrefetchValues.

private List fetchWithPrefetchValues(HazelcastClientInstanceImpl client) {
    ClientMessage request = MapFetchEntriesCodec.encodeRequest(mapProxy.getName(), encodePointers(pointers), fetchSize);
    ClientInvocation clientInvocation = new ClientInvocation(client, request, mapProxy.getName(), partitionId);
    try {
        ClientInvocationFuture f = clientInvocation.invoke();
        MapFetchEntriesCodec.ResponseParameters responseParameters = MapFetchEntriesCodec.decodeResponse(f.get());
        IterationPointer[] pointers = decodePointers(responseParameters.iterationPointers);
        setIterationPointers(responseParameters.entries, pointers);
        return responseParameters.entries;
    } catch (Exception e) {
        throw ExceptionUtil.rethrow(e);
    }
}
Also used : IterationPointer(com.hazelcast.internal.iteration.IterationPointer) MapFetchEntriesCodec(com.hazelcast.client.impl.protocol.codec.MapFetchEntriesCodec) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 24 with ClientInvocationFuture

use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture 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 25 with ClientInvocationFuture

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

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