Search in sources :

Example 36 with HazelcastClientInstanceImpl

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

the class HazelcastClientManager method shutdown.

public static void shutdown(HazelcastInstance instance) {
    if (instance instanceof HazelcastClientProxy) {
        final HazelcastClientProxy proxy = (HazelcastClientProxy) instance;
        HazelcastClientInstanceImpl client = proxy.client;
        if (client == null) {
            return;
        }
        proxy.client = null;
        INSTANCE.clients.remove(client.getName());
        try {
            client.shutdown();
        } catch (Throwable ignored) {
            EmptyStatement.ignore(ignored);
        } finally {
            OutOfMemoryErrorDispatcher.deregisterClient(client);
        }
    }
}
Also used : HazelcastClientInstanceImpl(com.hazelcast.client.impl.HazelcastClientInstanceImpl) HazelcastClientProxy(com.hazelcast.client.impl.HazelcastClientProxy)

Example 37 with HazelcastClientInstanceImpl

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

the class AbstractClientCacheProxyBase method invoke.

protected ClientMessage invoke(ClientMessage clientMessage, Data keyData) {
    try {
        int partitionId = clientContext.getPartitionService().getPartitionId(keyData);
        Future future = new ClientInvocation((HazelcastClientInstanceImpl) clientContext.getHazelcastInstance(), clientMessage, partitionId).invoke();
        return (ClientMessage) future.get();
    } catch (Exception e) {
        throw rethrow(e);
    }
}
Also used : ClientDelegatingFuture(com.hazelcast.client.util.ClientDelegatingFuture) Future(java.util.concurrent.Future) ClientInvocationFuture(com.hazelcast.client.spi.impl.ClientInvocationFuture) HazelcastClientInstanceImpl(com.hazelcast.client.impl.HazelcastClientInstanceImpl) ClientInvocation(com.hazelcast.client.spi.impl.ClientInvocation) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) CacheException(javax.cache.CacheException) ExecutionException(java.util.concurrent.ExecutionException)

Example 38 with HazelcastClientInstanceImpl

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

the class ClientNearCacheInvalidationTest method registerInvalidationListener.

private void registerInvalidationListener(AtomicInteger counter) {
    EventHandler handler = new NearCacheRepairingHandler(counter);
    ListenerMessageCodec listenerCodec = createInvalidationListenerCodec();
    final HazelcastClientInstanceImpl clientInstance = testContext.client.client;
    clientInstance.getListenerService().registerListener(listenerCodec, handler);
}
Also used : ListenerMessageCodec(com.hazelcast.client.spi.impl.ListenerMessageCodec) EventHandler(com.hazelcast.client.spi.EventHandler) HazelcastClientInstanceImpl(com.hazelcast.client.impl.HazelcastClientInstanceImpl)

Example 39 with HazelcastClientInstanceImpl

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

the class ProxyManagerTest method testNextAddressToSendCreateRequestOnMultipleDataMembers.

@Test
public void testNextAddressToSendCreateRequestOnMultipleDataMembers() {
    final List<HazelcastInstance> instances = createNodes(3, 3);
    final HazelcastInstance client = factory.newHazelcastClient();
    final HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client);
    Set<Address> addresses = new HashSet<Address>();
    final ProxyManager proxyManager = clientInstanceImpl.getProxyManager();
    for (int i = 0; i < instances.size() * 100; i++) {
        addresses.add(proxyManager.findNextAddressToSendCreateRequest());
    }
    assertEquals(3, addresses.size());
    for (HazelcastInstance lite : instances.subList(3, 6)) {
        assertContains(addresses, getAddress(lite));
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.nio.Address) ProxyManager(com.hazelcast.client.spi.ProxyManager) HazelcastClientInstanceImpl(com.hazelcast.client.impl.HazelcastClientInstanceImpl) ClientTestUtil.getHazelcastClientInstanceImpl(com.hazelcast.client.impl.ClientTestUtil.getHazelcastClientInstanceImpl) HashSet(java.util.HashSet) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 40 with HazelcastClientInstanceImpl

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

the class ProxyManagerTest method testNextAddressToSendCreateRequestOnSingleDataMember.

@Test
public void testNextAddressToSendCreateRequestOnSingleDataMember() {
    final List<HazelcastInstance> instances = createNodes(3, 1);
    final Address dataInstanceAddress = getAddress(instances.get(3));
    final HazelcastInstance client = factory.newHazelcastClient();
    final HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client);
    final ProxyManager proxyManager = clientInstanceImpl.getProxyManager();
    for (int i = 0; i < instances.size(); i++) {
        assertEquals(dataInstanceAddress, proxyManager.findNextAddressToSendCreateRequest());
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.nio.Address) ProxyManager(com.hazelcast.client.spi.ProxyManager) HazelcastClientInstanceImpl(com.hazelcast.client.impl.HazelcastClientInstanceImpl) ClientTestUtil.getHazelcastClientInstanceImpl(com.hazelcast.client.impl.ClientTestUtil.getHazelcastClientInstanceImpl) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

HazelcastClientInstanceImpl (com.hazelcast.client.impl.HazelcastClientInstanceImpl)40 HazelcastInstance (com.hazelcast.core.HazelcastInstance)15 Address (com.hazelcast.nio.Address)14 Test (org.junit.Test)12 ParallelTest (com.hazelcast.test.annotation.ParallelTest)11 QuickTest (com.hazelcast.test.annotation.QuickTest)11 ClientConnectionManager (com.hazelcast.client.connection.ClientConnectionManager)10 ClientInvocation (com.hazelcast.client.spi.impl.ClientInvocation)9 CountDownLatch (java.util.concurrent.CountDownLatch)9 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)7 ClientInvocationFuture (com.hazelcast.client.spi.impl.ClientInvocationFuture)7 HazelcastClientProxy (com.hazelcast.client.impl.HazelcastClientProxy)6 Connection (com.hazelcast.nio.Connection)6 ClientConfig (com.hazelcast.client.config.ClientConfig)5 ClientTestUtil.getHazelcastClientInstanceImpl (com.hazelcast.client.impl.ClientTestUtil.getHazelcastClientInstanceImpl)5 LifecycleEvent (com.hazelcast.core.LifecycleEvent)5 LifecycleListener (com.hazelcast.core.LifecycleListener)5 ClientConnection (com.hazelcast.client.connection.nio.ClientConnection)4 AssertTask (com.hazelcast.test.AssertTask)4 CacheException (javax.cache.CacheException)4