Search in sources :

Example 1 with ClientConnectionManager

use of com.hazelcast.client.impl.connection.ClientConnectionManager 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 ClientConnectionManager

use of com.hazelcast.client.impl.connection.ClientConnectionManager 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 ClientConnectionManager

use of com.hazelcast.client.impl.connection.ClientConnectionManager in project hazelcast by hazelcast.

the class ClientTestSupport method getAllEventHandlers.

protected Map<Long, EventHandler> getAllEventHandlers(HazelcastInstance client) {
    ClientConnectionManager connectionManager = getHazelcastClientInstanceImpl(client).getConnectionManager();
    Collection<Connection> activeConnections = connectionManager.getActiveConnections();
    HashMap<Long, EventHandler> map = new HashMap<>();
    for (Connection activeConnection : activeConnections) {
        map.putAll(((ClientConnection) activeConnection).getEventHandlers());
    }
    return map;
}
Also used : HashMap(java.util.HashMap) ClientConnection(com.hazelcast.client.impl.connection.ClientConnection) Connection(com.hazelcast.internal.nio.Connection) EventHandler(com.hazelcast.client.impl.spi.EventHandler) ClientConnectionManager(com.hazelcast.client.impl.connection.ClientConnectionManager)

Example 4 with ClientConnectionManager

use of com.hazelcast.client.impl.connection.ClientConnectionManager 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 5 with ClientConnectionManager

use of com.hazelcast.client.impl.connection.ClientConnectionManager in project hazelcast by hazelcast.

the class ClientTestSupport method makeSureDisconnectedFromServer.

public static void makeSureDisconnectedFromServer(final HazelcastInstance client, UUID memberUUID) {
    assertTrueEventually(() -> {
        ClientConnectionManager connectionManager = getHazelcastClientInstanceImpl(client).getConnectionManager();
        assertNull(connectionManager.getConnection(memberUUID));
    });
}
Also used : ClientConnectionManager(com.hazelcast.client.impl.connection.ClientConnectionManager)

Aggregations

ClientConnectionManager (com.hazelcast.client.impl.connection.ClientConnectionManager)14 HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 Address (com.hazelcast.cluster.Address)4 ClientConfig (com.hazelcast.client.config.ClientConfig)3 Connection (com.hazelcast.internal.nio.Connection)3 AssertTask (com.hazelcast.test.AssertTask)3 AbstractLoadBalancer (com.hazelcast.client.util.AbstractLoadBalancer)2 Member (com.hazelcast.cluster.Member)2 TransactionContext (com.hazelcast.transaction.TransactionContext)2 UUID (java.util.UUID)2 ClientConnectionStrategyConfig (com.hazelcast.client.config.ClientConnectionStrategyConfig)1 ClientNetworkConfig (com.hazelcast.client.config.ClientNetworkConfig)1 ClientImpl (com.hazelcast.client.impl.ClientImpl)1 ClientConnection (com.hazelcast.client.impl.connection.ClientConnection)1 TcpClientConnection (com.hazelcast.client.impl.connection.tcp.TcpClientConnection)1 TcpClientConnectionManager (com.hazelcast.client.impl.connection.tcp.TcpClientConnectionManager)1