Search in sources :

Example 1 with ClientEndpoint

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

the class ClientSelectorRaceTest method testConcurrency.

@Test
public void testConcurrency() throws InterruptedException {
    HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
    final ClientEngineImpl clientEngineImpl = getClientEngineImpl(instance);
    LinkedList<Thread> threads = new LinkedList<Thread>();
    int numberOfClients = 100;
    for (int i = 0; i < numberOfClients; i++) {
        Thread thread = new Thread(hazelcastFactory::newHazelcastClient);
        thread.start();
        threads.add(thread);
    }
    clientEngineImpl.applySelector(ClientSelectors.none());
    for (Thread thread : threads) {
        thread.join();
    }
    assertTrueEventually(() -> {
        Collection<ClientEndpoint> endpoints = clientEngineImpl.getEndpointManager().getEndpoints();
        assertEquals(0, endpoints.size());
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientEngineImpl(com.hazelcast.client.impl.ClientEngineImpl) Accessors.getClientEngineImpl(com.hazelcast.test.Accessors.getClientEngineImpl) ClientEndpoint(com.hazelcast.client.impl.ClientEndpoint) LinkedList(java.util.LinkedList) ClientEndpoint(com.hazelcast.client.impl.ClientEndpoint) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with ClientEndpoint

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

the class ClientMessageDecoder method isEndpointTrusted.

private boolean isEndpointTrusted() {
    if (clientEndpointManager == null || clientIsTrusted) {
        return true;
    }
    ClientEndpoint endpoint = clientEndpointManager.getEndpoint(connection);
    clientIsTrusted = endpoint != null && endpoint.isAuthenticated();
    return clientIsTrusted;
}
Also used : ClientEndpoint(com.hazelcast.client.impl.ClientEndpoint)

Example 3 with ClientEndpoint

use of com.hazelcast.client.impl.ClientEndpoint 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)

Aggregations

ClientEndpoint (com.hazelcast.client.impl.ClientEndpoint)3 ClientEngineImpl (com.hazelcast.client.impl.ClientEngineImpl)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 Accessors.getClientEngineImpl (com.hazelcast.test.Accessors.getClientEngineImpl)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 ClientConfig (com.hazelcast.client.config.ClientConfig)1 LinkedList (java.util.LinkedList)1