KKcorps commented on code in PR #9008: URL: https://github.com/apache/pinot/pull/9008#discussion_r932993337
########## pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/JsonAsyncHttpPinotClientTransportFactory.java: ########## @@ -60,4 +72,18 @@ public SSLContext getSslContext() { public void setSslContext(SSLContext sslContext) { _sslContext = sslContext; } + + public JsonAsyncHttpPinotClientTransportFactory withConnectionProperties(Properties properties) { + _readTimeout = Integer.parseInt(properties.getProperty("brokerReadTimeout", Review Comment: Since we expect timeouts to be in milliseconds, we should add this to property name as well. e.g. `brokerReadTimeoutMs` ########## pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/JsonAsyncHttpPinotClientTransport.java: ########## @@ -90,14 +95,32 @@ public JsonAsyncHttpPinotClientTransport(Map<String, String> headers, String sch builder.setSslContext(sslContext); } + builder.setReadTimeout(connectionTimeouts.getReadTimeout()) + .setConnectTimeout(connectionTimeouts.getConnectTimeout()) + .setHandshakeTimeout(connectionTimeouts.getHandshakeTimeout()) + .setUserAgent(getUserAgentVersionFromClassPath()) + .setEnabledProtocols(tlsProtocols.getEnabledProtocols().toArray(new String[0])); _httpClient = Dsl.asyncHttpClient(builder.build()); } + private String getUserAgentVersionFromClassPath() { + Properties userAgentProperties = new Properties(); + try { + userAgentProperties.load(JsonAsyncHttpPinotClientTransport.class.getClassLoader() + .getResourceAsStream("version.properties")); + } catch (IOException e) { + LOGGER.info("Unable to set user agent version"); Review Comment: nit: `LOGGER.warn` ########## pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/ConnectionTimeouts.java: ########## @@ -0,0 +1,53 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.client; + +/** + * Connections time out for AsyncHttpClient + */ +public class ConnectionTimeouts { + private final int _readTimeout; Review Comment: nit: we can provide timeunit in the variable for better clarity. e.g. `_readTimeoutMs` if we expect it in milliseconds ########## pinot-clients/pinot-jdbc-client/src/main/java/org/apache/pinot/client/controller/PinotControllerTransportFactory.java: ########## @@ -56,4 +71,18 @@ public SSLContext getSslContext() { public void setSslContext(SSLContext sslContext) { _sslContext = sslContext; } + + public PinotControllerTransportFactory withConnectionProperties(Properties properties) { + _readTimeout = Integer.parseInt(properties.getProperty("controllerReadTimeout", Review Comment: Same as before, property names should reflect time units if it is not configurable ########## pinot-clients/pinot-jdbc-client/src/main/java/org/apache/pinot/client/controller/PinotControllerTransport.java: ########## @@ -68,9 +62,26 @@ public PinotControllerTransport(Map<String, String> headers, String scheme, builder.setSslContext(new JdkSslContext(sslContext, true, ClientAuth.OPTIONAL)); } + builder.setReadTimeout(connectionTimeouts.getReadTimeout()) + .setConnectTimeout(connectionTimeouts.getConnectTimeout()) + .setHandshakeTimeout(connectionTimeouts.getHandshakeTimeout()) + .setUserAgent(getUserAgentVersionFromClassPath()) + .setEnabledProtocols(tlsProtocols.getEnabledProtocols().toArray(new String[0])); + _httpClient = Dsl.asyncHttpClient(builder.build()); } + private String getUserAgentVersionFromClassPath() { + Properties userAgentProperties = new Properties(); + try { + userAgentProperties.load(JsonAsyncHttpPinotClientTransport.class.getClassLoader() + .getResourceAsStream("version.properties")); + } catch (IOException e) { + LOGGER.info("Unable to set user agent version"); Review Comment: should be `LOGGER..warn` ########## pinot-clients/pinot-jdbc-client/src/main/java/org/apache/pinot/client/controller/PinotControllerTransport.java: ########## @@ -68,9 +62,26 @@ public PinotControllerTransport(Map<String, String> headers, String scheme, builder.setSslContext(new JdkSslContext(sslContext, true, ClientAuth.OPTIONAL)); } + builder.setReadTimeout(connectionTimeouts.getReadTimeout()) + .setConnectTimeout(connectionTimeouts.getConnectTimeout()) + .setHandshakeTimeout(connectionTimeouts.getHandshakeTimeout()) + .setUserAgent(getUserAgentVersionFromClassPath()) + .setEnabledProtocols(tlsProtocols.getEnabledProtocols().toArray(new String[0])); + _httpClient = Dsl.asyncHttpClient(builder.build()); } + private String getUserAgentVersionFromClassPath() { + Properties userAgentProperties = new Properties(); + try { + userAgentProperties.load(JsonAsyncHttpPinotClientTransport.class.getClassLoader() Review Comment: No need to import `JsonAsyncHttpPinotClientTransport` for this -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org