use of com.hazelcast.internal.server.ServerConnection in project hazelcast by hazelcast.
the class Invocation method doInvokeRemote.
private void doInvokeRemote() {
assert connectionManager != null : "Endpoint manager was null";
ServerConnection connection = connectionManager.getOrConnect(targetAddress, op.getPartitionId());
this.connection = connection;
boolean write;
if (connection != null) {
write = context.outboundOperationHandler.send(op, connection);
} else {
write = context.outboundOperationHandler.send(op, targetAddress);
}
if (!write) {
notifyError(new RetryableIOException(getPacketNotSentMessage(connection)));
}
}
use of com.hazelcast.internal.server.ServerConnection in project hazelcast by hazelcast.
the class ClientDisconnectTest method testConnectionEventsFiredForClientsOnServerConnectionManager.
@Test
public void testConnectionEventsFiredForClientsOnServerConnectionManager() {
HazelcastInstance server = hazelcastFactory.newHazelcastInstance();
CountDownLatch clientConnected = new CountDownLatch(1);
CountDownLatch clientDisconnected = new CountDownLatch(1);
getNodeEngineImpl(server).getNode().getServer().addConnectionListener(new ConnectionListener<ServerConnection>() {
@Override
public void connectionAdded(ServerConnection connection) {
if (connection.isClient()) {
clientConnected.countDown();
}
}
@Override
public void connectionRemoved(ServerConnection connection) {
if (connection.isClient()) {
clientDisconnected.countDown();
}
}
});
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
assertOpenEventually(clientConnected);
client.shutdown();
assertOpenEventually(clientDisconnected);
}
use of com.hazelcast.internal.server.ServerConnection in project hazelcast by hazelcast.
the class HttpGetCommandProcessor method handleCluster.
/**
* Sets the HTTP response to a string containing basic cluster information:
* <ul>
* <li>Member list</li>
* <li>Client connection count</li>
* <li>Connection count</li>
* </ul>
*
* @param command the HTTP request
*/
private void handleCluster(HttpGetCommand command) {
Node node = textCommandService.getNode();
Server server = node.getServer();
ClusterServiceImpl clusterService = node.getClusterService();
JsonArray membersArray = new JsonArray();
clusterService.getMembers().stream().map(m -> new JsonObject().add("address", m.getAddress().toString()).add("liteMember", m.isLiteMember()).add("localMember", m.localMember()).add("uuid", m.getUuid().toString()).add("memberVersion", m.getVersion().toString())).forEach(membersArray::add);
ServerConnectionManager cm = server.getConnectionManager(CLIENT);
int clientCount = cm == null ? 0 : cm.connectionCount(ServerConnection::isClient);
JsonObject response = new JsonObject().add("members", membersArray).add("connectionCount", clientCount).add("allConnectionCount", server.connectionCount());
prepareResponse(command, response);
}
use of com.hazelcast.internal.server.ServerConnection in project hazelcast by hazelcast.
the class OverloadedConnectionsPlugin method run.
@Override
public void run(DiagnosticsLogWriter writer) {
writer.startSection("OverloadedConnections");
Collection<ServerConnection> connections = nodeEngine.getNode().getServer().getConnections();
for (ServerConnection connection : connections) {
clear();
scan(writer, (TcpServerConnection) connection, false);
clear();
scan(writer, (TcpServerConnection) connection, true);
}
writer.endSection();
}
use of com.hazelcast.internal.server.ServerConnection 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());
if (connection instanceof ServerConnection) {
writer.writeKeyValueEntry("type", ((ServerConnection) connection).getConnectionType());
}
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