Search in sources :

Example 6 with NioThread

use of com.hazelcast.internal.networking.nio.NioThread in project hazelcast by hazelcast.

the class IOBalancerStressTest method debug.

private StringBuilder debug(Map<NioThread, Map<MigratablePipeline, Long>> pipelinesLoadPerOwnerBeforeLoad) {
    StringBuilder sbIn = new StringBuilder();
    sbIn.append("in owners\n");
    StringBuilder sbOut = new StringBuilder();
    sbOut.append("out owners\n");
    for (Map.Entry<NioThread, Map<MigratablePipeline, Long>> entry : pipelinesLoadPerOwnerBeforeLoad.entrySet()) {
        NioThread nioThread = entry.getKey();
        StringBuilder sb = nioThread.getName().contains("thread-in") ? sbIn : sbOut;
        sb.append(entry.getKey()).append("\n");
        for (Map.Entry<MigratablePipeline, Long> pipelineEntry : entry.getValue().entrySet()) {
            MigratablePipeline pipeline = pipelineEntry.getKey();
            sb.append("\t").append(pipeline).append(" load: ").append(pipelineEntry.getValue()).append("\n");
        }
    }
    return sbIn.append(sbOut);
}
Also used : NioThread(com.hazelcast.internal.networking.nio.NioThread) MigratablePipeline(com.hazelcast.internal.networking.nio.MigratablePipeline) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) IMap(com.hazelcast.map.IMap)

Example 7 with NioThread

use of com.hazelcast.internal.networking.nio.NioThread in project hazelcast by hazelcast.

the class IOBalancerStressTest method testEachConnectionUseDifferentOwnerEventually.

@Test
public void testEachConnectionUseDifferentOwnerEventually() {
    Config config = new Config().setProperty(ClusterProperty.IO_BALANCER_INTERVAL_SECONDS.getName(), "1").setProperty(ClusterProperty.IO_THREAD_COUNT.getName(), "4");
    HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance instance3 = Hazelcast.newHazelcastInstance(config);
    instance2.shutdown();
    instance2 = Hazelcast.newHazelcastInstance(config);
    // prerecord pipelines load, grouped by the owner-thread, before start the load
    Map<NioThread, Map<MigratablePipeline, Long>> pipelinesLoadPerOwnerBeforeLoad1 = getPipelinesLoadPerOwner(instance1);
    Map<NioThread, Map<MigratablePipeline, Long>> pipelinesLoadPerOwnerBeforeLoad2 = getPipelinesLoadPerOwner(instance2);
    Map<NioThread, Map<MigratablePipeline, Long>> pipelinesLoadPerOwnerBeforeLoad3 = getPipelinesLoadPerOwner(instance3);
    IMap<Integer, Integer> map = instance1.getMap(randomMapName());
    for (int i = 0; i < 10000; i++) {
        map.put(i, i);
    }
    assertBalanced(pipelinesLoadPerOwnerBeforeLoad1, instance1);
    assertBalanced(pipelinesLoadPerOwnerBeforeLoad2, instance2);
    assertBalanced(pipelinesLoadPerOwnerBeforeLoad3, instance3);
}
Also used : NioThread(com.hazelcast.internal.networking.nio.NioThread) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) IMap(com.hazelcast.map.IMap) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test)

Example 8 with NioThread

use of com.hazelcast.internal.networking.nio.NioThread in project hazelcast by hazelcast.

the class LoadTrackerTest method setUp.

@Before
public void setUp() {
    owner1 = mock(NioThread.class);
    owner2 = mock(NioThread.class);
    owner3 = new NioThread[] { owner1, owner2 };
    ILogger logger = mock(ILogger.class);
    when(logger.isFinestEnabled()).thenReturn(true);
    loadTracker = new LoadTracker(owner3, logger);
}
Also used : NioThread(com.hazelcast.internal.networking.nio.NioThread) ILogger(com.hazelcast.logging.ILogger) Before(org.junit.Before)

Example 9 with NioThread

use of com.hazelcast.internal.networking.nio.NioThread in project hazelcast by hazelcast.

the class NetworkingImbalancePlugin method render.

