use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceProxy method submitToPartition.
private <T> DurableExecutorServiceFuture<T> submitToPartition(@Nonnull Callable<T> task, int partitionId, @Nullable T result) {
checkNotNull(task, "task should not be null");
ClientMessage request = DurableExecutorSubmitToPartitionCodec.encodeRequest(name, toData(task));
int sequence;
try {
ClientMessage response = invokeOnPartition(request, partitionId);
sequence = DurableExecutorSubmitToPartitionCodec.decodeResponse(response);
} catch (Throwable t) {
return completedExceptionally(t, ConcurrencyUtil.getDefaultAsyncExecutor());
}
ClientMessage clientMessage = DurableExecutorRetrieveResultCodec.encodeRequest(name, sequence);
ClientInvocationFuture future = new ClientInvocation(getClient(), clientMessage, getName(), partitionId).invoke();
long taskId = Bits.combineToLong(partitionId, sequence);
return new ClientDurableExecutorServiceDelegatingFuture<>(future, getSerializationService(), DurableExecutorRetrieveResultCodec::decodeResponse, result, taskId);
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture 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.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class DisabledOperationsTest method assertFailure.
private void assertFailure(ClientMessage clientMessage, String expectedExceptionMsg) throws Exception {
ClientInvocation invocation = new ClientInvocation(client, clientMessage, null);
ClientInvocationFuture future = invocation.invoke();
assertThatThrownBy(() -> future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS)).hasCauseInstanceOf(AccessControlException.class).hasRootCauseMessage(expectedExceptionMsg);
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class ClientDelegatingFuture_SerializationExceptionTest method setup.
@Before
public void setup() {
serializationService = new DefaultSerializationServiceBuilder().build();
key = serializationService.toData("key");
value = invalidData;
logger = mock(ILogger.class);
request = MapGetCodec.encodeRequest("test", key, 1L);
response = MapGetCodec.encodeResponse(value);
callIdSequence = mock(CallIdSequence.class);
invocationFuture = new ClientInvocationFuture(mock(ClientInvocation.class), request, logger, callIdSequence);
invocationFuture.complete(response);
delegatingFuture = new ClientDelegatingFuture<>(invocationFuture, serializationService, MapGetCodec::decodeResponse, true);
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocationFuture in project hazelcast by hazelcast.
the class MCTrustedInterfacesTest method assertFailureOnUntrustedInterface.
private void assertFailureOnUntrustedInterface(ClientMessage clientMessage) throws Exception {
ClientInvocation invocation = new ClientInvocation(((HazelcastClientProxy) client).client, clientMessage, null);
ClientInvocationFuture future = invocation.invoke();
try {
future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS);
fail("AccessControlException was expected.");
} catch (ExecutionException e) {
assertThat(e.getCause(), is(instanceOf(AccessControlException.class)));
}
}
Aggregations