Search in sources :

Example 11 with ClientConnection

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

the class ClientSmartInvocationServiceImpl method invokeOnRandomTarget.

@Override
public void invokeOnRandomTarget(ClientInvocation invocation) throws IOException {
    final Address randomAddress = getRandomAddress();
    if (randomAddress == null) {
        throw new IOException("Not address found to invoke ");
    }
    final Connection connection = getOrTriggerConnect(randomAddress);
    send(invocation, (ClientConnection) connection);
}
Also used : Address(com.hazelcast.nio.Address) ClientConnection(com.hazelcast.client.connection.nio.ClientConnection) Connection(com.hazelcast.nio.Connection) IOException(java.io.IOException)

Example 12 with ClientConnection

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

the class ClientSmartInvocationServiceImpl method invokeOnTarget.

@Override
public void invokeOnTarget(ClientInvocation invocation, Address target) throws IOException {
    if (target == null) {
        throw new NullPointerException("Target can not be null");
    }
    if (!isMember(target)) {
        throw new TargetNotMemberException("Target :  " + target + " is not member. ");
    }
    final Connection connection = getOrTriggerConnect(target);
    invokeOnConnection(invocation, (ClientConnection) connection);
}
Also used : TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) ClientConnection(com.hazelcast.client.connection.nio.ClientConnection) Connection(com.hazelcast.nio.Connection)

Example 13 with ClientConnection

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

the class ClientSmartInvocationServiceImpl method invokeOnPartitionOwner.

@Override
public void invokeOnPartitionOwner(ClientInvocation invocation, int partitionId) throws IOException {
    final Address owner = partitionService.getPartitionOwner(partitionId);
    if (owner == null) {
        throw new IOException("Partition does not have owner. partitionId : " + partitionId);
    }
    invocation.getClientMessage().setPartitionId(partitionId);
    Connection connection = getOrTriggerConnect(owner);
    send(invocation, (ClientConnection) connection);
}
Also used : Address(com.hazelcast.nio.Address) ClientConnection(com.hazelcast.client.connection.nio.ClientConnection) Connection(com.hazelcast.nio.Connection) IOException(java.io.IOException)

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