[ 
https://issues.apache.org/jira/browse/YARN-11296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17605022#comment-17605022
 ] 

ASF GitHub Bot commented on YARN-11296:
---------------------------------------

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


##########
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:
   I will fix it.



##########
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:
   I will fix it.





> Fix SQLFederationStateStore#Sql script bug
> ------------------------------------------
>
>                 Key: YARN-11296
>                 URL: https://issues.apache.org/jira/browse/YARN-11296
>             Project: Hadoop YARN
>          Issue Type: Bug
>          Components: federation
>    Affects Versions: 3.4.0
>            Reporter: fanshilun
>            Assignee: fanshilun
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: Improve Query Condition of 
> FederationStateStore#getApplicationsHomeSubCluster Test Report.pdf
>
>
> *MySQL:*
> FederationStateStoreTables.sql cannot create *membership* table, both in 
> MySQL 5.7 and MySQL 8.0.
>  
> {code:java}
> CREATE TABLE membership(
>    subClusterId varchar(256) NOT NULL,
>    amRMServiceAddress varchar(256) NOT NULL,
>    clientRMServiceAddress varchar(256) NOT NULL,
>    rmAdminServiceAddress varchar(256) NOT NULL,
>    rmWebServiceAddress varchar(256) NOT NULL,
>    lastHeartBeat datetime NOT NULL,
>    state varchar(32) NOT NULL,
>    lastStartTime bigint NULL,
>    capability varchar(6000),
>    CONSTRAINT pk_subClusterId PRIMARY KEY (subClusterId), -- missing comma    
> UNIQUE(lastStartTime)
> ); {code}
>  
> *SQLServer:*
> FederationStateStoreTables.sql
>  
> {code:java}
> IF NOT EXISTS ( SELECT * FROM [FederationStateStore].sys.tables
>     WHERE name = 'membership'
>     AND schema_id = SCHEMA_ID('dbo'))
>     BEGIN
>         PRINT 'Table membership does not exist, create it...'
>         SET ANSI_NULLS ON
>         SET QUOTED_IDENTIFIER ON
>         SET ANSI_PADDING ON
>         CREATE TABLE [dbo].[membership](
>             [subClusterId]            VARCHAR(256) COLLATE 
> Latin1_General_100_BIN2 NOT NULL,
>             [amRMServiceAddress]      VARCHAR(256) NOT NULL,
>             [clientRMServiceAddress]  VARCHAR(256) NOT NULL,
>             [rmAdminServiceAddress]   VARCHAR(256) NOT NULL,
>             [rmWebServiceAddress]     VARCHAR(256) NOT NULL,
>             [lastHeartBeat]           DATETIME2 NOT NULL,
>             [state]                   VARCHAR(32) NOT NULL,
>             [lastStartTime]           BIGINT NOT NULL,
>             [capability]              VARCHAR(6000) NOT NULL,
>             CONSTRAINT [pk_subClusterId] PRIMARY KEY
>             (
>                 [subClusterId]
>             ), -- missing comma
>             CONSTRAINT [uc_lastStartTime] UNIQUE
>             (
>                 [lastStartTime]
>             )
>         )
>         SET ANSI_PADDING OFF
>         PRINT 'Table membership created.'
>     END
> ELSE
>     PRINT 'Table membership exists, no operation required...'
>     GO
> GO {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to