Search in sources :

Example 11 with ClientEngineImpl

use of com.hazelcast.client.impl.ClientEngineImpl in project hazelcast by hazelcast.

the class BackupListenerLeakTest method testBackupListenerRemoved_afterClientShutdown.

@Test
public void testBackupListenerRemoved_afterClientShutdown() {
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.getConnectionStrategyConfig().getConnectionRetryConfig().setClusterConnectTimeoutMillis(Long.MAX_VALUE);
    HazelcastInstance hazelcast = hazelcastFactory.newHazelcastInstance();
    HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
    client.shutdown();
    Map<UUID, Consumer<Long>> backupListeners = ((ClientEngineImpl) getNode(hazelcast).clientEngine).getBackupListeners();
    assertTrueEventually(() -> assertEquals(0, backupListeners.size()));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientEngineImpl(com.hazelcast.client.impl.ClientEngineImpl) Consumer(java.util.function.Consumer) ClientConfig(com.hazelcast.client.config.ClientConfig) UUID(java.util.UUID) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 12 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)

Example 13 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 14 with ClientEngineImpl

use of com.hazelcast.client.impl.ClientEngineImpl in project hazelcast by hazelcast.

the class ClientSelectorManagementCenterClientTest method testManagementCenterClient_doesNotGetDisconnected.

@Test
public void testManagementCenterClient_doesNotGetDisconnected() {
    HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
    final ClientEngineImpl clientEngineImpl = getClientEngineImpl(instance);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setProperty(MC_CLIENT_MODE_PROP.getName(), "true");
    hazelcastFactory.newHazelcastClient(clientConfig);
    clientEngineImpl.applySelector(ClientSelectors.none());
    assertTrueAllTheTime(() -> {
        Collection<ClientEndpoint> endpoints = clientEngineImpl.getEndpointManager().getEndpoints();
        assertEquals(1, endpoints.size());
    }, 10);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientEngineImpl(com.hazelcast.client.impl.ClientEngineImpl) Accessors.getClientEngineImpl(com.hazelcast.test.Accessors.getClientEngineImpl) ClientConfig(com.hazelcast.client.config.ClientConfig) ClientEndpoint(com.hazelcast.client.impl.ClientEndpoint) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 15 with ClientEngineImpl

use of com.hazelcast.client.impl.ClientEngineImpl in project hazelcast by hazelcast.

the class ClientStatisticsTest method testNoUpdateWhenDisabled.

@Test
public void testNoUpdateWhenDisabled() {
    HazelcastInstance hazelcastInstance = hazelcastFactory.newHazelcastInstance();
    final ClientEngineImpl clientEngine = getClientEngineImpl(hazelcastInstance);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.getMetricsConfig().setEnabled(false).setCollectionFrequencySeconds(STATS_PERIOD_SECONDS);
    hazelcastFactory.newHazelcastClient(clientConfig);
    assertTrueAllTheTime(() -> {
        Map<UUID, ClientStatistics> statistics = clientEngine.getClientStatistics();
        assertEquals(0, statistics.size());
    }, STATS_PERIOD_SECONDS * 3);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientEngineImpl(com.hazelcast.client.impl.ClientEngineImpl) Accessors.getClientEngineImpl(com.hazelcast.test.Accessors.getClientEngineImpl) ClientStatistics(com.hazelcast.client.impl.statistics.ClientStatistics) ClientConfig(com.hazelcast.client.config.ClientConfig) UUID(java.util.UUID) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ClientEngineImpl (com.hazelcast.client.impl.ClientEngineImpl)20 HazelcastInstance (com.hazelcast.core.HazelcastInstance)16 Test (org.junit.Test)16 QuickTest (com.hazelcast.test.annotation.QuickTest)15 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)9 Accessors.getClientEngineImpl (com.hazelcast.test.Accessors.getClientEngineImpl)8 ClientConfig (com.hazelcast.client.config.ClientConfig)6 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)6 AssertTask (com.hazelcast.test.AssertTask)6 ParallelTest (com.hazelcast.test.annotation.ParallelTest)6 UUID (java.util.UUID)4 ClientEndpoint (com.hazelcast.client.ClientEndpoint)2 ClientEndpoint (com.hazelcast.client.impl.ClientEndpoint)2 ClientStatistics (com.hazelcast.client.impl.statistics.ClientStatistics)2 Consumer (java.util.function.Consumer)2 AuthenticationException (com.hazelcast.client.AuthenticationException)1 ClientEndpointManagerImpl (com.hazelcast.client.impl.ClientEndpointManagerImpl)1 ClientEndpointStatisticsManagerImpl (com.hazelcast.client.impl.ClientEndpointStatisticsManagerImpl)1 ClientPrincipal (com.hazelcast.client.impl.client.ClientPrincipal)1 ClientTestUtil.getHazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.ClientTestUtil.getHazelcastClientInstanceImpl)1