Search in sources :

Example 6 with NonBlockingIOThread

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);
}
Also used : NonBlockingIOThread(com.hazelcast.internal.networking.nonblocking.NonBlockingIOThread) ILogger(com.hazelcast.logging.ILogger) Before(org.junit.Before)

Example 7 with NonBlockingIOThread

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);
}
Also used : NonBlockingIOThread(com.hazelcast.internal.networking.nonblocking.NonBlockingIOThread) MigratableHandler(com.hazelcast.internal.networking.nonblocking.MigratableHandler) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 8 with NonBlockingIOThread

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();
}
Also used : NonBlockingIOThread(com.hazelcast.internal.networking.nonblocking.NonBlockingIOThread) TcpIpConnection(com.hazelcast.nio.tcp.TcpIpConnection) NonBlockingSocketReader(com.hazelcast.internal.networking.nonblocking.NonBlockingSocketReader) NonBlockingSocketWriter(com.hazelcast.internal.networking.nonblocking.NonBlockingSocketWriter) NonBlockingIOThreadingModel(com.hazelcast.internal.networking.nonblocking.NonBlockingIOThreadingModel)

Example 9 with NonBlockingIOThread

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;
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) NonBlockingIOThread(com.hazelcast.internal.networking.nonblocking.NonBlockingIOThread) TcpIpConnectionManager(com.hazelcast.nio.tcp.TcpIpConnectionManager) MigratableHandler(com.hazelcast.internal.networking.nonblocking.MigratableHandler) HashMap(java.util.HashMap) Map(java.util.Map) IMap(com.hazelcast.core.IMap)

Aggregations

NonBlockingIOThread (com.hazelcast.internal.networking.nonblocking.NonBlockingIOThread)9 MigratableHandler (com.hazelcast.internal.networking.nonblocking.MigratableHandler)5 TcpIpConnection (com.hazelcast.nio.tcp.TcpIpConnection)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 IMap (com.hazelcast.core.IMap)1 NonBlockingIOThreadingModel (com.hazelcast.internal.networking.nonblocking.NonBlockingIOThreadingModel)1 NonBlockingSocketReader (com.hazelcast.internal.networking.nonblocking.NonBlockingSocketReader)1 NonBlockingSocketWriter (com.hazelcast.internal.networking.nonblocking.NonBlockingSocketWriter)1 ILogger (com.hazelcast.logging.ILogger)1 TcpIpConnectionManager (com.hazelcast.nio.tcp.TcpIpConnectionManager)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Map (java.util.Map)1 Before (org.junit.Before)1 Test (org.junit.Test)1