goiri commented on code in PR #4858:
URL: https://github.com/apache/hadoop/pull/4858#discussion_r971047522


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/impl/HSQLDBFederationStateStore.java:
##########
@@ -356,4 +376,31 @@ public void closeConnection() {
     }
   }
 
+  /**
+   * Extract The Create Table Sql From The Script.
+   *
+   * @param dbIdentifier database identifier, Like Mysql / SqlServer
+   * @param regex the regex
+   * @throws IOException IO exception.
+   */
+  protected void extractCreateTableSQL(String dbIdentifier, String regex) 
throws IOException {
+    String createTableScriptPath = "." + File.separator + "target" + 
File.separator +
+        "test-classes" + File.separator + dbIdentifier + 
"/FederationStateStoreTables.sql";
+    String createTableSQL =
+        FileUtils.readFileToString(new File(createTableScriptPath), 
StandardCharsets.UTF_8);
+    Pattern p = Pattern.compile(regex);
+    Matcher m = p.matcher(createTableSQL);
+    while(m!=null && m.find()) {

Review Comment:
   space after while



##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/impl/HSQLDBFederationStateStore.java:
##########
@@ -301,14 +309,17 @@ public class HSQLDBFederationStateStore extends 
SQLFederationStateStore {
           + " WHERE reservationId = reservationId_IN;"
           + " SET rowCount_OUT = 2; END";
 
+  private List<String> tables = new ArrayList<>();
 
   @Override
   public void init(Configuration conf) {
+

Review Comment:
   Avoid



##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/impl/HSQLDBFederationStateStore.java:
##########
@@ -342,11 +353,20 @@ public void init(Configuration conf) {
       conn.prepareStatement(SP_UPDATERESERVATIONHOMESUBCLUSTER).execute();
 
       LOG.info("Database Init: Complete");
-    } catch (SQLException e) {
+    } catch (Exception e) {
       LOG.error("ERROR: failed to inizialize HSQLDB " + e.getMessage());

Review Comment:
   Use logger {}



##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/impl/HSQLDBFederationStateStore.java:
##########
@@ -301,14 +309,17 @@ public class HSQLDBFederationStateStore extends 
SQLFederationStateStore {
           + " WHERE reservationId = reservationId_IN;"
           + " SET rowCount_OUT = 2; END";
 
+  private List<String> tables = new ArrayList<>();
 
   @Override
   public void init(Configuration conf) {
+
     try {
       super.init(conf);
     } catch (YarnException e1) {
       LOG.error("ERROR: failed to init HSQLDB " + e1.getMessage());
     }
+

Review Comment:
   Avoid



##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/impl/HSQLDBFederationStateStore.java:
##########
@@ -342,11 +353,20 @@ public void init(Configuration conf) {
       conn.prepareStatement(SP_UPDATERESERVATIONHOMESUBCLUSTER).execute();
 
       LOG.info("Database Init: Complete");
-    } catch (SQLException e) {
+    } catch (Exception e) {
       LOG.error("ERROR: failed to inizialize HSQLDB " + e.getMessage());
     }
   }
 
+  public void initConnection(Configuration conf) {
+    try {
+      super.init(conf);
+      conn = super.conn;
+    } catch (YarnException e1) {
+      LOG.error("ERROR: failed to init HSQLDB " + e1.getMessage());

Review Comment:
   Use {}



##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/impl/HSQLDBFederationStateStore.java:
##########
@@ -356,4 +376,31 @@ public void closeConnection() {
     }
   }
 
+  /**
+   * Extract The Create Table Sql From The Script.
+   *
+   * @param dbIdentifier database identifier, Like Mysql / SqlServer
+   * @param regex the regex
+   * @throws IOException IO exception.
+   */
+  protected void extractCreateTableSQL(String dbIdentifier, String regex) 
throws IOException {
+    String createTableScriptPath = "." + File.separator + "target" + 
File.separator +

Review Comment:
   It might be cleaner to use String.format()



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

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


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to