Search in sources :

Example 6 with ClientConnectionManager

use of com.hazelcast.client.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.MockClientConnectionManager) connectionManager).unblockTo(address);
}
Also used : Address(com.hazelcast.nio.Address) HazelcastClientInstanceImpl(com.hazelcast.client.impl.HazelcastClientInstanceImpl) ClientConnectionManager(com.hazelcast.client.connection.ClientConnectionManager)

Example 7 with ClientConnectionManager

use of com.hazelcast.client.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.MockClientConnectionManager) connectionManager).unblockFrom(address);
}
Also used : Address(com.hazelcast.nio.Address) HazelcastClientInstanceImpl(com.hazelcast.client.impl.HazelcastClientInstanceImpl) ClientConnectionManager(com.hazelcast.client.connection.ClientConnectionManager)

Example 8 with ClientConnectionManager

use of com.hazelcast.client.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.MockClientConnectionManager) connectionManager).blockFrom(address);
}
Also used : Address(com.hazelcast.nio.Address) HazelcastClientInstanceImpl(com.hazelcast.client.impl.HazelcastClientInstanceImpl) ClientConnectionManager(com.hazelcast.client.connection.ClientConnectionManager)

Example 9 with ClientConnectionManager

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

the class NearCachedClientMapProxy method getConnectedServerVersion.

private int getConnectedServerVersion() {
    ClientContext clientContext = getClientContext();
    ClientClusterService clusterService = clientContext.getClusterService();
    Address ownerConnectionAddress = clusterService.getOwnerConnectionAddress();
    HazelcastClientInstanceImpl client = getClient();
    ClientConnectionManager connectionManager = client.getConnectionManager();
    Connection connection = connectionManager.getConnection(ownerConnectionAddress);
    if (connection == null) {
        logger.warning(format("No owner connection is available, " + "near cached cache %s will be started in legacy mode", name));
        return UNKNOWN_HAZELCAST_VERSION;
    }
    return ((ClientConnection) connection).getConnectedServerVersion();
}
Also used : Address(com.hazelcast.nio.Address) ClientContext(com.hazelcast.client.spi.ClientContext) ClientConnection(com.hazelcast.client.connection.nio.ClientConnection) Connection(com.hazelcast.nio.Connection) HazelcastClientInstanceImpl(com.hazelcast.client.impl.HazelcastClientInstanceImpl) ClientConnection(com.hazelcast.client.connection.nio.ClientConnection) ClientConnectionManager(com.hazelcast.client.connection.ClientConnectionManager) ClientClusterService(com.hazelcast.client.spi.ClientClusterService)

Example 10 with ClientConnectionManager

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

the class ProxyManager method getTargetOrOwnerConnection.

private Connection getTargetOrOwnerConnection(final Address target) throws IOException {
    if (target == null) {
        throw new IOException("Not able to setup owner connection!");
    }
    final ClientConnectionManager connectionManager = client.getConnectionManager();
    Connection connection = connectionManager.getConnection(target);
    if (connection == null) {
        final Address ownerConnectionAddress = client.getClientClusterService().getOwnerConnectionAddress();
        if (ownerConnectionAddress == null) {
            throw new IOException("Not able to setup owner connection!");
        }
        connection = connectionManager.getConnection(ownerConnectionAddress);
        if (connection == null) {
            throw new IOException("Client is not connected to member " + target);
        }
    }
    return connection;
}
Also used : Address(com.hazelcast.nio.Address) Connection(com.hazelcast.nio.Connection) IOException(java.io.IOException) ClientConnectionManager(com.hazelcast.client.connection.ClientConnectionManager)

Aggregations

ClientConnectionManager (com.hazelcast.client.connection.ClientConnectionManager)13 HazelcastClientInstanceImpl (com.hazelcast.client.impl.HazelcastClientInstanceImpl)10 Address (com.hazelcast.nio.Address)10 Connection (com.hazelcast.nio.Connection)6 ClientConnection (com.hazelcast.client.connection.nio.ClientConnection)4 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Test (org.junit.Test)4 AssertTask (com.hazelcast.test.AssertTask)3 InetSocketAddress (java.net.InetSocketAddress)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 ClientClusterService (com.hazelcast.client.spi.ClientClusterService)2 ClientContext (com.hazelcast.client.spi.ClientContext)2 ConnectionHeartbeatListener (com.hazelcast.client.spi.impl.ConnectionHeartbeatListener)2 ExecutionException (java.util.concurrent.ExecutionException)2 ClientImpl (com.hazelcast.client.impl.ClientImpl)1 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 ClientMessageReadHandler (com.hazelcast.client.impl.protocol.util.ClientMessageReadHandler)1 EntryAdapter (com.hazelcast.core.EntryAdapter)1