Search in sources :

Example 1 with HazelcastClientInstanceImpl

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

the class ClientTestSupport method blockMessagesFromInstance.

/**
 * Blocks incoming messages to client from given instance
 */
protected void blockMessagesFromInstance(HazelcastInstance instance, HazelcastInstance client) {
    HazelcastClientInstanceImpl clientImpl = getHazelcastClientInstanceImpl(client);
    ClientConnectionManager connectionManager = clientImpl.getConnectionManager();
    Address address = instance.getCluster().getLocalMember().getAddress();
    ((TestClientRegistry.MockTcpClientConnectionManager) connectionManager).blockFrom(address);
}
Also used : Address(com.hazelcast.cluster.Address) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) ClientConnectionManager(com.hazelcast.client.impl.connection.ClientConnectionManager)

Example 2 with HazelcastClientInstanceImpl

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

the class ClientTestSupport method unblockMessagesToInstance.

/**
 * Unblocks outgoing messages from client to given instance
 */
protected void unblockMessagesToInstance(HazelcastInstance instance, HazelcastInstance client) {
    HazelcastClientInstanceImpl clientImpl = getHazelcastClientInstanceImpl(client);
    ClientConnectionManager connectionManager = clientImpl.getConnectionManager();
    Address address = instance.getCluster().getLocalMember().getAddress();
    ((TestClientRegistry.MockTcpClientConnectionManager) connectionManager).unblockTo(address);
}
Also used : Address(com.hazelcast.cluster.Address) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) ClientConnectionManager(com.hazelcast.client.impl.connection.ClientConnectionManager)

Example 3 with HazelcastClientInstanceImpl

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

the class ClientTestSupport method unblockMessagesFromInstance.

/**
 * Unblocks incoming messages to client from given instance
 */
protected void unblockMessagesFromInstance(HazelcastInstance instance, HazelcastInstance client) {
    HazelcastClientInstanceImpl clientImpl = getHazelcastClientInstanceImpl(client);
    ClientConnectionManager connectionManager = clientImpl.getConnectionManager();
    Address address = instance.getCluster().getLocalMember().getAddress();
    ((TestClientRegistry.MockTcpClientConnectionManager) connectionManager).unblockFrom(address);
}
Also used : Address(com.hazelcast.cluster.Address) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) ClientConnectionManager(com.hazelcast.client.impl.connection.ClientConnectionManager)

Example 4 with HazelcastClientInstanceImpl

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

the class HazelcastClient method shutdownAll.

/**
 * Shuts down all the client HazelcastInstance created in this JVM.
 * <p>
 * To be more precise it shuts down the HazelcastInstances loaded using the same classloader this HazelcastClient has been
 * loaded with.
 * <p>
 * This method is mostly used for testing purposes.
 *
 * @see #getAllHazelcastClients()
 */
public static void shutdownAll() {
    for (InstanceFuture<HazelcastClientProxy> future : CLIENTS.values()) {
        try {
            HazelcastClientProxy proxy = future.get();
            HazelcastClientInstanceImpl client = proxy.client;
            if (client == null) {
                continue;
            }
            proxy.client = null;
            client.shutdown();
        } catch (Throwable ignored) {
            EmptyStatement.ignore(ignored);
        }
    }
    OutOfMemoryErrorDispatcher.clearClients();
    CLIENTS.clear();
}
Also used : HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy)

Example 5 with HazelcastClientInstanceImpl

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

the class HazelcastClient method shutdown.

/**
 * Shutdown the provided client and remove it from the managed list
 *
 * @param instanceName the hazelcast client instance name
 */
public static void shutdown(String instanceName) {
    InstanceFuture<HazelcastClientProxy> future = CLIENTS.remove(instanceName);
    if (future == null || !future.isSet()) {
        return;
    }
    HazelcastClientProxy proxy = future.get();
    HazelcastClientInstanceImpl client = proxy.client;
    if (client == null) {
        return;
    }
    proxy.client = null;
    try {
        client.shutdown();
    } catch (Throwable ignored) {
        EmptyStatement.ignore(ignored);
    } finally {
        OutOfMemoryErrorDispatcher.deregisterClient(client);
    }
}
Also used : HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy)

Aggregations

HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)59 Test (org.junit.Test)24 HazelcastInstance (com.hazelcast.core.HazelcastInstance)23 QuickTest (com.hazelcast.test.annotation.QuickTest)23 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)21 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)19 ClientInvocation (com.hazelcast.client.impl.spi.impl.ClientInvocation)15 UUID (java.util.UUID)14 ClientConfig (com.hazelcast.client.config.ClientConfig)11 ClientConnectionManager (com.hazelcast.client.impl.connection.ClientConnectionManager)9 HazelcastClientProxy (com.hazelcast.client.impl.clientside.HazelcastClientProxy)7 ClientEngineImpl (com.hazelcast.client.impl.ClientEngineImpl)6 UuidUtil.newUnsecureUUID (com.hazelcast.internal.util.UuidUtil.newUnsecureUUID)6 CountDownLatch (java.util.concurrent.CountDownLatch)5 TcpClientConnectionManager (com.hazelcast.client.impl.connection.tcp.TcpClientConnectionManager)4 Address (com.hazelcast.cluster.Address)4 SessionExpiredException (com.hazelcast.cp.internal.session.SessionExpiredException)4 Accessors.getClientEngineImpl (com.hazelcast.test.Accessors.getClientEngineImpl)4 LoadBalancer (com.hazelcast.client.LoadBalancer)3 MCClusterMetadata (com.hazelcast.client.impl.management.MCClusterMetadata)3