use of com.hazelcast.internal.networking.nonblocking.NonBlockingIOThread in project hazelcast by hazelcast.
the class IOBalancerStressTest method getHandlersPerSelector.
private Map<NonBlockingIOThread, Set<MigratableHandler>> getHandlersPerSelector(TcpIpConnectionManager connectionManager) {
Map<NonBlockingIOThread, Set<MigratableHandler>> handlersPerSelector = new HashMap<NonBlockingIOThread, Set<MigratableHandler>>();
for (TcpIpConnection connection : connectionManager.getActiveConnections()) {
add(handlersPerSelector, (MigratableHandler) connection.getSocketReader());
add(handlersPerSelector, (MigratableHandler) connection.getSocketWriter());
}
return handlersPerSelector;
}
use of com.hazelcast.internal.networking.nonblocking.NonBlockingIOThread in project hazelcast by hazelcast.
the class IOBalancer method tryMigrate.
private void tryMigrate(LoadImbalance loadImbalance) {
MigratableHandler handler = strategy.findHandlerToMigrate(loadImbalance);
if (handler == null) {
logger.finest("I/O imbalance is detected, but no suitable migration candidate is found.");
return;
}
NonBlockingIOThread destinationSelector = loadImbalance.destinationSelector;
if (logger.isFinestEnabled()) {
NonBlockingIOThread sourceSelector = loadImbalance.sourceSelector;
logger.finest("Scheduling migration of handler " + handler + " from selector thread " + sourceSelector + " to " + destinationSelector);
}
handler.requestMigration(destinationSelector);
}
use of com.hazelcast.internal.networking.nonblocking.NonBlockingIOThread in project hazelcast by hazelcast.
the class LoadTracker method printDebugTable.
private void printDebugTable() {
if (!logger.isFinestEnabled()) {
return;
}
NonBlockingIOThread minThread = imbalance.destinationSelector;
NonBlockingIOThread maxThread = imbalance.sourceSelector;
if (minThread == null || maxThread == null) {
return;
}
StringBuilder sb = new StringBuilder(LINE_SEPARATOR).append("------------").append(LINE_SEPARATOR);
Long eventCountPerSelector = selectorEvents.get(minThread);
sb.append("Min Selector ").append(minThread).append(" received ").append(eventCountPerSelector).append(" events. ");
sb.append("It contains following handlers: ").append(LINE_SEPARATOR);
appendSelectorInfo(minThread, selectorToHandlers, sb);
eventCountPerSelector = selectorEvents.get(maxThread);
sb.append("Max Selector ").append(maxThread).append(" received ").append(eventCountPerSelector).append(" events. ");
sb.append("It contains following handlers: ").append(LINE_SEPARATOR);
appendSelectorInfo(maxThread, selectorToHandlers, sb);
sb.append("Other Selectors: ").append(LINE_SEPARATOR);
for (NonBlockingIOThread selector : ioThreads) {
if (!selector.equals(minThread) && !selector.equals(maxThread)) {
eventCountPerSelector = selectorEvents.get(selector);
sb.append("Selector ").append(selector).append(" contains ").append(eventCountPerSelector).append(" and has these handlers: ").append(LINE_SEPARATOR);
appendSelectorInfo(selector, selectorToHandlers, sb);
}
}
sb.append("------------").append(LINE_SEPARATOR);
logger.finest(sb.toString());
}
use of com.hazelcast.internal.networking.nonblocking.NonBlockingIOThread in project hazelcast by hazelcast.
the class LoadTracker method updateHandlerState.
private void updateHandlerState(MigratableHandler handler) {
long handlerEventCount = getEventCountSinceLastCheck(handler);
handlerEventsCounter.set(handler, handlerEventCount);
NonBlockingIOThread owner = handler.getOwner();
selectorEvents.add(owner, handlerEventCount);
Set<MigratableHandler> handlersOwnedBy = selectorToHandlers.get(owner);
handlersOwnedBy.add(handler);
}
use of com.hazelcast.internal.networking.nonblocking.NonBlockingIOThread in project hazelcast by hazelcast.
the class LoadTracker method updateNewFinalImbalance.
private void updateNewFinalImbalance() {
imbalance.minimumEvents = Long.MAX_VALUE;
imbalance.maximumEvents = Long.MIN_VALUE;
imbalance.sourceSelector = null;
imbalance.destinationSelector = null;
for (NonBlockingIOThread selector : ioThreads) {
long eventCount = selectorEvents.get(selector);
int handlerCount = selectorToHandlers.get(selector).size();
if (eventCount > imbalance.maximumEvents && handlerCount > 1) {
// if a selector has only 1 handle, there is no point in making it a source selector since
// there is no handler that can be migrated anyway. In that case it is better to move on to
// the next selector.
imbalance.maximumEvents = eventCount;
imbalance.sourceSelector = selector;
}
if (eventCount < imbalance.minimumEvents) {
imbalance.minimumEvents = eventCount;
imbalance.destinationSelector = selector;
}
}
}
Aggregations