Source:
public int warmUpConnections(List<DataNodeId> dataNodeIds, int connectionWarmUpPercentagePerDataNode, long timeForWarmUp) { int expectedConnections = 0; logger.info("Connections warm up start."); for (DataNodeId dataNodeId : dataNodeIds) { int numberOfConnections = connectionWarmUpPercentagePerDataNode * (dataNodeId.getPortToConnectTo().getPortType() == PortType.PLAINTEXT ? connectionTracker.getMaxConnectionsPerPortPlainText() : connectionTracker.getMaxConnectionsPerPortSsl()) / 100; for (int i = 0; i < numberOfConnections; i++) { try { String connId = selector.connect( new InetSocketAddress(dataNodeId.getHostname(), dataNodeId.getPortToConnectTo().getPort()), networkConfig.socketSendBufferBytes, networkConfig.socketReceiveBufferBytes, dataNodeId.getPortToConnectTo().getPortType()); connectionTracker.startTrackingInitiatedConnection(dataNodeId.getHostname(), dataNodeId.getPortToConnectTo(), connId); expectedConnections++; } catch (IOException e) { logger.error("Received exception while warming up connection: {}", e); } } } long startTime = System.currentTimeMillis(); int successfulConnections = 0; int failedConnections = 0; while (successfulConnections + failedConnections < expectedConnections) { try { selector.poll(1000L); successfulConnections += selector.connected().size(); failedConnections += selector.disconnected().size(); handleSelectorEvents(null); } catch (IOException e) { logger.error("Warm up received unexpected error while polling: {}", e); } if (System.currentTimeMillis() - startTime > timeForWarmUp) { break; } } logger.info("Connections warm up done. Tried: Success: Failed: Time elapsed: {}ms", expectedConnections, successfulConnections, failedConnections, System.currentTimeMillis() - startTime); return successfulConnections; }

Target:
public int warmUpConnections(List<DataNodeId> dataNodeIds, int connectionWarmUpPercentagePerDataNode, long timeForWarmUp) { int expectedConnections = 0; logger.info("Connections warm up start."); if (dataNodeIds.size() == 0) { return 0; } int numberOfConnections = connectionWarmUpPercentagePerDataNode == 0 ? 0 : Math.max(1, connectionWarmUpPercentagePerDataNode * ( dataNodeIds.get(0).getPortToConnectTo().getPortType() == PortType.PLAINTEXT ? connectionTracker.getMaxConnectionsPerPortPlainText() : connectionTracker.getMaxConnectionsPerPortSsl()) / 100); for (DataNodeId dataNodeId : dataNodeIds) { for (int i = 0; i < numberOfConnections; i++) { try { String connId = selector.connect( new InetSocketAddress(dataNodeId.getHostname(), dataNodeId.getPortToConnectTo().getPort()), networkConfig.socketSendBufferBytes, networkConfig.socketReceiveBufferBytes, dataNodeId.getPortToConnectTo().getPortType()); connectionTracker.startTrackingInitiatedConnection(dataNodeId.getHostname(), dataNodeId.getPortToConnectTo(), connId); expectedConnections++; } catch (IOException e) { logger.error("Received exception while warming up connection: {}", e); } } } long startTime = System.currentTimeMillis(); int successfulConnections = 0; int failedConnections = 0; while (successfulConnections + failedConnections < expectedConnections) { try { selector.poll(1000L); successfulConnections += selector.connected().size(); failedConnections += selector.disconnected().size(); handleSelectorEvents(null); } catch (IOException e) { logger.error("Warm up received unexpected error while polling: {}", e); } if (System.currentTimeMillis() - startTime > timeForWarmUp) { break; } } logger.info("Connections warm up done. Tried: Success: Failed: Time elapsed: {}ms", expectedConnections, successfulConnections, failedConnections, System.currentTimeMillis() - startTime); return successfulConnections; }