use of com.hazelcast.client.impl.ClientDelegatingFuture in project hazelcast by hazelcast.
the class ClientCacheProxySupport method submitLoadAllTask.
private void submitLoadAllTask(ClientMessage request, CompletionListener completionListener, final List<Data> binaryKeys) {
final CompletionListener listener = completionListener != null ? injectDependencies(completionListener) : NULL_COMPLETION_LISTENER;
ClientDelegatingFuture<V> delegatingFuture = null;
try {
final long startNanos = nowInNanosOrDefault();
ClientInvocationFuture future = new ClientInvocation(getClient(), request, getName()).invoke();
delegatingFuture = newDelegatingFuture(future, clientMessage -> Boolean.TRUE);
final Future delFuture = delegatingFuture;
loadAllCalls.put(delegatingFuture, listener);
delegatingFuture.whenCompleteAsync((response, t) -> {
if (t == null) {
loadAllCalls.remove(delFuture);
onLoadAll(binaryKeys, startNanos);
listener.onCompletion();
} else {
loadAllCalls.remove(delFuture);
handleFailureOnCompletionListener(listener, t);
}
});
} catch (Throwable t) {
if (delegatingFuture != null) {
loadAllCalls.remove(delegatingFuture);
}
handleFailureOnCompletionListener(listener, t);
}
}
use of com.hazelcast.client.impl.ClientDelegatingFuture in project hazelcast by hazelcast.
the class SqlClientService method mappingDdl.
/**
* Gets a SQL Mapping suggestion for the given IMap name.
*
* Used by Management Center.
*/
@Nonnull
public CompletableFuture<String> mappingDdl(Member member, String mapName) {
checkNotNull(mapName);
ClientInvocation invocation = new ClientInvocation(client, SqlMappingDdlCodec.encodeRequest(mapName), null, member.getUuid());
return new ClientDelegatingFuture<>(invocation.invoke(), client.getSerializationService(), SqlMappingDdlCodec::decodeResponse);
}
use of com.hazelcast.client.impl.ClientDelegatingFuture in project hazelcast by hazelcast.
the class ClientRingbufferProxy method addAllAsync.
@Override
public InternalCompletableFuture<Long> addAllAsync(@Nonnull Collection<? extends E> collection, @Nonnull OverflowPolicy overflowPolicy) {
checkNotNull(collection, "collection can't be null");
checkNotNull(overflowPolicy, "overflowPolicy can't be null");
checkFalse(collection.isEmpty(), "collection can't be empty");
checkTrue(collection.size() <= MAX_BATCH_SIZE, "collection can't be larger than " + MAX_BATCH_SIZE);
Collection<Data> dataCollection = objectToDataCollection(collection, getSerializationService());
ClientMessage request = RingbufferAddAllCodec.encodeRequest(name, dataCollection, overflowPolicy.getId());
try {
ClientInvocationFuture future = new ClientInvocation(getClient(), request, getName(), partitionId).invoke();
return new ClientDelegatingFuture<>(future, getSerializationService(), RingbufferAddAllCodec::decodeResponse);
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.client.impl.ClientDelegatingFuture in project hazelcast by hazelcast.
the class ClientRingbufferProxy method readManyAsync.
@Override
public InternalCompletableFuture<ReadResultSet<E>> readManyAsync(long startSequence, int minCount, int maxCount, IFunction<E, Boolean> filter) {
checkSequence(startSequence);
checkNotNegative(minCount, "minCount can't be smaller than 0");
checkTrue(maxCount >= minCount, "maxCount should be equal or larger than minCount");
try {
capacity();
} catch (Throwable e) {
return completedExceptionally(e);
}
checkTrue(maxCount <= capacity, "the maxCount should be smaller than or equal to the capacity");
checkTrue(maxCount <= MAX_BATCH_SIZE, "maxCount can't be larger than " + MAX_BATCH_SIZE);
ClientMessage request = RingbufferReadManyCodec.encodeRequest(name, startSequence, minCount, maxCount, toData(filter));
try {
ClientInvocationFuture invocationFuture = new ClientInvocation(getClient(), request, getName(), partitionId).invoke();
return new ClientDelegatingFuture<>(invocationFuture, getSerializationService(), readManyAsyncResponseDecoder);
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.client.impl.ClientDelegatingFuture in project hazelcast by hazelcast.
the class ClientRingbufferProxy method addAsync.
@Override
public InternalCompletableFuture<Long> addAsync(@Nonnull E item, @Nonnull OverflowPolicy overflowPolicy) {
checkNotNull(item, "item can't be null");
checkNotNull(overflowPolicy, "overflowPolicy can't be null");
Data element = toData(item);
ClientMessage request = RingbufferAddCodec.encodeRequest(name, overflowPolicy.getId(), element);
try {
ClientInvocationFuture future = new ClientInvocation(getClient(), request, getName(), partitionId).invoke();
return new ClientDelegatingFuture<>(future, getSerializationService(), RingbufferAddCodec::decodeResponse);
} catch (Exception e) {
throw rethrow(e);
}
}
Aggregations