private EventExecutor chooseWithLeastConns() { EventExecutor leastExec = null; int leastValue = Integer.MAX_VALUE; Map<Thread, Integer> connsPer = groupMetrics.connectionsPerEventLoop(); // Shuffle the list of executors each time so that if they all have the same number of connections, then // we don't favour the 1st one. Collections.shuffle(executors, ThreadLocalRandom.current()); for (EventExecutor executor : executors) { int value = connsPer.getOrDefault(executor, 0); if (value < leastValue) { leastValue = value; leastExec = executor; } } // If none chosen, then just use first. if (leastExec == null) { leastExec = executors.get(0); } if (LOG.isDebugEnabled()) { LOG.debug("Chose eventloop: " + String.valueOf(leastExec) + ", leastValue=" + leastValue + ", connsPer=" + String.valueOf(connsPer)); } return leastExec; } }
private EventExecutor chooseWithLeastConns() { EventExecutor leastExec = null; int leastValue = Integer.MAX_VALUE; Map<Thread, Integer> connsPer = groupMetrics.connectionsPerEventLoop(); // Shuffle the list of executors each time so that if they all have the same number of connections, then // we don't favour the 1st one. Collections.shuffle(executors, ThreadLocalRandom.current()); for (EventExecutor executor : executors) { int value = connsPer.getOrDefault(executor, 0); if (value < leastValue) { leastValue = value; leastExec = executor; } } // If none chosen, then just use first. if (leastExec == null) { leastExec = executors.get(0); } if (LOG.isDebugEnabled()) { LOG.debug("Chose eventloop: " + String.valueOf(leastExec) + ", leastValue=" + leastValue + ", connsPer=" + String.valueOf(connsPer)); } return leastExec; } }
private EventExecutor chooseWithLeastConns() { EventExecutor leastExec = null; int leastValue = Integer.MAX_VALUE; Map<Thread, Integer> connsPer = groupMetrics.connectionsPerEventLoop(); // Shuffle the list of executors each time so that if they all have the same number of connections, then // we don't favour the 1st one. Collections.shuffle(executors, ThreadLocalRandom.current()); for (EventExecutor executor : executors) { int value = connsPer.getOrDefault(executor, 0); if (value < leastValue) { leastValue = value; leastExec = executor; } } // If none chosen, then just use first. if (leastExec == null) { leastExec = executors.get(0); } if (LOG.isDebugEnabled()) { LOG.debug("Chose eventloop: " + String.valueOf(leastExec) + ", leastValue=" + leastValue + ", connsPer=" + String.valueOf(connsPer)); } return leastExec; } }