Search in sources :

Example 1 with TcpServer

use of com.hazelcast.internal.server.tcp.TcpServer in project hazelcast by hazelcast.

the class NioChannelMemoryLeakTest method assertNoChannelLeak.

private void assertNoChannelLeak(HazelcastInstance instance) {
    int clusterSize = instance.getCluster().getMembers().size();
    // There may be one or two channels between two members.
    // Ideally there'll be only a single channel,
    // but when two members initiate the connection concurrently,
    // it may end up with two different connections between them.
    int maxChannelCount = (clusterSize - 1) * 2;
    TcpServer networkingService = (TcpServer) getNode(instance).getServer();
    NioNetworking networking = (NioNetworking) networkingService.getNetworking();
    Set<NioChannel> channels = networking.getChannels();
    assertThat(channels.size(), lessThanOrEqualTo(maxChannelCount));
    for (NioChannel channel : channels) {
        assertTrue("Channel " + channel + " was found closed (channel: " + channel.isClosed() + ", socketChannel: " + !channel.socketChannel().isOpen() + ") in instance " + instance, !channel.isClosed() && channel.socketChannel().isOpen());
    }
}
Also used : TcpServer(com.hazelcast.internal.server.tcp.TcpServer)

Example 2 with TcpServer

use of com.hazelcast.internal.server.tcp.TcpServer in project hazelcast by hazelcast.

the class IOBalancerStressTest method debug.

private StringBuilder debug(HazelcastInstance hz) {
    TcpServer networkingService = (TcpServer) getNode(hz).getServer();
    NioNetworking networking = (NioNetworking) networkingService.getNetworking();
    ServerConnectionManager cm = getNode(hz).getServer().getConnectionManager(EndpointQualifier.MEMBER);
    StringBuilder sb = new StringBuilder();
    sb.append("in owners\n");
    for (NioThread in : networking.getInputThreads()) {
        sb.append(in).append(": ").append(in.getEventCount()).append("\n");
        for (ServerConnection connection : cm.getConnections()) {
            TcpServerConnection tcpConnection = (TcpServerConnection) connection;
            NioInboundPipeline inboundPipeline = ((NioChannel) tcpConnection.getChannel()).inboundPipeline();
            if (inboundPipeline.owner() == in) {
                sb.append("\t").append(inboundPipeline).append(" load: ").append(inboundPipeline.load()).append("\n");
            }
        }
    }
    sb.append("out owners\n");
    for (NioThread in : networking.getOutputThreads()) {
        sb.append(in).append(": ").append(in.getEventCount()).append("\n");
        for (ServerConnection connection : cm.getConnections()) {
            TcpServerConnection tcpConnection = (TcpServerConnection) connection;
            NioOutboundPipeline outboundPipeline = ((NioChannel) tcpConnection.getChannel()).outboundPipeline();
            if (outboundPipeline.owner() == in) {
                sb.append("\t").append(outboundPipeline).append(" load:").append(outboundPipeline.load()).append("\n");
            }
        }
    }
    return sb;
}
Also used : NioThread(com.hazelcast.internal.networking.nio.NioThread) ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager) NioChannel(com.hazelcast.internal.networking.nio.NioChannel) ServerConnection(com.hazelcast.internal.server.ServerConnection) TcpServerConnection(com.hazelcast.internal.server.tcp.TcpServerConnection) NioNetworking(com.hazelcast.internal.networking.nio.NioNetworking) NioOutboundPipeline(com.hazelcast.internal.networking.nio.NioOutboundPipeline) TcpServer(com.hazelcast.internal.server.tcp.TcpServer) TcpServerConnection(com.hazelcast.internal.server.tcp.TcpServerConnection) NioInboundPipeline(com.hazelcast.internal.networking.nio.NioInboundPipeline)

Example 3 with TcpServer

use of com.hazelcast.internal.server.tcp.TcpServer in project hazelcast by hazelcast.

the class IOBalancerMemoryLeakTest method getIoBalancer.

