Search in sources :

Example 11 with ServerConnection

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)));
    }
}
Also used : ServerConnection(com.hazelcast.internal.server.ServerConnection) RetryableIOException(com.hazelcast.spi.exception.RetryableIOException)

Example 12 with ServerConnection

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ServerConnection(com.hazelcast.internal.server.ServerConnection) CountDownLatch(java.util.concurrent.CountDownLatch) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 13 with ServerConnection

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);
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) Address(com.hazelcast.cluster.Address) LoggingServiceImpl(com.hazelcast.logging.impl.LoggingServiceImpl) ServerConnection(com.hazelcast.internal.server.ServerConnection) JsonArray(com.hazelcast.internal.json.JsonArray) Level(java.util.logging.Level) Json(com.hazelcast.internal.json.Json) ClusterService(com.hazelcast.internal.cluster.ClusterService) SC_500(com.hazelcast.internal.ascii.rest.HttpStatusCode.SC_500) CPGroup(com.hazelcast.cp.CPGroup) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) StringUtil.equalsIgnoreCase(com.hazelcast.internal.util.StringUtil.equalsIgnoreCase) CPSession(com.hazelcast.cp.session.CPSession) JsonObject(com.hazelcast.internal.json.JsonObject) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) CPGroupId(com.hazelcast.cp.CPGroupId) ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager) TextCommandService(com.hazelcast.internal.ascii.TextCommandService) StringUtil(com.hazelcast.internal.util.StringUtil) ExceptionUtil.peel(com.hazelcast.internal.util.ExceptionUtil.peel) CPSubsystemManagementService(com.hazelcast.cp.CPSubsystemManagementService) Collection(java.util.Collection) Server(com.hazelcast.internal.server.Server) NodeState(com.hazelcast.instance.impl.NodeState) MAP(com.hazelcast.internal.ascii.rest.RestCallExecution.ObjectType.MAP) Node(com.hazelcast.instance.impl.Node) CLIENT(com.hazelcast.instance.EndpointQualifier.CLIENT) CompletionStage(java.util.concurrent.CompletionStage) CPMember(com.hazelcast.cp.CPMember) ClusterState(com.hazelcast.cluster.ClusterState) CPSubsystem(com.hazelcast.cp.CPSubsystem) QUEUE(com.hazelcast.internal.ascii.rest.RestCallExecution.ObjectType.QUEUE) Server(com.hazelcast.internal.server.Server) ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager) Node(com.hazelcast.instance.impl.Node) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) JsonObject(com.hazelcast.internal.json.JsonObject)

Example 14 with ServerConnection

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();
}
Also used : TcpServerConnection(com.hazelcast.internal.server.tcp.TcpServerConnection) ServerConnection(com.hazelcast.internal.server.ServerConnection)

Example 15 with ServerConnection

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();
}
Also used : ServerConnection(com.hazelcast.internal.server.ServerConnection) Connection(com.hazelcast.internal.nio.Connection) ServerConnection(com.hazelcast.internal.server.ServerConnection)

Aggregations

ServerConnection (com.hazelcast.internal.server.ServerConnection)22 Address (com.hazelcast.cluster.Address)6 ClientMessageDecoder (com.hazelcast.client.impl.protocol.util.ClientMessageDecoder)2 InboundHandler (com.hazelcast.internal.networking.InboundHandler)2 OutboundHandler (com.hazelcast.internal.networking.OutboundHandler)2 ServerConnectionManager (com.hazelcast.internal.server.ServerConnectionManager)2 TcpServerConnection (com.hazelcast.internal.server.tcp.TcpServerConnection)2 Operation (com.hazelcast.spi.impl.operationservice.Operation)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 UUID (java.util.UUID)2 Test (org.junit.Test)2 ClientEndpointImpl (com.hazelcast.client.impl.ClientEndpointImpl)1 ClientMessageEncoder (com.hazelcast.client.impl.protocol.util.ClientMessageEncoder)1 ClusterState (com.hazelcast.cluster.ClusterState)1 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)1 EndpointConfig (com.hazelcast.config.EndpointConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)1 CPGroup (com.hazelcast.cp.CPGroup)1