use of com.hazelcast.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientCacheHelper method getCacheConfig.
/**
* Gets the cache configuration from the server.
*
* @param client the client instance which will send the operation to server
* @param cacheName full cache name with prefixes
* @param simpleCacheName pure cache name without any prefix
* @param <K> type of the key of the cache
* @param <V> type of the value of the cache
* @return the cache configuration if it can be found
*/
static <K, V> CacheConfig<K, V> getCacheConfig(HazelcastClientInstanceImpl client, String cacheName, String simpleCacheName) {
ClientMessage request = CacheGetConfigCodec.encodeRequest(cacheName, simpleCacheName);
try {
int partitionId = client.getClientPartitionService().getPartitionId(cacheName);
ClientInvocation clientInvocation = new ClientInvocation(client, request, partitionId);
Future<ClientMessage> future = clientInvocation.invoke();
ClientMessage responseMessage = future.get();
SerializationService serializationService = client.getSerializationService();
return deserializeCacheConfig(client, responseMessage, serializationService, clientInvocation);
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientInvokerWrapper method invokeOnAllPartitions.
@Override
public Object invokeOnAllPartitions(Object request) {
try {
ClientMessage clientRequest = (ClientMessage) request;
final Future future = new ClientInvocation(getClient(), clientRequest).invoke();
Object result = future.get();
return context.toObject(result);
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientInvokerWrapper method invokeOnPartitionOwner.
@Override
public Future invokeOnPartitionOwner(Object request, int partitionId) {
checkNotNull(request, "request cannot be null");
checkNotNegative(partitionId, "partitionId");
ClientMessage clientRequest = (ClientMessage) request;
ClientInvocation clientInvocation = new ClientInvocation(getClient(), clientRequest, partitionId);
return clientInvocation.invoke();
}
use of com.hazelcast.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientDurableExecutorServiceProxy method submitToPartition.
private <T> DurableExecutorServiceFuture<T> submitToPartition(Callable<T> task, int partitionId, T result) {
checkNotNull(task, "task should not be null");
SerializationService serService = getSerializationService();
ClientMessage request = DurableExecutorSubmitToPartitionCodec.encodeRequest(name, serService.toData(task));
int sequence;
try {
ClientMessage response = invokeOnPartition(request, partitionId);
sequence = DurableExecutorSubmitToPartitionCodec.decodeResponse(response).response;
} catch (Throwable t) {
return new ClientDurableExecutorServiceCompletedFuture<T>(t, getUserExecutor());
}
ClientMessage clientMessage = DurableExecutorRetrieveResultCodec.encodeRequest(name, sequence);
ClientInvocationFuture future = new ClientInvocation(getClient(), clientMessage, partitionId).invoke();
long taskId = Bits.combineToLong(partitionId, sequence);
return new ClientDurableExecutorServiceDelegatingFuture<T>(future, serService, RETRIEVE_RESPONSE_DECODER, result, taskId);
}
use of com.hazelcast.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientNonSmartListenerService method invoke.
private ClientEventRegistration invoke(ClientRegistrationKey registrationKey) throws Exception {
EventHandler handler = registrationKey.getHandler();
handler.beforeListenerRegister();
ClientMessage request = registrationKey.getCodec().encodeAddRequest(false);
ClientInvocation invocation = new ClientInvocation(client, request);
invocation.setEventHandler(handler);
ClientInvocationFuture future = invocation.invoke();
String registrationId = registrationKey.getCodec().decodeAddResponse(future.get());
handler.onListenerRegister();
Connection connection = future.getInvocation().getSendConnection();
return new ClientEventRegistration(registrationId, request.getCorrelationId(), connection, registrationKey.getCodec());
}
Aggregations