use of com.hazelcast.client.impl.ClientEngineImpl in project hazelcast by hazelcast.
the class ClientReAuthOperation method run.
@Override
public void run() throws Exception {
ClientEngineImpl engine = getService();
String memberUuid = getCallerUuid();
if (!engine.trySetLastAuthenticationCorrelationId(clientUuid, authCorrelationId)) {
String message = "Server already processed a newer authentication from client with uuid " + clientUuid + ". Not applying requested ownership change to " + memberUuid;
getLogger().info(message);
throw new AuthenticationException(message);
}
Set<ClientEndpoint> endpoints = engine.getEndpointManager().getEndpoints(clientUuid);
for (ClientEndpoint endpoint : endpoints) {
ClientPrincipal principal = new ClientPrincipal(clientUuid, memberUuid);
endpoint.authenticated(principal);
}
String previousMemberUuid = engine.addOwnershipMapping(clientUuid, memberUuid);
clientDisconnectOperationRun = previousMemberUuid == null;
}
use of com.hazelcast.client.impl.ClientEngineImpl in project hazelcast by hazelcast.
the class GetConnectedClientsOperation method run.
@Override
public void run() throws Exception {
ClientEngineImpl service = getService();
this.clients = new HashMap<String, ClientType>();
for (Client clientEndpoint : service.getClients()) {
ClientEndpointImpl clientEndpointImpl = (ClientEndpointImpl) clientEndpoint;
this.clients.put(clientEndpointImpl.getUuid(), clientEndpointImpl.getClientType());
}
}
use of com.hazelcast.client.impl.ClientEngineImpl in project hazelcast by hazelcast.
the class ClientOwnershipTest method test_clientOwnedBySecondMember_afterFirstOwnerDies.
@Test
public void test_clientOwnedBySecondMember_afterFirstOwnerDies() {
HazelcastInstance instance1 = hazelcastFactory.newHazelcastInstance();
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance();
instance1.shutdown();
final String instance2Uuid = instance2.getLocalEndpoint().getUuid();
final String clientUuid = client.getLocalEndpoint().getUuid();
final ClientEngineImpl clientEngine = getClientEngineImpl(instance2);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(instance2Uuid, clientEngine.getOwnerUuid(clientUuid));
}
});
}
use of com.hazelcast.client.impl.ClientEngineImpl in project hazelcast by hazelcast.
the class ClientDisconnectionOperation method run.
@Override
public void run() throws Exception {
ClientEngineImpl engine = getService();
final ClientEndpointManagerImpl endpointManager = (ClientEndpointManagerImpl) engine.getEndpointManager();
if (!engine.removeOwnershipMapping(clientUuid, memberUuid)) {
return;
}
Set<ClientEndpoint> endpoints = endpointManager.getEndpoints(clientUuid);
// This part cleans up listener and transactions
for (ClientEndpoint endpoint : endpoints) {
endpoint.getConnection().close("ClientDisconnectionOperation: Client disconnected from cluster", null);
}
// This part cleans up locks conditions semaphore etc..
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
nodeEngine.onClientDisconnected(clientUuid);
Collection<ClientAwareService> services = nodeEngine.getServices(ClientAwareService.class);
for (ClientAwareService service : services) {
service.clientDisconnected(clientUuid);
}
}
Aggregations