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);
}
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);
});
}
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;
});
}
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);
}
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());
}
Aggregations