kirktrue commented on code in PR #13640: URL: https://github.com/apache/kafka/pull/13640#discussion_r1179776287
########## clients/src/main/java/org/apache/kafka/clients/ClientUtils.java: ########## @@ -134,4 +147,112 @@ static List<InetAddress> filterPreferredAddresses(InetAddress[] allAddresses) { } return preferredAddresses; } + + public static NetworkClient createNetworkClient(AbstractConfig config, + Metrics metrics, + String metricsGroupPrefix, + LogContext logContext, + ApiVersions apiVersions, + Time time, + int maxInFlightRequestsPerConnection, + Metadata metadata, + Sensor sensor) { + ChannelBuilder channelBuilder = null; + Selector selector = null; + + try { + channelBuilder = ClientUtils.createChannelBuilder(config, time, logContext); + selector = new Selector(config.getLong(CommonClientConfigs.CONNECTIONS_MAX_IDLE_MS_CONFIG), + metrics, + time, + metricsGroupPrefix, + channelBuilder, + logContext); + return new NetworkClient(selector, + metadata, + config.getString(CommonClientConfigs.CLIENT_ID_CONFIG), + maxInFlightRequestsPerConnection, + config.getLong(CommonClientConfigs.RECONNECT_BACKOFF_MS_CONFIG), + config.getLong(CommonClientConfigs.RECONNECT_BACKOFF_MAX_MS_CONFIG), + config.getInt(CommonClientConfigs.SEND_BUFFER_CONFIG), + config.getInt(CommonClientConfigs.RECEIVE_BUFFER_CONFIG), + config.getInt(CommonClientConfigs.REQUEST_TIMEOUT_MS_CONFIG), + config.getLong(CommonClientConfigs.SOCKET_CONNECTION_SETUP_TIMEOUT_MS_CONFIG), + config.getLong(CommonClientConfigs.SOCKET_CONNECTION_SETUP_TIMEOUT_MAX_MS_CONFIG), + time, + true, + apiVersions, + sensor, + logContext); + } catch (Throwable t) { + closeQuietly(selector, "Selector"); + closeQuietly(channelBuilder, "ChannelBuilder"); + throw new KafkaException("Failed to create new NetworkClient", t); + } + } + + public static NetworkClient createNetworkClient(AbstractConfig config, Review Comment: Not directly, no. I created another version of `createNetworkClient` that the other two can call, though. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org