use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class MCMessageTasksTest method testGetMemberConfigMessageTask.
@Test
public void testGetMemberConfigMessageTask() throws Exception {
ClientInvocation invocation = new ClientInvocation(getClientImpl(), MCGetMemberConfigCodec.encodeRequest(), null);
ClientDelegatingFuture<String> future = new ClientDelegatingFuture<>(invocation.invoke(), getClientImpl().getSerializationService(), MCGetMemberConfigCodec::decodeResponse);
assertFalse(isNullOrEmptyAfterTrim(future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, SECONDS)));
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientCacheIterator method fetch.
protected List fetch() {
HazelcastClientInstanceImpl client = (HazelcastClientInstanceImpl) context.getHazelcastInstance();
String name = cacheProxy.getPrefixedName();
if (prefetchValues) {
ClientMessage request = CacheIterateEntriesCodec.encodeRequest(name, encodePointers(pointers), fetchSize);
try {
ClientInvocation clientInvocation = new ClientInvocation(client, request, name, partitionIndex);
ClientInvocationFuture future = clientInvocation.invoke();
CacheIterateEntriesCodec.ResponseParameters responseParameters = CacheIterateEntriesCodec.decodeResponse(future.get());
IterationPointer[] pointers = decodePointers(responseParameters.iterationPointers);
setIterationPointers(responseParameters.entries, pointers);
return responseParameters.entries;
} catch (Exception e) {
throw rethrow(e);
}
} else {
ClientMessage request = CacheIterateCodec.encodeRequest(name, encodePointers(pointers), fetchSize);
try {
ClientInvocation clientInvocation = new ClientInvocation(client, request, name, partitionIndex);
ClientInvocationFuture future = clientInvocation.invoke();
CacheIterateCodec.ResponseParameters responseParameters = CacheIterateCodec.decodeResponse(future.get());
IterationPointer[] pointers = decodePointers(responseParameters.iterationPointers);
setIterationPointers(responseParameters.keys, pointers);
return responseParameters.keys;
} catch (Exception e) {
throw rethrow(e);
}
}
}
use of com.hazelcast.client.impl.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientCacheProxy method subscribeToEventJournal.
@Override
public InternalCompletableFuture<EventJournalInitialSubscriberState> subscribeToEventJournal(int partitionId) {
final ClientMessage request = CacheEventJournalSubscribeCodec.encodeRequest(nameWithPrefix);
final ClientInvocationFuture fut = new ClientInvocation(getClient(), request, getName(), partitionId).invoke();
return new ClientDelegatingFuture<>(fut, getSerializationService(), eventJournalSubscribeResponseDecoder);
}
use of com.hazelcast.client.impl.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, cacheName, partitionId);
Future<ClientMessage> future = clientInvocation.invoke();
ClientMessage responseMessage = future.get();
SerializationService serializationService = client.getSerializationService();
CacheConfigHolder cacheConfigHolder = CacheGetConfigCodec.decodeResponse(responseMessage);
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 ClientCacheHelper method enableStatisticManagementOnNodes.
/**
* Enables/disables statistics or management support of cache on the all servers in the cluster.
*
* @param client the client instance which will send the operation to server
* @param cacheName full cache name with prefixes
* @param statOrMan flag that represents which one of the statistics or management will be enabled
* @param enabled flag which represents whether it is enable or disable
*/
static void enableStatisticManagementOnNodes(HazelcastClientInstanceImpl client, String cacheName, boolean statOrMan, boolean enabled) {
Collection<Member> members = client.getClientClusterService().getMemberList();
Collection<Future> futures = new ArrayList<Future>();
for (Member member : members) {
try {
UUID uuid = member.getUuid();
ClientMessage request = CacheManagementConfigCodec.encodeRequest(cacheName, statOrMan, enabled, uuid);
ClientInvocation clientInvocation = new ClientInvocation(client, request, cacheName, uuid);
Future<ClientMessage> future = clientInvocation.invoke();
futures.add(future);
} catch (Exception e) {
sneakyThrow(e);
}
}
// make sure all configs are created
FutureUtil.waitWithDeadline(futures, CacheProxyUtil.AWAIT_COMPLETION_TIMEOUT_SECONDS, TimeUnit.SECONDS);
}
Aggregations