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

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

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


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/federation/store/sql/TestFederationSQLServerScriptAccuracy.java:
##########
@@ -0,0 +1,62 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.hadoop.yarn.server.federation.store.sql;
+
+import org.apache.hadoop.yarn.conf.YarnConfiguration;
+import 
org.apache.hadoop.yarn.server.federation.store.impl.SQLServerFederationStateStore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.SQLException;
+import java.util.List;
+
+public class TestFederationSQLServerScriptAccuracy extends 
FederationSQLAccuracyTest {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(TestFederationSQLServerScriptAccuracy.class);
+
+  private final String DATABASE_URL_SQLSERVER = 
"jdbc:hsqldb:mem-sqlserver:state-sqlserver";
+  private final String SQLSERVER_COMPATIBILITY = ";sql.syntax_mss=true";
+
+  @Override
+  protected SQLServerFederationStateStore createStateStore() {
+    YarnConfiguration conf = new YarnConfiguration();
+    conf.set(YarnConfiguration.FEDERATION_STATESTORE_SQL_JDBC_CLASS, 
HSQLDB_DRIVER);
+    conf.set(YarnConfiguration.FEDERATION_STATESTORE_SQL_USERNAME, 
DATABASE_USERNAME);
+    conf.set(YarnConfiguration.FEDERATION_STATESTORE_SQL_PASSWORD, 
DATABASE_PASSWORD);
+    conf.set(YarnConfiguration.FEDERATION_STATESTORE_SQL_URL,

Review Comment:
   I will refactor this part of the code.





> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to