Search in sources :

Example 1 with ClientConnection

use of com.hazelcast.client.connection.nio.ClientConnection 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 ClientConnection

use of com.hazelcast.client.connection.nio.ClientConnection in project hazelcast by hazelcast.

the class ClientMapReduceProxy method invoke.

private ClientMessage invoke(ClientMessage request, String jobId) throws Exception {
    ClientTrackableJob trackableJob = trackableJobs.get(jobId);
    if (trackableJob != null) {
        ClientConnection sendConnection = trackableJob.clientInvocation.getSendConnectionOrWait();
        Address runningMember = sendConnection.getEndPoint();
        final ClientInvocation clientInvocation = new ClientInvocation(getClient(), request, runningMember);
        ClientInvocationFuture future = clientInvocation.invoke();
        return future.get();
    }
    return null;
}
Also used : Address(com.hazelcast.nio.Address) ClientConnection(com.hazelcast.client.connection.nio.ClientConnection) ClientInvocation(com.hazelcast.client.spi.impl.ClientInvocation) ClientInvocationFuture(com.hazelcast.client.spi.impl.ClientInvocationFuture)

Example 3 with ClientConnection

use of com.hazelcast.client.connection.nio.ClientConnection 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 ClientConnection

use of com.hazelcast.client.connection.nio.ClientConnection in project hazelcast by hazelcast.

the class ClientTransactionManagerServiceImpl method connect.

public ClientConnection connect() throws Exception {
    Exception lastError = null;
    int count = 0;
    while (count < RETRY_COUNT) {
        try {
            final Address randomAddress = getRandomAddress();
            return (ClientConnection) client.getConnectionManager().getOrConnect(randomAddress, false);
        } catch (Exception e) {
            lastError = e;
        }
        count++;
    }
    throw lastError;
}
Also used : Address(com.hazelcast.nio.Address) ClientConnection(com.hazelcast.client.connection.nio.ClientConnection) TransactionException(com.hazelcast.transaction.TransactionException)

Example 5 with ClientConnection

use of com.hazelcast.client.connection.nio.ClientConnection in project hazelcast by hazelcast.

the class ClientClusterServiceImpl method getLocalClient.

@Override
public Client getLocalClient() {
    Address address = getOwnerConnectionAddress();
    final ClientConnectionManager cm = client.getConnectionManager();
    final ClientConnection connection = (ClientConnection) cm.getConnection(address);
    InetSocketAddress inetSocketAddress = connection != null ? connection.getLocalSocketAddress() : null;
    final String uuid = getPrincipal().getUuid();
    return new ClientImpl(uuid, inetSocketAddress);
}
Also used : Address(com.hazelcast.nio.Address) InetSocketAddress(java.net.InetSocketAddress) InetSocketAddress(java.net.InetSocketAddress) ClientImpl(com.hazelcast.client.impl.ClientImpl) ClientConnection(com.hazelcast.client.connection.nio.ClientConnection) ClientConnectionManager(com.hazelcast.client.connection.ClientConnectionManager)

Aggregations

ClientConnection (com.hazelcast.client.connection.nio.ClientConnection)13 Address (com.hazelcast.nio.Address)10 Connection (com.hazelcast.nio.Connection)6 ClientConnectionManager (com.hazelcast.client.connection.ClientConnectionManager)4 HazelcastClientInstanceImpl (com.hazelcast.client.impl.HazelcastClientInstanceImpl)4 ClientClusterService (com.hazelcast.client.spi.ClientClusterService)4 IOException (java.io.IOException)4 ClientContext (com.hazelcast.client.spi.ClientContext)2 ClientInvocation (com.hazelcast.client.spi.impl.ClientInvocation)2 InetSocketAddress (java.net.InetSocketAddress)2 ClientImpl (com.hazelcast.client.impl.ClientImpl)1 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 ClientInvocationFuture (com.hazelcast.client.spi.impl.ClientInvocationFuture)1 EntryAdapter (com.hazelcast.core.EntryAdapter)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 IMap (com.hazelcast.core.IMap)1 Data (com.hazelcast.nio.serialization.Data)1 TargetNotMemberException (com.hazelcast.spi.exception.TargetNotMemberException)1 AssertTask (com.hazelcast.test.AssertTask)1 NightlyTest (com.hazelcast.test.annotation.NightlyTest)1