1996fanrui commented on code in PR #785:
URL: 
https://github.com/apache/flink-kubernetes-operator/pull/785#discussion_r1528175144


##########
flink-autoscaler-plugin-jdbc/pom.xml:
##########
@@ -140,6 +140,12 @@ under the License.
             <scope>test</scope>
         </dependency>
 
+        <dependency>
+            <groupId>com.zaxxer</groupId>
+            <artifactId>HikariCP</artifactId>
+            <version>5.1.0</version>
+        </dependency>

Review Comment:
   1. The `HikariCP` is production dependency, it's better to move it before 
test related dependencies.
   2. The version is better to extract a property.



##########
flink-autoscaler-standalone/src/main/java/org/apache/flink/autoscaler/standalone/utils/HikariJDBCUtil.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * 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.flink.autoscaler.standalone.utils;
+
+import org.apache.flink.configuration.Configuration;
+
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
+
+import static 
org.apache.flink.autoscaler.standalone.config.AutoscalerStandaloneOptions.JDBC_PASSWORD_ENV_VARIABLE;
+import static 
org.apache.flink.autoscaler.standalone.config.AutoscalerStandaloneOptions.JDBC_URL;
+import static 
org.apache.flink.autoscaler.standalone.config.AutoscalerStandaloneOptions.JDBC_USERNAME;
+import static org.apache.flink.util.Preconditions.checkArgument;
+
+public class HikariJDBCUtil {
+
+    public static HikariDataSource getHikariDataSource(Configuration conf, 
String errMsg) {
+        final var jdbcUrl = conf.get(JDBC_URL);
+        checkArgument(jdbcUrl != null, errMsg, JDBC_URL.key());
+        var user = conf.get(JDBC_USERNAME);
+        var password = 
System.getenv().get(conf.get(JDBC_PASSWORD_ENV_VARIABLE));
+        HikariConfig hikariConfig = new HikariConfig();
+        hikariConfig.setJdbcUrl(jdbcUrl);
+        hikariConfig.setUsername(user);
+        hikariConfig.setPassword(password);

Review Comment:
   The user and password can be null, did you test it with Autoscaler 
Standalone?
   
   Also, could AutoscalerStateStoreFactoryTest use this method as well instead 
of create `HikariConfig` and `HikariDataSource` directly?



-- 
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: issues-unsubscr...@flink.apache.org

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

Reply via email to