private static IOBalancer getIoBalancer(HazelcastInstance instance) {
    TcpServer ns = (TcpServer) getNode(instance).getServer();
    NioNetworking threadingModel = (NioNetworking) ns.getNetworking();
    return threadingModel.getIOBalancer();
}
Also used : NioNetworking(com.hazelcast.internal.networking.nio.NioNetworking) TcpServer(com.hazelcast.internal.server.tcp.TcpServer)

Example 4 with TcpServer

use of com.hazelcast.internal.server.tcp.TcpServer in project hazelcast by hazelcast.

the class DefaultNodeContext method createServer.

@Override
public Server createServer(Node node, ServerSocketRegistry registry, LocalAddressRegistry addressRegistry) {
    TcpServerContext context = new TcpServerContext(node, node.nodeEngine);
    Networking networking = createNetworking(node);
    Config config = node.getConfig();
    MetricsRegistry metricsRegistry = node.nodeEngine.getMetricsRegistry();
    return new TcpServer(config, context, registry, addressRegistry, metricsRegistry, networking, node.getNodeExtension().createChannelInitializerFn(context));
}
Also used : MetricsRegistry(com.hazelcast.internal.metrics.MetricsRegistry) Networking(com.hazelcast.internal.networking.Networking) NioNetworking(com.hazelcast.internal.networking.nio.NioNetworking) Config(com.hazelcast.config.Config) ConfigAccessor.getActiveMemberNetworkConfig(com.hazelcast.config.ConfigAccessor.getActiveMemberNetworkConfig) MemberAddressProviderConfig(com.hazelcast.config.MemberAddressProviderConfig) TcpServerContext(com.hazelcast.internal.server.tcp.TcpServerContext) TcpServer(com.hazelcast.internal.server.tcp.TcpServer)

Example 5 with TcpServer

use of com.hazelcast.internal.server.tcp.TcpServer in project hazelcast by hazelcast.

the class NioChannelMemoryLeakTest method testNioChannelLeak.

@Test
public void testNioChannelLeak() {
    Config config = getConfig();
    config.setProperty(MERGE_NEXT_RUN_DELAY_SECONDS.getName(), "1");
    config.setProperty(MERGE_FIRST_RUN_DELAY_SECONDS.getName(), "1");
    HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
    TcpServer networkingService = (TcpServer) getNode(instance).getServer();
    final NioNetworking networking = (NioNetworking) networkingService.getNetworking();
    assertTrueEventually(() -> assertThat(networking.getChannels(), Matchers.empty()));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Hazelcast.newHazelcastInstance(com.hazelcast.core.Hazelcast.newHazelcastInstance) Config(com.hazelcast.config.Config) JoinConfig(com.hazelcast.config.JoinConfig) TcpServer(com.hazelcast.internal.server.tcp.TcpServer) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Aggregations

TcpServer (com.hazelcast.internal.server.tcp.TcpServer)5 NioNetworking (com.hazelcast.internal.networking.nio.NioNetworking)3 Config (com.hazelcast.config.Config)2 ConfigAccessor.getActiveMemberNetworkConfig (com.hazelcast.config.ConfigAccessor.getActiveMemberNetworkConfig)1 JoinConfig (com.hazelcast.config.JoinConfig)1 MemberAddressProviderConfig (com.hazelcast.config.MemberAddressProviderConfig)1 Hazelcast.newHazelcastInstance (com.hazelcast.core.Hazelcast.newHazelcastInstance)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 MetricsRegistry (com.hazelcast.internal.metrics.MetricsRegistry)1 Networking (com.hazelcast.internal.networking.Networking)1 NioChannel (com.hazelcast.internal.networking.nio.NioChannel)1 NioInboundPipeline (com.hazelcast.internal.networking.nio.NioInboundPipeline)1 NioOutboundPipeline (com.hazelcast.internal.networking.nio.NioOutboundPipeline)1 NioThread (com.hazelcast.internal.networking.nio.NioThread)1 ServerConnection (com.hazelcast.internal.server.ServerConnection)1 ServerConnectionManager (com.hazelcast.internal.server.ServerConnectionManager)1 TcpServerConnection (com.hazelcast.internal.server.tcp.TcpServerConnection)1 TcpServerContext (com.hazelcast.internal.server.tcp.TcpServerContext)1 SlowTest (com.hazelcast.test.annotation.SlowTest)1 Test (org.junit.Test)1