use of com.hazelcast.internal.networking.nonblocking.NonBlockingIOThread in project hazelcast by hazelcast.
the class LoadTrackerTest method setUp.
@Before
public void setUp() {
selector1 = mock(NonBlockingIOThread.class);
selector2 = mock(NonBlockingIOThread.class);
selectors = new NonBlockingIOThread[] { selector1, selector2 };
ILogger logger = mock(ILogger.class);
when(logger.isFinestEnabled()).thenReturn(true);
loadTracker = new LoadTracker(selectors, logger);
}
use of com.hazelcast.internal.networking.nonblocking.NonBlockingIOThread in project hazelcast by hazelcast.
the class EventCountBasicMigrationStrategyTest method testFindHandlerToMigrate.
@Test
public void testFindHandlerToMigrate() throws Exception {
NonBlockingIOThread sourceSelector = mock(NonBlockingIOThread.class);
NonBlockingIOThread destinationSelector = mock(NonBlockingIOThread.class);
imbalance.sourceSelector = sourceSelector;
imbalance.destinationSelector = destinationSelector;
imbalance.minimumEvents = 100;
MigratableHandler handler1 = mock(MigratableHandler.class);
handlerEventsCounter.set(handler1, 100l);
selectorToHandlers.put(destinationSelector, singleton(handler1));
imbalance.maximumEvents = 300;
MigratableHandler handler2 = mock(MigratableHandler.class);
MigratableHandler handler3 = mock(MigratableHandler.class);
handlerEventsCounter.set(handler2, 200l);
handlerEventsCounter.set(handler3, 100l);
selectorToHandlers.put(sourceSelector, setOf(handler2, handler3));
MigratableHandler handlerToMigrate = strategy.findHandlerToMigrate(imbalance);
assertEquals(handler3, handlerToMigrate);
}
use of com.hazelcast.internal.networking.nonblocking.NonBlockingIOThread in project hazelcast by hazelcast.
the class IOBalancerStressTest method debug.
public String debug(TcpIpConnectionManager connectionManager) {
NonBlockingIOThreadingModel threadingModel = (NonBlockingIOThreadingModel) connectionManager.getIoThreadingModel();
StringBuffer sb = new StringBuffer();
sb.append("in selectors\n");
for (NonBlockingIOThread in : threadingModel.getInputThreads()) {
sb.append(in + ": " + in.getEventCount() + "\n");
for (TcpIpConnection connection : connectionManager.getActiveConnections()) {
NonBlockingSocketReader socketReader = (NonBlockingSocketReader) connection.getSocketReader();
if (socketReader.getOwner() == in) {
sb.append("\t" + socketReader + " eventCount:" + socketReader.getEventCount() + "\n");
}
}
}
sb.append("out selectors\n");
for (NonBlockingIOThread in : threadingModel.getOutputThreads()) {
sb.append(in + ": " + in.getEventCount() + "\n");
for (TcpIpConnection connection : connectionManager.getActiveConnections()) {
NonBlockingSocketWriter socketWriter = (NonBlockingSocketWriter) connection.getSocketWriter();
if (socketWriter.getOwner() == in) {
sb.append("\t" + socketWriter + " eventCount:" + socketWriter.getEventCount() + "\n");
}
}
}
return sb.toString();
}
use of com.hazelcast.internal.networking.nonblocking.NonBlockingIOThread in project hazelcast by hazelcast.
the class IOBalancerStressTest method assertBalanced.
private void assertBalanced(HazelcastInstance hz) {
TcpIpConnectionManager connectionManager = (TcpIpConnectionManager) getConnectionManager(hz);
Map<NonBlockingIOThread, Set<MigratableHandler>> handlersPerSelector = getHandlersPerSelector(connectionManager);
try {
for (Map.Entry<NonBlockingIOThread, Set<MigratableHandler>> entry : handlersPerSelector.entrySet()) {
NonBlockingIOThread selector = entry.getKey();
Set<MigratableHandler> handlers = entry.getValue();
assertBalanced(selector, handlers);
}
} catch (AssertionError e) {
// if something fails, we want to see the debug
System.out.println(debug(connectionManager));
throw e;
}
}
Aggregations