Search in sources :

Example 1 with ClientClusterService

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

the class AbstractClientInternalCacheProxy method getConnectedServerVersion.

private int getConnectedServerVersion() {
    ClientContext clientContext = getContext();
    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 2 with ClientClusterService

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

the class ClientSmartListenerService method start.

@Override
public void start() {
    clientConnectionManager.addConnectionListener(this);
    clientConnectionManager.addConnectionHeartbeatListener(this);
    final ClientClusterService clientClusterService = client.getClientClusterService();
    registrationExecutor.scheduleWithFixedDelay(new Runnable() {

        @Override
        public void run() {
            Collection<Member> memberList = clientClusterService.getMemberList();
            for (Member member : memberList) {
                clientConnectionManager.getOrTriggerConnect(member.getAddress(), false);
            }
        }
    }, 1, 1, TimeUnit.SECONDS);
}
Also used : Collection(java.util.Collection) Member(com.hazelcast.core.Member) ClientClusterService(com.hazelcast.client.spi.ClientClusterService)

Example 3 with ClientClusterService

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

the class ClientNonSmartInvocationServiceImpl method getConnection.

@Override
public ClientConnection getConnection(int partitionId) throws IOException {
    ClientClusterService clusterService = client.getClientClusterService();
    Address ownerConnectionAddress = clusterService.getOwnerConnectionAddress();
    if (ownerConnectionAddress == null) {
        throw new IOException("ClientNonSmartInvocationServiceImpl: Owner connection is not available.");
    }
    return (ClientConnection) connectionManager.getConnection(ownerConnectionAddress);
}
Also used : Address(com.hazelcast.nio.Address) ClientConnection(com.hazelcast.client.connection.nio.ClientConnection) IOException(java.io.IOException) ClientClusterService(com.hazelcast.client.spi.ClientClusterService)

Example 4 with ClientClusterService

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

the class ClientPartitionServiceImpl method getOwnerConnection.

private Connection getOwnerConnection() {
    ClientClusterService clusterService = client.getClientClusterService();
    Address ownerAddress = clusterService.getOwnerConnectionAddress();
    if (ownerAddress == null) {
        return null;
    }
    Connection connection = client.getConnectionManager().getConnection(ownerAddress);
    if (connection == null) {
        return null;
    }
    return connection;
}
Also used : Address(com.hazelcast.nio.Address) Connection(com.hazelcast.nio.Connection) ClientClusterService(com.hazelcast.client.spi.ClientClusterService)

Example 5 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)

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