apucher commented on a change in pull request #7010:
URL: https://github.com/apache/incubator-pinot/pull/7010#discussion_r645170179



##########
File path: 
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/ConnectionFactory.java
##########
@@ -40,20 +37,20 @@ private ConnectionFactory() {
    * @return A connection that connects to the brokers in the given Helix 
cluster
    */
   public static Connection fromZookeeper(String zkUrl) {
-    return fromZookeeper(zkUrl, null);
+    return fromZookeeper(zkUrl, new 
JsonAsyncHttpPinotClientTransportFactory().buildTransport());

Review comment:
       done. lazy default instance

##########
File path: 
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/JsonAsyncHttpPinotClientTransport.java
##########
@@ -23,30 +23,47 @@
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.ning.http.client.AsyncHttpClient;
+import com.ning.http.client.AsyncHttpClientConfig;
 import com.ning.http.client.Response;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
+import javax.net.ssl.SSLContext;
+import org.apache.pinot.spi.utils.CommonConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
 /**
  * JSON encoded Pinot client transport over AsyncHttpClient.
  */
-class JsonAsyncHttpPinotClientTransport implements PinotClientTransport {
+public class JsonAsyncHttpPinotClientTransport implements PinotClientTransport 
{
   private static final Logger LOGGER = 
LoggerFactory.getLogger(JsonAsyncHttpPinotClientTransport.class);
   private static final ObjectReader OBJECT_READER = new 
ObjectMapper().reader();
 
-  AsyncHttpClient _httpClient = new AsyncHttpClient();
-  Map<String, String> _headers;
+  AsyncHttpClient _httpClient;
+
+  Map<String, String> _headers = new HashMap<>();
+  String _scheme = CommonConstants.HTTP_PROTOCOL;
+  SSLContext _sslContext = null;

Review comment:
       done. all final

##########
File path: 
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/JsonAsyncHttpPinotClientTransportFactory.java
##########
@@ -18,19 +18,46 @@
  */
 package org.apache.pinot.client;
 
+import java.util.HashMap;
 import java.util.Map;
+import javax.net.ssl.SSLContext;
+import org.apache.pinot.spi.utils.CommonConstants;
+
 
 /**
  * Pinot client transport factory for JSON encoded BrokerResults through HTTP.
  */
-class JsonAsyncHttpPinotClientTransportFactory implements 
PinotClientTransportFactory {
+public class JsonAsyncHttpPinotClientTransportFactory implements 
PinotClientTransportFactory {
+  Map<String, String> _headers = new HashMap<>();
+  String _scheme = CommonConstants.HTTP_PROTOCOL;
+  SSLContext _sslContext = null;

Review comment:
       done

##########
File path: 
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/JsonAsyncHttpPinotClientTransport.java
##########
@@ -23,30 +23,47 @@
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.ning.http.client.AsyncHttpClient;
+import com.ning.http.client.AsyncHttpClientConfig;
 import com.ning.http.client.Response;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
+import javax.net.ssl.SSLContext;
+import org.apache.pinot.spi.utils.CommonConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
 /**
  * JSON encoded Pinot client transport over AsyncHttpClient.
  */
-class JsonAsyncHttpPinotClientTransport implements PinotClientTransport {
+public class JsonAsyncHttpPinotClientTransport implements PinotClientTransport 
{
   private static final Logger LOGGER = 
LoggerFactory.getLogger(JsonAsyncHttpPinotClientTransport.class);
   private static final ObjectReader OBJECT_READER = new 
ObjectMapper().reader();
 
-  AsyncHttpClient _httpClient = new AsyncHttpClient();
-  Map<String, String> _headers;
+  AsyncHttpClient _httpClient;
+
+  Map<String, String> _headers = new HashMap<>();
+  String _scheme = CommonConstants.HTTP_PROTOCOL;
+  SSLContext _sslContext = null;
 
   public JsonAsyncHttpPinotClientTransport() {
+    _httpClient = new AsyncHttpClient();
   }
 
-  public JsonAsyncHttpPinotClientTransport(Map<String, String> headers) {
+  public JsonAsyncHttpPinotClientTransport(SSLContext sslContext, Map<String, 
String> headers, String scheme) {

Review comment:
       added annotation to sslContext

##########
File path: 
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/JsonAsyncHttpPinotClientTransport.java
##########
@@ -23,30 +23,47 @@
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.ning.http.client.AsyncHttpClient;
+import com.ning.http.client.AsyncHttpClientConfig;
 import com.ning.http.client.Response;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
+import javax.net.ssl.SSLContext;
+import org.apache.pinot.spi.utils.CommonConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
 /**
  * JSON encoded Pinot client transport over AsyncHttpClient.
  */
-class JsonAsyncHttpPinotClientTransport implements PinotClientTransport {
+public class JsonAsyncHttpPinotClientTransport implements PinotClientTransport 
{
   private static final Logger LOGGER = 
LoggerFactory.getLogger(JsonAsyncHttpPinotClientTransport.class);
   private static final ObjectReader OBJECT_READER = new 
ObjectMapper().reader();
 
-  AsyncHttpClient _httpClient = new AsyncHttpClient();
-  Map<String, String> _headers;
+  AsyncHttpClient _httpClient;
+
+  Map<String, String> _headers = new HashMap<>();
+  String _scheme = CommonConstants.HTTP_PROTOCOL;
+  SSLContext _sslContext = null;
 
   public JsonAsyncHttpPinotClientTransport() {
+    _httpClient = new AsyncHttpClient();
   }
 
-  public JsonAsyncHttpPinotClientTransport(Map<String, String> headers) {
+  public JsonAsyncHttpPinotClientTransport(SSLContext sslContext, Map<String, 
String> headers, String scheme) {
     _headers = headers;
+    _scheme = scheme;

Review comment:
       now requires explicit non-null value

##########
File path: 
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/BasicAuthTlsRealtimeIntegrationTest.java
##########
@@ -0,0 +1,260 @@
+/**
+ * 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.integration.tests;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.base.Preconditions;
+import groovy.lang.IntRange;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.pinot.client.Connection;
+import org.apache.pinot.client.ConnectionFactory;
+import org.apache.pinot.client.JsonAsyncHttpPinotClientTransportFactory;
+import org.apache.pinot.client.Request;
+import org.apache.pinot.client.ResultSetGroup;
+import org.apache.pinot.common.utils.FileUploadDownloadClient;
+import org.apache.pinot.core.common.MinionConstants;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.TableTaskConfig;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.env.PinotConfiguration;
+import org.apache.pinot.spi.utils.JsonUtils;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.apache.pinot.util.TestUtils;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static 
org.apache.pinot.integration.tests.BasicAuthTestUtils.AUTH_HEADER;
+
+
+public class BasicAuthTlsRealtimeIntegrationTest extends 
BaseClusterIntegrationTest {

Review comment:
       imo since this is a cross-integration test we should at least be able to 
tell which aspect broke.
   
   Pinot isn't very helpful debugging these issues. If we remove the auth 
realtime test, we'll end up trouble shooting two enormous aspects - tls AND 
auth - when a breaking change happens.

##########
File path: 
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/ClusterTest.java
##########
@@ -131,6 +131,27 @@ protected void startBrokers(int numBrokers, int basePort, 
String zkStr)
     _brokerBaseApiUrl = "http://localhost:"; + _brokerPorts.get(0);
   }
 
+  protected void startBrokerHttps()
+      throws Exception {
+    _brokerStarters = new ArrayList<>();
+    _brokerPorts = new ArrayList<>();
+
+    Map<String, Object> properties = getDefaultBrokerConfiguration().toMap();
+    properties.put(Broker.CONFIG_OF_BROKER_TIMEOUT_MS, 60 * 1000L);
+    properties.put(Broker.CONFIG_OF_DELAY_SHUTDOWN_TIME_MS, 0);
+
+    PinotConfiguration configuration = new PinotConfiguration(properties);
+    overrideBrokerConf(configuration);
+
+    HelixBrokerStarter brokerStarter =
+        new HelixBrokerStarter(configuration, getHelixClusterName(), 
getZkUrl(), LOCAL_HOST);
+    brokerStarter.start();
+    _brokerStarters.add(brokerStarter);
+
+    _brokerPorts.add(DEFAULT_BROKER_PORT);

Review comment:
       I get your point, however, the broker's TLS listener spec requires 
hard-coding port numbers anyways

##########
File path: 
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/ClusterTest.java
##########
@@ -79,7 +79,7 @@
  */
 public abstract class ClusterTest extends ControllerTest {
   private static final Logger LOGGER = 
LoggerFactory.getLogger(ClusterTest.class);
-  private static final int DEFAULT_BROKER_PORT = 18099;
+  protected static final int DEFAULT_BROKER_PORT = 18099;

Review comment:
       see above

##########
File path: 
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/ClusterTest.java
##########
@@ -196,6 +217,24 @@ protected void startServers(int numServers, 
PinotConfiguration configuration, in
     }
   }
 
+  protected void startServerHttps() {
+    FileUtils.deleteQuietly(new File(Server.DEFAULT_INSTANCE_BASE_DIR));
+    _serverStarters = new ArrayList<>();
+
+    Map<String, Object> properties = getDefaultServerConfiguration().toMap();
+
+    PinotConfiguration configuration = new PinotConfiguration(properties);
+    overrideServerConf(configuration);

Review comment:
       turns out the test code already sets default values for pinot server in 
involved ways. imo pinot's test code should be cleaned up, but that's another 
story

##########
File path: 
pinot-core/src/main/java/org/apache/pinot/server/realtime/ServerSegmentCompletionProtocolHandler.java
##########
@@ -64,6 +65,7 @@ public static void init(PinotConfiguration uploaderConfig) {
       _sslContext = new 
ClientSSLContextGenerator(httpsConfig.subset(CommonConstants.PREFIX_OF_SSL_SUBSET)).generate();
       _controllerHttpsPort = 
httpsConfig.getProperty(CONFIG_OF_CONTROLLER_HTTPS_PORT, Integer.class);
     }
+    _protocol = uploaderConfig.getProperty(CONFIG_OF_PROTOCOL, HTTP_PROTOCOL);

Review comment:
       unfortunately, the way `ServerSegmentCompletionProtocolHandler` is 
written and used, there's no sane way to pass "non-specific" configs. Afaik 
LinkedIn has some internal dependencies on this behavior, so I can't change it 
either.

##########
File path: 
pinot-controller/src/test/java/org/apache/pinot/controller/helix/ControllerTest.java
##########
@@ -158,8 +159,17 @@ protected void startController(Map<String, Object> 
properties) {
 
     ControllerConf config = new ControllerConf(properties);
 
-    _controllerPort = Integer.valueOf(config.getControllerPort());
-    _controllerBaseApiUrl = "http://localhost:"; + _controllerPort;
+    String controllerScheme = "http";
+    if (StringUtils.isNotBlank(config.getControllerVipProtocol())) {
+      controllerScheme = config.getControllerVipProtocol();
+    }
+
+    _controllerPort = DEFAULT_CONTROLLER_PORT;
+    if (StringUtils.isNotBlank(config.getControllerPort())) {

Review comment:
       this has changed with the TLS listener spec PR. if `controller.port` is 
set we turn it into a spec, but it's optional as long as there's a spec.

##########
File path: 
pinot-core/src/main/java/org/apache/pinot/server/realtime/ServerSegmentCompletionProtocolHandler.java
##########
@@ -64,6 +65,7 @@ public static void init(PinotConfiguration uploaderConfig) {
       _sslContext = new 
ClientSSLContextGenerator(httpsConfig.subset(CommonConstants.PREFIX_OF_SSL_SUBSET)).generate();
       _controllerHttpsPort = 
httpsConfig.getProperty(CONFIG_OF_CONTROLLER_HTTPS_PORT, Integer.class);
     }
+    _protocol = uploaderConfig.getProperty(CONFIG_OF_PROTOCOL, HTTP_PROTOCOL);

Review comment:
       `CONFIG_OF_CONTROLLER_HTTPS_ENABLED` really is a feature flag that 
configures a hand-rolled TLS key and truststore. it also requires a dedicated 
https port (there may be only one)

##########
File path: 
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/ClusterTest.java
##########
@@ -131,6 +131,27 @@ protected void startBrokers(int numBrokers, int basePort, 
String zkStr)
     _brokerBaseApiUrl = "http://localhost:"; + _brokerPorts.get(0);
   }
 
+  protected void startBrokerHttps()
+      throws Exception {
+    _brokerStarters = new ArrayList<>();
+    _brokerPorts = new ArrayList<>();
+
+    Map<String, Object> properties = getDefaultBrokerConfiguration().toMap();
+    properties.put(Broker.CONFIG_OF_BROKER_TIMEOUT_MS, 60 * 1000L);
+    properties.put(Broker.CONFIG_OF_DELAY_SHUTDOWN_TIME_MS, 0);
+
+    PinotConfiguration configuration = new PinotConfiguration(properties);
+    overrideBrokerConf(configuration);
+
+    HelixBrokerStarter brokerStarter =
+        new HelixBrokerStarter(configuration, getHelixClusterName(), 
getZkUrl(), LOCAL_HOST);
+    brokerStarter.start();
+    _brokerStarters.add(brokerStarter);
+
+    _brokerPorts.add(DEFAULT_BROKER_PORT);

Review comment:
       added

##########
File path: 
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/BasicAuthTlsRealtimeIntegrationTest.java
##########
@@ -0,0 +1,260 @@
+/**
+ * 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.integration.tests;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.base.Preconditions;
+import groovy.lang.IntRange;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.pinot.client.Connection;
+import org.apache.pinot.client.ConnectionFactory;
+import org.apache.pinot.client.JsonAsyncHttpPinotClientTransportFactory;
+import org.apache.pinot.client.Request;
+import org.apache.pinot.client.ResultSetGroup;
+import org.apache.pinot.common.utils.FileUploadDownloadClient;
+import org.apache.pinot.core.common.MinionConstants;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.TableTaskConfig;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.env.PinotConfiguration;
+import org.apache.pinot.spi.utils.JsonUtils;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.apache.pinot.util.TestUtils;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static 
org.apache.pinot.integration.tests.BasicAuthTestUtils.AUTH_HEADER;
+
+
+public class BasicAuthTlsRealtimeIntegrationTest extends 
BaseClusterIntegrationTest {

Review comment:
       added, plus some javadoc

##########
File path: 
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/JsonAsyncHttpPinotClientTransport.java
##########
@@ -23,30 +23,49 @@
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.ning.http.client.AsyncHttpClient;
+import com.ning.http.client.AsyncHttpClientConfig;
 import com.ning.http.client.Response;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
+import javax.annotation.Nullable;
+import javax.net.ssl.SSLContext;
+import org.apache.pinot.spi.utils.CommonConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
 /**
  * JSON encoded Pinot client transport over AsyncHttpClient.
  */
-class JsonAsyncHttpPinotClientTransport implements PinotClientTransport {
+public class JsonAsyncHttpPinotClientTransport implements PinotClientTransport 
{
   private static final Logger LOGGER = 
LoggerFactory.getLogger(JsonAsyncHttpPinotClientTransport.class);
   private static final ObjectReader OBJECT_READER = new 
ObjectMapper().reader();
 
-  AsyncHttpClient _httpClient = new AsyncHttpClient();
-  Map<String, String> _headers;
+  private final Map<String, String> _headers;
+  private final String _scheme;
+
+  private final AsyncHttpClient _httpClient;
 
   public JsonAsyncHttpPinotClientTransport() {
+    _headers = new HashMap<>();
+    _scheme = CommonConstants.HTTP_PROTOCOL;
+    _httpClient = new AsyncHttpClient();
   }
 
-  public JsonAsyncHttpPinotClientTransport(Map<String, String> headers) {
+  public JsonAsyncHttpPinotClientTransport(@Nullable SSLContext sslContext, 
Map<String, String> headers,

Review comment:
       done




-- 
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.

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

Reply via email to