Search in sources :

Example 6 with ClientEngineImpl

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;
}
Also used : ClientEngineImpl(com.hazelcast.client.impl.ClientEngineImpl) AuthenticationException(com.hazelcast.client.AuthenticationException) ClientEndpoint(com.hazelcast.client.ClientEndpoint) ClientPrincipal(com.hazelcast.client.impl.client.ClientPrincipal)

Example 7 with ClientEngineImpl

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());
    }
}
Also used : ClientType(com.hazelcast.core.ClientType) ClientEngineImpl(com.hazelcast.client.impl.ClientEngineImpl) ClientEndpointImpl(com.hazelcast.client.impl.ClientEndpointImpl) Client(com.hazelcast.core.Client)

Example 8 with ClientEngineImpl

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));
        }
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientEngineImpl(com.hazelcast.client.impl.ClientEngineImpl) AssertTask(com.hazelcast.test.AssertTask) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 9 with ClientEngineImpl

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);
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ClientAwareService(com.hazelcast.spi.ClientAwareService) ClientEndpointManagerImpl(com.hazelcast.client.impl.ClientEndpointManagerImpl) ClientEngineImpl(com.hazelcast.client.impl.ClientEngineImpl) ClientEndpoint(com.hazelcast.client.ClientEndpoint)

Aggregations

ClientEngineImpl (com.hazelcast.client.impl.ClientEngineImpl)9 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 ParallelTest (com.hazelcast.test.annotation.ParallelTest)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Test (org.junit.Test)6 AssertTask (com.hazelcast.test.AssertTask)5 ClientEndpoint (com.hazelcast.client.ClientEndpoint)2 AuthenticationException (com.hazelcast.client.AuthenticationException)1 ClientConfig (com.hazelcast.client.config.ClientConfig)1 ClientEndpointImpl (com.hazelcast.client.impl.ClientEndpointImpl)1 ClientEndpointManagerImpl (com.hazelcast.client.impl.ClientEndpointManagerImpl)1 ClientPrincipal (com.hazelcast.client.impl.client.ClientPrincipal)1 Client (com.hazelcast.core.Client)1 ClientType (com.hazelcast.core.ClientType)1 IExecutorService (com.hazelcast.core.IExecutorService)1 ClientAwareService (com.hazelcast.spi.ClientAwareService)1 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)1