Search in sources :

Example 6 with ClientClusterService

use of com.hazelcast.client.spi.ClientClusterService in project hazelcast by hazelcast.

the class ClientNonSmartInvocationServiceImpl method sendToOwner.

private void sendToOwner(ClientInvocation invocation) throws IOException {
    ClientClusterService clusterService = client.getClientClusterService();
    Address ownerConnectionAddress = clusterService.getOwnerConnectionAddress();
    if (ownerConnectionAddress == null) {
        throw new IOException("Packet is not send to owner address");
    }
    Connection conn = connectionManager.getConnection(ownerConnectionAddress);
    if (conn == null) {
        throw new IOException("Packet is not sent to owner address: " + ownerConnectionAddress);
    }
    send(invocation, (ClientConnection) conn);
}
Also used : Address(com.hazelcast.nio.Address) ClientConnection(com.hazelcast.client.connection.nio.ClientConnection) Connection(com.hazelcast.nio.Connection) IOException(java.io.IOException) ClientClusterService(com.hazelcast.client.spi.ClientClusterService)

Example 7 with ClientClusterService

use of com.hazelcast.client.spi.ClientClusterService in project hazelcast by hazelcast.

the class ClientSmartInvocationServiceImpl method ensureOwnerConnectionAvailable.

private void ensureOwnerConnectionAvailable() throws IOException {
    ClientClusterService clientClusterService = client.getClientClusterService();
    Address ownerConnectionAddress = clientClusterService.getOwnerConnectionAddress();
    boolean isOwnerConnectionAvailable = ownerConnectionAddress != null && connectionManager.getConnection(ownerConnectionAddress) != null;
    if (!isOwnerConnectionAvailable) {
        if (isShutdown()) {
            throw new HazelcastException("ConnectionManager is not active!");
        }
        throw new IOException("Not able to setup owner connection!");
    }
}
Also used : HazelcastException(com.hazelcast.core.HazelcastException) Address(com.hazelcast.nio.Address) IOException(java.io.IOException) ClientClusterService(com.hazelcast.client.spi.ClientClusterService)

Aggregations

ClientClusterService (com.hazelcast.client.spi.ClientClusterService)7 Address (com.hazelcast.nio.Address)6 ClientConnection (com.hazelcast.client.connection.nio.ClientConnection)4 Connection (com.hazelcast.nio.Connection)4 IOException (java.io.IOException)3 ClientConnectionManager (com.hazelcast.client.connection.ClientConnectionManager)2 HazelcastClientInstanceImpl (com.hazelcast.client.impl.HazelcastClientInstanceImpl)2 ClientContext (com.hazelcast.client.spi.ClientContext)2 HazelcastException (com.hazelcast.core.HazelcastException)1 Member (com.hazelcast.core.Member)1 Collection (java.util.Collection)1