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());
}
}
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;
}
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();
}
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));
}
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()));
}
Aggregations