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 ClientOwnershipTest method test_clientOwnedByMember.
@Test
public void test_clientOwnedByMember() {
HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
String instanceUuid = instance.getLocalEndpoint().getUuid();
String clientUuid = client.getLocalEndpoint().getUuid();
ClientEngineImpl clientEngine = getClientEngineImpl(instance);
assertEquals(instanceUuid, clientEngine.getOwnerUuid(clientUuid));
}
use of com.hazelcast.client.impl.ClientEngineImpl in project hazelcast by hazelcast.
the class ClientOwnershipTest method test_ownerShip_afterClusterRestart.
@Test
public void test_ownerShip_afterClusterRestart() {
HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setConnectionAttemptLimit(Integer.MAX_VALUE);
final HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
instance.shutdown();
final HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance();
// wait for client to connect to node
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(1, client.getCluster().getMembers().size());
assertEquals(1, instance2.getCluster().getMembers().size());
}
});
final String instanceUuid = instance2.getLocalEndpoint().getUuid();
final ClientEngineImpl clientEngine2 = getClientEngineImpl(instance2);
final String clientUuid = client.getLocalEndpoint().getUuid();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(instanceUuid, clientEngine2.getOwnerUuid(clientUuid));
}
});
}
use of com.hazelcast.client.impl.ClientEngineImpl in project hazelcast by hazelcast.
the class ClientOwnershipTest method test_clientOwnedInfoPropagatedToAllMembers.
@Test
public void test_clientOwnedInfoPropagatedToAllMembers() {
HazelcastInstance instance1 = hazelcastFactory.newHazelcastInstance();
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance();
final String instanceUuid = instance1.getLocalEndpoint().getUuid();
final String clientUuid = client.getLocalEndpoint().getUuid();
final ClientEngineImpl clientEngine1 = getClientEngineImpl(instance1);
final ClientEngineImpl clientEngine2 = getClientEngineImpl(instance2);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(instanceUuid, clientEngine1.getOwnerUuid(clientUuid));
assertEquals(instanceUuid, clientEngine2.getOwnerUuid(clientUuid));
}
});
}
use of com.hazelcast.client.impl.ClientEngineImpl in project hazelcast by hazelcast.
the class ClientOwnershipTest method test_ownerShipRemoved_afterClientDies.
@Test
public void test_ownerShipRemoved_afterClientDies() {
HazelcastInstance instance1 = hazelcastFactory.newHazelcastInstance();
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance();
final String instanceUuid = instance1.getLocalEndpoint().getUuid();
final String clientUuid = client.getLocalEndpoint().getUuid();
final ClientEngineImpl clientEngine1 = getClientEngineImpl(instance1);
final ClientEngineImpl clientEngine2 = getClientEngineImpl(instance2);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(instanceUuid, clientEngine1.getOwnerUuid(clientUuid));
assertEquals(instanceUuid, clientEngine2.getOwnerUuid(clientUuid));
}
});
client.shutdown();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(null, clientEngine1.getOwnerUuid(clientUuid));
assertEquals(null, clientEngine2.getOwnerUuid(clientUuid));
}
});
}
Aggregations