use of com.hazelcast.nio.Connection 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);
}
use of com.hazelcast.nio.Connection in project hazelcast by hazelcast.
the class ClientSmartInvocationServiceImpl method getOrTriggerConnect.
private Connection getOrTriggerConnect(Address target) throws IOException {
ensureOwnerConnectionAvailable();
Connection connection = connectionManager.getOrTriggerConnect(target, false);
if (connection == null) {
throw new IOException("No available connection to address " + target);
}
return connection;
}
use of com.hazelcast.nio.Connection 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);
}
use of com.hazelcast.nio.Connection 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);
}
use of com.hazelcast.nio.Connection in project hazelcast by hazelcast.
the class TcpIpConnectionManager method getOrConnect.
@Override
public Connection getOrConnect(final Address address, final boolean silent) {
Connection connection = connectionsMap.get(address);
if (connection == null && live) {
if (connectionsInProgress.add(address)) {
ioService.shouldConnectTo(address);
ioService.executeAsync(new InitConnectionTask(this, address, silent));
}
}
return connection;
}
Aggregations