use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientSchemaService method put.
@Override
public void put(Schema schema) {
long schemaId = schema.getSchemaId();
Schema existingSchema = schemas.get(schemaId);
if (existingSchema != null) {
return;
}
ClientMessage clientMessage = ClientSendSchemaCodec.encodeRequest(schema);
ClientInvocation invocation = new ClientInvocation(client, clientMessage, SERVICE_NAME);
invocation.invoke().joinInternal();
putIfAbsent(schema);
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientScheduledExecutorProxy method getAllScheduledFutures.
@Nonnull
@Override
public <V> Map<Member, List<IScheduledFuture<V>>> getAllScheduledFutures() {
ClientMessage request = ScheduledExecutorGetAllScheduledFuturesCodec.encodeRequest(getName());
ClientInvocationFuture future = new ClientInvocation(getClient(), request, getName()).invoke();
ClientMessage response;
try {
response = future.get();
} catch (Exception e) {
throw rethrow(e);
}
Collection<ScheduledTaskHandler> urnsPerMember = ScheduledExecutorGetAllScheduledFuturesCodec.decodeResponse(response);
Map<Member, List<IScheduledFuture<V>>> tasksMap = new HashMap<>();
for (ScheduledTaskHandler scheduledTaskHandler : urnsPerMember) {
UUID memberUuid = scheduledTaskHandler.getUuid();
Member member = getContext().getClusterService().getMember(memberUuid);
tasksMap.compute(member, (BiFunctionEx<Member, List<IScheduledFuture<V>>, List<IScheduledFuture<V>>>) (m, iScheduledFutures) -> {
if (iScheduledFutures == null) {
iScheduledFutures = new LinkedList<>();
}
iScheduledFutures.add(new ClientScheduledFutureProxy(scheduledTaskHandler, getContext()));
return iScheduledFutures;
});
}
return tasksMap;
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class IExecutorDelegatingFuture method invokeCancelRequest.
private boolean invokeCancelRequest(boolean mayInterruptIfRunning) throws InterruptedException, ExecutionException {
waitForRequestToBeSend();
HazelcastClientInstanceImpl client = (HazelcastClientInstanceImpl) context.getHazelcastInstance();
if (partitionId > -1) {
ClientMessage request = ExecutorServiceCancelOnPartitionCodec.encodeRequest(uuid, mayInterruptIfRunning);
ClientInvocation clientInvocation = new ClientInvocation(client, request, objectName, partitionId);
ClientInvocationFuture f = clientInvocation.invoke();
return ExecutorServiceCancelOnPartitionCodec.decodeResponse(f.get());
} else {
ClientMessage request = ExecutorServiceCancelOnMemberCodec.encodeRequest(uuid, member.getUuid(), mayInterruptIfRunning);
ClientInvocation clientInvocation = new ClientInvocation(client, request, objectName, member.getUuid());
ClientInvocationFuture f = clientInvocation.invoke();
return ExecutorServiceCancelOnMemberCodec.decodeResponse(f.get());
}
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocation 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.spi.impl.ClientInvocation 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);
}
}
Aggregations