Search in sources :

Example 11 with MigratablePipeline

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

the class MonkeyMigrationStrategyTest method imbalanceDetected_shouldReturnTrueWhenPipelineExist.

@Test
public void imbalanceDetected_shouldReturnTrueWhenPipelineExist() {
    MigratablePipeline pipeline = mock(MigratablePipeline.class);
    ownerPipelines.put(imbalance.srcOwner, setOf(pipeline));
    boolean imbalanceDetected = strategy.imbalanceDetected(imbalance);
    assertTrue(imbalanceDetected);
}
Also used : MigratablePipeline(com.hazelcast.internal.networking.nio.MigratablePipeline) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 12 with MigratablePipeline

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

the class MonkeyMigrationStrategyTest method findPipelineToMigrate_shouldWorkEvenWithASinglePipelineAvailable.

@Test
public void findPipelineToMigrate_shouldWorkEvenWithASinglePipelineAvailable() {
    MigratablePipeline pipeline = mock(MigratablePipeline.class);
    ownerPipelines.put(imbalance.srcOwner, setOf(pipeline));
    MigratablePipeline pipelineToMigrate = strategy.findPipelineToMigrate(imbalance);
    assertEquals(pipeline, pipelineToMigrate);
}
Also used : MigratablePipeline(com.hazelcast.internal.networking.nio.MigratablePipeline) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 13 with MigratablePipeline

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

the class IOBalancerTest method whenChannelRemoved_andDisabled_thenSkipTaskCreation.

// https://github.com/hazelcast/hazelcast/issues/11501
@Test
public void whenChannelRemoved_andDisabled_thenSkipTaskCreation() {
    IOBalancer ioBalancer = new IOBalancer(new NioThread[1], new NioThread[1], "foo", 1, loggingService);
    MigratablePipeline inboundPipeline = mock(MigratablePipeline.class);
    MigratablePipeline outboundPipelines = mock(MigratablePipeline.class);
    ioBalancer.channelRemoved(inboundPipeline, outboundPipelines);
    assertTrue(ioBalancer.getWorkQueue().isEmpty());
}
Also used : MigratablePipeline(com.hazelcast.internal.networking.nio.MigratablePipeline) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 14 with MigratablePipeline

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

the class LoadTrackerTest method testUpdateImbalance_notUsingSinglePipelineOwnerAsSource.

// there is no point in selecting a selector with a single handler as source.
@Test
public void testUpdateImbalance_notUsingSinglePipelineOwnerAsSource() throws Exception {
    MigratablePipeline owmer1Pipeline1 = mock(MigratablePipeline.class);
    // the first selector has a handler with a large number of events
    when(owmer1Pipeline1.load()).thenReturn(10000L);
    when(owmer1Pipeline1.owner()).thenReturn(owner1);
    loadTracker.addPipeline(owmer1Pipeline1);
    MigratablePipeline owner2Pipeline = mock(MigratablePipeline.class);
    when(owner2Pipeline.load()).thenReturn(200L);
    when(owner2Pipeline.owner()).thenReturn(owner2);
    loadTracker.addPipeline(owner2Pipeline);
    MigratablePipeline owner2Pipeline2 = mock(MigratablePipeline.class);
    when(owner2Pipeline2.load()).thenReturn(200L);
    when(owner2Pipeline2.owner()).thenReturn(owner2);
    loadTracker.addPipeline(owner2Pipeline2);
    LoadImbalance loadImbalance = loadTracker.updateImbalance();
    assertEquals(400, loadImbalance.minimumLoad);
    assertEquals(400, loadImbalance.maximumLoad);
    assertEquals(owner2, loadImbalance.dstOwner);
    assertEquals(owner2, loadImbalance.srcOwner);
}
Also used : MigratablePipeline(com.hazelcast.internal.networking.nio.MigratablePipeline) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

MigratablePipeline (com.hazelcast.internal.networking.nio.MigratablePipeline)14 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)8 QuickTest (com.hazelcast.test.annotation.QuickTest)8 Test (org.junit.Test)8 NioThread (com.hazelcast.internal.networking.nio.NioThread)4 IMap (com.hazelcast.map.IMap)2 Map (java.util.Map)2 Collectors.toMap (java.util.stream.Collectors.toMap)2