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;
}
use of com.hazelcast.nio.Connection in project hazelcast by hazelcast.
the class ClientEngineImpl method shutdown.
@Override
public void shutdown(boolean terminate) {
for (ClientEndpoint ce : endpointManager.getEndpoints()) {
ClientEndpointImpl endpoint = (ClientEndpointImpl) ce;
try {
endpoint.destroy();
} catch (LoginException e) {
logger.finest(e.getMessage());
}
try {
final Connection conn = endpoint.getConnection();
if (conn.isAlive()) {
conn.close("Shutdown of ClientEngine", null);
}
} catch (Exception e) {
logger.finest(e);
}
}
endpointManager.clear();
ownershipMappings.clear();
}
use of com.hazelcast.nio.Connection in project hazelcast by hazelcast.
the class ClusterServiceImpl method doRemoveAddress.
void doRemoveAddress(Address deadAddress, String reason, boolean destroyConnection) {
if (!ensureMemberIsRemovable(deadAddress)) {
return;
}
lock.lock();
try {
if (deadAddress.equals(node.getMasterAddress())) {
assignNewMaster();
}
if (node.isMaster()) {
clusterJoinManager.removeJoin(deadAddress);
}
Connection conn = node.connectionManager.getConnection(deadAddress);
if (destroyConnection && conn != null) {
conn.close(reason, null);
}
MemberImpl deadMember = getMember(deadAddress);
if (deadMember != null) {
removeMember(deadMember);
logger.info(membersString());
}
} finally {
lock.unlock();
}
}
use of com.hazelcast.nio.Connection in project hazelcast by hazelcast.
the class SystemLogPlugin method render.
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
private void render(DiagnosticsLogWriter writer, ConnectionEvent event) {
if (event.added) {
writer.startSection("ConnectionAdded");
} else {
writer.startSection("ConnectionRemoved");
}
Connection connection = event.connection;
writer.writeEntry(connection.toString());
writer.writeKeyValueEntry("type", connection.getType().name());
writer.writeKeyValueEntry("isAlive", connection.isAlive());
if (!event.added) {
String closeReason = connection.getCloseReason();
Throwable closeCause = connection.getCloseCause();
if (closeReason == null && closeCause != null) {
closeReason = closeCause.getMessage();
}
writer.writeKeyValueEntry("closeReason", closeReason == null ? "Unknown" : closeReason);
if (closeCause != null) {
writer.startSection("CloseCause");
String s = closeCause.getClass().getName();
String message = closeCause.getMessage();
writer.writeEntry((message != null) ? (s + ": " + message) : s);
for (StackTraceElement element : closeCause.getStackTrace()) {
writer.writeEntry(element.toString());
}
writer.endSection();
}
}
writer.endSection();
}
Aggregations