use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientCacheHelper method createCacheConfig.
/**
* Creates a new cache configuration on Hazelcast members.
*
* @param client the client instance which will send the operation to server
* @param newCacheConfig the cache configuration to be sent to server
* @param <K> type of the key of the cache
* @param <V> type of the value of the cache
* @param urgent whether creating the config is urgent or not(urgent messages can be send in DISCONNECTED state )
* @return the created cache configuration
* @see com.hazelcast.cache.impl.operation.AddCacheConfigOperation
*/
static <K, V> CacheConfig<K, V> createCacheConfig(HazelcastClientInstanceImpl client, CacheConfig<K, V> newCacheConfig, boolean urgent) {
try {
String nameWithPrefix = newCacheConfig.getNameWithPrefix();
int partitionId = client.getClientPartitionService().getPartitionId(nameWithPrefix);
InternalSerializationService serializationService = client.getSerializationService();
ClientMessage request = CacheCreateConfigCodec.encodeRequest(CacheConfigHolder.of(newCacheConfig, serializationService), true);
ClientInvocation clientInvocation = new ClientInvocation(client, request, nameWithPrefix, partitionId);
Future<ClientMessage> future = urgent ? clientInvocation.invokeUrgent() : clientInvocation.invoke();
final ClientMessage response = future.get();
final CacheConfigHolder cacheConfigHolder = CacheCreateConfigCodec.decodeResponse(response);
if (cacheConfigHolder == null) {
return null;
}
return cacheConfigHolder.asCacheConfig(serializationService);
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientCacheProxy method readFromEventJournal.
@Override
public <T> InternalCompletableFuture<ReadResultSet<T>> readFromEventJournal(long startSequence, int minSize, int maxSize, int partitionId, Predicate<? super EventJournalCacheEvent<K, V>> predicate, Function<? super EventJournalCacheEvent<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 = CacheEventJournalReadCodec.encodeRequest(nameWithPrefix, startSequence, minSize, maxSize, ss.toData(predicate), ss.toData(projection));
final ClientInvocationFuture fut = new ClientInvocation(getClient(), request, getName(), partitionId).invoke();
return new ClientDelegatingFuture<>(fut, ss, eventJournalReadResponseDecoder);
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientCacheProxySupport method invoke.
private ClientMessage invoke(ClientMessage clientMessage, Data keyData) {
try {
int partitionId = getContext().getPartitionService().getPartitionId(keyData);
Future future = new ClientInvocation(getClient(), clientMessage, getName(), partitionId).invoke();
return (ClientMessage) future.get();
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientCacheInvalidationMetaDataFetcher method fetchMetadataOf.
@Override
protected InternalCompletableFuture fetchMetadataOf(Member member, List<String> names) {
ClientMessage message = encodeRequest(names, member.getUuid());
ClientInvocation invocation = new ClientInvocation(clientImpl, message, null, member.getUuid());
return invocation.invoke();
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class CountDownLatchProxy method await.
@Override
public boolean await(long timeout, TimeUnit unit) {
checkNotNull(unit);
long timeoutMillis = Math.max(0, unit.toMillis(timeout));
ClientMessage request = CountDownLatchAwaitCodec.encodeRequest(groupId, objectName, newUnsecureUUID(), timeoutMillis);
ClientMessage response = new ClientInvocation(getClient(), request, name).invoke().joinInternal();
return CountDownLatchAwaitCodec.decodeResponse(response);
}
Aggregations