use of com.hazelcast.internal.networking.nio.MigratablePipeline in project hazelcast by hazelcast.
the class IOBalancerTest method whenChannelAdded_andDisabled_thenSkipTaskCreation.
// https://github.com/hazelcast/hazelcast/issues/11501
@Test
public void whenChannelAdded_andDisabled_thenSkipTaskCreation() {
IOBalancer ioBalancer = new IOBalancer(new NioThread[1], new NioThread[1], "foo", 1, loggingService);
MigratablePipeline inboundPipeline = mock(MigratablePipeline.class);
MigratablePipeline outboundPipeline = mock(MigratablePipeline.class);
ioBalancer.channelAdded(inboundPipeline, outboundPipeline);
assertTrue(ioBalancer.getWorkQueue().isEmpty());
}
use of com.hazelcast.internal.networking.nio.MigratablePipeline in project hazelcast by hazelcast.
the class LoadTrackerTest method testUpdateImbalance.
@Test
public void testUpdateImbalance() throws Exception {
MigratablePipeline owner1Pipeline1 = mock(MigratablePipeline.class);
when(owner1Pipeline1.load()).thenReturn(0L).thenReturn(100L);
when(owner1Pipeline1.owner()).thenReturn(owner1);
loadTracker.addPipeline(owner1Pipeline1);
MigratablePipeline owner2Pipeline1 = mock(MigratablePipeline.class);
when(owner2Pipeline1.load()).thenReturn(0L).thenReturn(200L);
when(owner2Pipeline1.owner()).thenReturn(owner2);
loadTracker.addPipeline(owner2Pipeline1);
MigratablePipeline owner2Pipeline3 = mock(MigratablePipeline.class);
when(owner2Pipeline3.load()).thenReturn(0L).thenReturn(100L);
when(owner2Pipeline3.owner()).thenReturn(owner2);
loadTracker.addPipeline(owner2Pipeline3);
LoadImbalance loadImbalance = loadTracker.updateImbalance();
assertEquals(0, loadImbalance.minimumLoad);
assertEquals(0, loadImbalance.maximumLoad);
loadTracker.updateImbalance();
assertEquals(100, loadImbalance.minimumLoad);
assertEquals(300, loadImbalance.maximumLoad);
assertEquals(owner1, loadImbalance.dstOwner);
assertEquals(owner2, loadImbalance.srcOwner);
}
use of com.hazelcast.internal.networking.nio.MigratablePipeline 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);
}
use of com.hazelcast.internal.networking.nio.MigratablePipeline in project hazelcast by hazelcast.
the class LoadTracker method appendSelectorInfo.
private void appendSelectorInfo(NioThread minThread, Map<NioThread, Set<MigratablePipeline>> pipelinesPerOwner, StringBuilder sb) {
Set<MigratablePipeline> pipelines = pipelinesPerOwner.get(minThread);
for (MigratablePipeline pipeline : pipelines) {
Long loadPerPipeline = pipelineLoadCount.get(pipeline);
sb.append(pipeline).append(": ").append(loadPerPipeline).append(LINE_SEPARATOR);
}
sb.append(LINE_SEPARATOR);
}
use of com.hazelcast.internal.networking.nio.MigratablePipeline in project hazelcast by hazelcast.
the class LoadMigrationStrategyTest method testFindPipelineToMigrate.
@Test
public void testFindPipelineToMigrate() throws Exception {
NioThread srcOwner = mock(NioThread.class);
NioThread dstOwner = mock(NioThread.class);
imbalance.srcOwner = srcOwner;
imbalance.dstOwner = dstOwner;
imbalance.minimumLoad = 100;
MigratablePipeline pipeline1 = mock(MigratablePipeline.class);
loadCounter.set(pipeline1, 100L);
ownerToPipelines.put(dstOwner, singleton(pipeline1));
imbalance.maximumLoad = 300;
MigratablePipeline pipeline2 = mock(MigratablePipeline.class);
MigratablePipeline pipeline3 = mock(MigratablePipeline.class);
loadCounter.set(pipeline2, 200L);
loadCounter.set(pipeline3, 100L);
ownerToPipelines.put(srcOwner, setOf(pipeline2, pipeline3));
MigratablePipeline pipelineToMigrate = strategy.findPipelineToMigrate(imbalance);
assertEquals(pipeline3, pipelineToMigrate);
}
Aggregations