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