You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/04/27 17:38:17 UTC

[GitHub] [pinot] walterddr commented on a diff in pull request #8578: Add TLS configuration to JDBC driver

walterddr commented on code in PR #8578:
URL: https://github.com/apache/pinot/pull/8578#discussion_r860078484


##########
pinot-clients/pinot-jdbc-client/src/main/java/org/apache/pinot/client/utils/DriverUtils.java:
##########
@@ -38,9 +41,31 @@ public class DriverUtils {
   public static final String CONTROLLER = "controller";
   private static final String LIMIT_STATEMENT_REGEX = "\\s(limit)\\s";
 
+  // SSL Properties
+  public static final String KEYSTORE_TYPE = "keystore.type";
+  public static final String KEYSTORE_PATH = "keystore.path";
+  public static final String KEYSTORE_PASSWORD = "keystore.password";
+  public static final String TRUSTSTORE_TYPE = "truststore.type";
+  public static final String TRUSTSTORE_PATH = "truststore.path";
+  public static final String TRUSTSTORE_PASSWORD = "truststore.password";
+
   private DriverUtils() {
   }
 
+  public static SSLContext getSSLContextFromJDBCProps(Properties properties) {

Review Comment:
   why do we need one additional sslContext parser when TlsUtils already has one? (otherwise we need to make sure the static keyword here matches TlsUtils ones)



##########
pinot-clients/pinot-jdbc-client/src/main/java/org/apache/pinot/client/controller/PinotControllerTransport.java:
##########
@@ -38,19 +45,39 @@ public class PinotControllerTransport {
 
   private static final Logger LOGGER = LoggerFactory.getLogger(PinotControllerTransport.class);
 
-  AsyncHttpClient _httpClient = Dsl.asyncHttpClient();
   Map<String, String> _headers;
+  private final String _scheme;
+  private final AsyncHttpClient _httpClient;
+
 
   public PinotControllerTransport() {
+    _headers = new HashMap<>();
+    _scheme = CommonConstants.HTTP_PROTOCOL;
+    _httpClient = Dsl.asyncHttpClient();

Review Comment:
   ```suggestion
       this(Collections.emptyMap(), CommonConstants.HTTP_PROTOCOL, null);
   ```



##########
pinot-clients/pinot-jdbc-client/src/main/java/org/apache/pinot/client/controller/PinotControllerTransport.java:
##########
@@ -38,19 +45,39 @@ public class PinotControllerTransport {
 
   private static final Logger LOGGER = LoggerFactory.getLogger(PinotControllerTransport.class);
 
-  AsyncHttpClient _httpClient = Dsl.asyncHttpClient();
   Map<String, String> _headers;
+  private final String _scheme;
+  private final AsyncHttpClient _httpClient;
+
 
   public PinotControllerTransport() {
+    _headers = new HashMap<>();
+    _scheme = CommonConstants.HTTP_PROTOCOL;
+    _httpClient = Dsl.asyncHttpClient();
   }
 
   public PinotControllerTransport(Map<String, String> headers) {
     _headers = headers;
+    _scheme = CommonConstants.HTTP_PROTOCOL;
+    _httpClient = Dsl.asyncHttpClient();

Review Comment:
   ```suggestion
       this(headers, CommonConstants.HTTP_PROTOCOL, null);
   ```



##########
pinot-clients/pinot-jdbc-client/src/main/java/org/apache/pinot/client/controller/PinotControllerTransportFactory.java:
##########
@@ -0,0 +1,59 @@
+/**
+ * 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.controller;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.net.ssl.SSLContext;
+import org.apache.pinot.spi.utils.CommonConstants;
+
+
+public class PinotControllerTransportFactory {

Review Comment:
   IMO this is not so much as a builder pattern because if the scheme is HTTP, SSL is not used (if I understand correctly) 
   --> this means you have to do a if check in where you use the builder anyway, might as well just call the corresponding constructor of PinotControllerTransport



-- 
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-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org