private void render(DiagnosticsLogWriter writer, NioThread[] threads) {
    if (threads == null) {
        // this can become null due to stopping of the system
        return;
    }
    long totalPriorityFramesReceived = 0;
    long totalFramesReceived = 0;
    long totalBytesReceived = 0;
    long totalEvents = 0;
    long totalTaskCount = 0;
    long totalHandleCount = 0;
    for (NioThread thread : threads) {
        totalBytesReceived += thread.bytesTransceived();
        totalFramesReceived += thread.framesTransceived();
        totalPriorityFramesReceived += thread.priorityFramesTransceived();
        totalEvents += thread.eventCount();
        totalTaskCount += thread.completedTaskCount();
        totalHandleCount += thread.handleCount();
    }
    for (NioThread thread : threads) {
        writer.startSection(thread.getName());
        writer.writeKeyValueEntry("frames-percentage", toPercentage(thread.framesTransceived(), totalFramesReceived));
        writer.writeKeyValueEntry("frames", thread.framesTransceived());
        writer.writeKeyValueEntry("priority-frames-percentage", toPercentage(thread.priorityFramesTransceived(), totalPriorityFramesReceived));
        writer.writeKeyValueEntry("priority-frames", thread.priorityFramesTransceived());
        writer.writeKeyValueEntry("bytes-percentage", toPercentage(thread.bytesTransceived(), totalBytesReceived));
        writer.writeKeyValueEntry("bytes", thread.bytesTransceived());
        writer.writeKeyValueEntry("events-percentage", toPercentage(thread.eventCount(), totalEvents));
        writer.writeKeyValueEntry("events", thread.eventCount());
        writer.writeKeyValueEntry("handle-count-percentage", toPercentage(thread.handleCount(), totalHandleCount));
        writer.writeKeyValueEntry("handle-count", thread.handleCount());
        writer.writeKeyValueEntry("tasks-percentage", toPercentage(thread.completedTaskCount(), totalTaskCount));
        writer.writeKeyValueEntry("tasks", thread.completedTaskCount());
        writer.endSection();
    }
}
Also used : NioThread(com.hazelcast.internal.networking.nio.NioThread)

Example 10 with NioThread

use of com.hazelcast.internal.networking.nio.NioThread in project hazelcast by hazelcast.

the class IOBalancer method tryMigrate.

private void tryMigrate(LoadImbalance loadImbalance) {
    MigratablePipeline pipeline = strategy.findPipelineToMigrate(loadImbalance);
    if (pipeline == null) {
        logger.finest("I/O imbalance is detected, but no suitable migration candidate is found.");
        return;
    }
    NioThread dstOwner = loadImbalance.dstOwner;
    if (logger.isFinestEnabled()) {
        NioThread srcOwner = loadImbalance.srcOwner;
        logger.finest("Scheduling migration of pipeline " + pipeline + " from " + srcOwner + " to " + dstOwner);
    }
    pipeline.requestMigration(dstOwner);
}
Also used : NioThread(com.hazelcast.internal.networking.nio.NioThread) MigratablePipeline(com.hazelcast.internal.networking.nio.MigratablePipeline)

Aggregations

NioThread (com.hazelcast.internal.networking.nio.NioThread)11 MigratablePipeline (com.hazelcast.internal.networking.nio.MigratablePipeline)4 IMap (com.hazelcast.map.IMap)3 Map (java.util.Map)3 Collectors.toMap (java.util.stream.Collectors.toMap)3 Test (org.junit.Test)2 Config (com.hazelcast.config.Config)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 NioChannel (com.hazelcast.internal.networking.nio.NioChannel)1 NioInboundPipeline (com.hazelcast.internal.networking.nio.NioInboundPipeline)1 NioNetworking (com.hazelcast.internal.networking.nio.NioNetworking)1 NioOutboundPipeline (com.hazelcast.internal.networking.nio.NioOutboundPipeline)1 ServerConnection (com.hazelcast.internal.server.ServerConnection)1 ServerConnectionManager (com.hazelcast.internal.server.ServerConnectionManager)1 TcpServer (com.hazelcast.internal.server.tcp.TcpServer)1 TcpServerConnection (com.hazelcast.internal.server.tcp.TcpServerConnection)1 ILogger (com.hazelcast.logging.ILogger)1 NightlyTest (com.hazelcast.test.annotation.NightlyTest)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1