Search in sources :

Example 36 with ClientInvocationFuture

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

the class ClientCacheIterator method fetch.

protected List fetch() {
    HazelcastClientInstanceImpl client = (HazelcastClientInstanceImpl) context.getHazelcastInstance();
    String name = cacheProxy.getPrefixedName();
    if (prefetchValues) {
        ClientMessage request = CacheIterateEntriesCodec.encodeRequest(name, encodePointers(pointers), fetchSize);
        try {
            ClientInvocation clientInvocation = new ClientInvocation(client, request, name, partitionIndex);
            ClientInvocationFuture future = clientInvocation.invoke();
            CacheIterateEntriesCodec.ResponseParameters responseParameters = CacheIterateEntriesCodec.decodeResponse(future.get());
            IterationPointer[] pointers = decodePointers(responseParameters.iterationPointers);
            setIterationPointers(responseParameters.entries, pointers);
            return responseParameters.entries;
        } catch (Exception e) {
            throw rethrow(e);
        }
    } else {
        ClientMessage request = CacheIterateCodec.encodeRequest(name, encodePointers(pointers), fetchSize);
        try {
            ClientInvocation clientInvocation = new ClientInvocation(client, request, name, partitionIndex);
            ClientInvocationFuture future = clientInvocation.invoke();
            CacheIterateCodec.ResponseParameters responseParameters = CacheIterateCodec.decodeResponse(future.get());
            IterationPointer[] pointers = decodePointers(responseParameters.iterationPointers);
            setIterationPointers(responseParameters.keys, pointers);
            return responseParameters.keys;
        } catch (Exception e) {
            throw rethrow(e);
        }
    }
}
Also used : CacheIterateCodec(com.hazelcast.client.impl.protocol.codec.CacheIterateCodec) CacheIterateEntriesCodec(com.hazelcast.client.impl.protocol.codec.CacheIterateEntriesCodec) IterationPointer(com.hazelcast.internal.iteration.IterationPointer) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 37 with ClientInvocationFuture

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

the class ClientCacheProxy method subscribeToEventJournal.

@Override
public InternalCompletableFuture<EventJournalInitialSubscriberState> subscribeToEventJournal(int partitionId) {
    final ClientMessage request = CacheEventJournalSubscribeCodec.encodeRequest(nameWithPrefix);
    final ClientInvocationFuture fut = new ClientInvocation(getClient(), request, getName(), partitionId).invoke();
    return new ClientDelegatingFuture<>(fut, getSerializationService(), eventJournalSubscribeResponseDecoder);
}
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)

Example 38 with ClientInvocationFuture

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

the class ClientCacheProxy method readFromEventJournal.

@Override
public <T> InternalCompletableFuture<ReadResultSet<T>> readFromEventJournal(long startSequence, int minSize, int maxSize, int partitionId, Predicate<? super EventJournalCacheEvent<K, V>> predicate, Function<? super EventJournalCacheEvent<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 = CacheEventJournalReadCodec.encodeRequest(nameWithPrefix, startSequence, minSize, maxSize, ss.toData(predicate), ss.toData(projection));
    final ClientInvocationFuture fut = new ClientInvocation(getClient(), request, getName(), partitionId).invoke();
    return new ClientDelegatingFuture<>(fut, ss, eventJournalReadResponseDecoder);
}
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) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 39 with ClientInvocationFuture

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

the class ClientCacheProxySupport method callPutAsync.

protected CompletableFuture callPutAsync(K key, Data keyData, V value, Data valueData, Data expiryPolicyData, boolean isGet, boolean withCompletionEvent, BiConsumer<V, Throwable> statsCallback) {
    ClientInvocationFuture invocationFuture = putInternal(keyData, valueData, expiryPolicyData, isGet, withCompletionEvent);
    InternalCompletableFuture future = newDelegatingFuture(invocationFuture, CachePutCodec::decodeResponse);
    return addCallback(future, statsCallback);
}
Also used : InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) CachePutCodec(com.hazelcast.client.impl.protocol.codec.CachePutCodec) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Example 40 with ClientInvocationFuture

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

the class AtomicLongProxy method addAndGetAsync.

@Override
public InternalCompletableFuture<Long> addAndGetAsync(long delta) {
    ClientMessage request = AtomicLongAddAndGetCodec.encodeRequest(groupId, objectName, delta);
    ClientInvocationFuture future = new ClientInvocation(getClient(), request, name).invoke();
    return new ClientDelegatingFuture<>(future, getSerializationService(), AtomicLongAddAndGetCodec::decodeResponse);
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) AtomicLongAddAndGetCodec(com.hazelcast.client.impl.protocol.codec.AtomicLongAddAndGetCodec) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) 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