use of com.hazelcast.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientMapPartitionIterator method fetchWithoutPrefetchValues.
private List fetchWithoutPrefetchValues(HazelcastClientInstanceImpl client) {
ClientMessage request = MapFetchKeysCodec.encodeRequest(mapProxy.getName(), partitionId, lastTableIndex, fetchSize);
ClientInvocation clientInvocation = new ClientInvocation(client, request, partitionId);
try {
ClientInvocationFuture f = clientInvocation.invoke();
MapFetchKeysCodec.ResponseParameters responseParameters = MapFetchKeysCodec.decodeResponse(f.get());
setLastTableIndex(responseParameters.keys, responseParameters.tableIndex);
return responseParameters.keys;
} catch (Exception e) {
throw ExceptionUtil.rethrow(e);
}
}
use of com.hazelcast.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientMapMetaDataFetcher method assignAndGetUuids.
@Override
public List<Map.Entry<Integer, UUID>> assignAndGetUuids() throws Exception {
ClientMessage request = MapAssignAndGetUuidsCodec.encodeRequest();
ClientInvocation invocation = new ClientInvocation(clientImpl, request);
MapAssignAndGetUuidsCodec.ResponseParameters responseParameters = MapAssignAndGetUuidsCodec.decodeResponse(invocation.invoke().get());
return responseParameters.partitionUuidList;
}
use of com.hazelcast.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientMapMetaDataFetcher method scanMembers.
@Override
protected List<InternalCompletableFuture> scanMembers(List<String> names) {
Collection<Member> members = clusterService.getMembers(DATA_MEMBER_SELECTOR);
List<InternalCompletableFuture> futures = new ArrayList<InternalCompletableFuture>(members.size());
for (Member member : members) {
Address address = member.getAddress();
ClientMessage message = encodeRequest(names, address);
ClientInvocation invocation = new ClientInvocation(clientImpl, message, address);
try {
futures.add(invocation.invoke());
} catch (Exception e) {
if (logger.isWarningEnabled()) {
logger.warning("Cant fetch invalidation meta-data from address + " + address + " + [" + e.getMessage() + "]");
}
}
}
return futures;
}
use of com.hazelcast.client.spi.impl.ClientInvocation in project hazelcast by hazelcast.
the class ClientConnectionManagerImpl method authenticate.
private void authenticate(final Address target, final ClientConnection connection, final boolean asOwner, final AuthenticationFuture callback) {
SerializationService ss = client.getSerializationService();
final ClientClusterServiceImpl clusterService = (ClientClusterServiceImpl) client.getClientClusterService();
final ClientPrincipal principal = clusterService.getPrincipal();
byte serializationVersion = ((InternalSerializationService) client.getSerializationService()).getVersion();
String uuid = null;
String ownerUuid = null;
if (principal != null) {
uuid = principal.getUuid();
ownerUuid = principal.getOwnerUuid();
}
ClientMessage clientMessage = encodeAuthenticationRequest(asOwner, ss, serializationVersion, uuid, ownerUuid);
ClientInvocation clientInvocation = new ClientInvocation(client, clientMessage, connection);
ClientInvocationFuture future = clientInvocation.invokeUrgent();
if (asOwner && clientInvocation.getSendConnection() != null) {
correlationIddOfLastAuthentication.set(clientInvocation.getClientMessage().getCorrelationId());
}
future.andThen(new ExecutionCallback<ClientMessage>() {
@Override
public void onResponse(ClientMessage response) {
ClientAuthenticationCodec.ResponseParameters result = ClientAuthenticationCodec.decodeResponse(response);
AuthenticationStatus authenticationStatus = AuthenticationStatus.getById(result.status);
switch(authenticationStatus) {
case AUTHENTICATED:
connection.setConnectedServerVersion(result.serverHazelcastVersion);
connection.setRemoteEndpoint(result.address);
if (asOwner) {
if (!(correlationIddOfLastAuthentication.get() == response.getCorrelationId())) {
//if not same, client already gave up on this and send another authentication.
onFailure(new AuthenticationException("Owner authentication response from address " + target + " is late. Dropping the response. Principal : " + principal));
return;
}
connection.setIsAuthenticatedAsOwner();
ClientPrincipal principal = new ClientPrincipal(result.uuid, result.ownerUuid);
clusterService.setPrincipal(principal);
clusterService.setOwnerConnectionAddress(connection.getEndPoint());
logger.info("Setting " + connection + " as owner with principal " + principal);
}
onAuthenticated(target, connection);
callback.onSuccess(connection, asOwner);
break;
case CREDENTIALS_FAILED:
onFailure(new AuthenticationException("Invalid credentials! Principal: " + principal));
break;
default:
onFailure(new AuthenticationException("Authentication status code not supported. status: " + authenticationStatus));
}
}
@Override
public void onFailure(Throwable t) {
onAuthenticationFailed(target, connection, t);
callback.onFailure(t);
}
});
}
use of com.hazelcast.client.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 {
Address address = member.getAddress();
ClientMessage request = CacheManagementConfigCodec.encodeRequest(cacheName, statOrMan, enabled, address);
ClientInvocation clientInvocation = new ClientInvocation(client, request, address);
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