You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/06/07 07:38:12 UTC

[GitHub] [flink] fsk119 opened a new pull request, #19894: [FLINK-27931][sql-gateway] Introduce the SqlGateway to assemble all components

fsk119 opened a new pull request, #19894:
URL: https://github.com/apache/flink/pull/19894

   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   *Add the main entry for the SqlGateway that assembles all components.*
   
   
   ## Brief change log
   
     - *Add the SqlGateway to assemble all components.*
   
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - *Added the test to verify whether can load the specified endpoint and startup.*
     - *Added the test to verify the print help message*
     - *Added the test to verify to specify duplicate identifiers.*
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / **no**)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
     - The serializers: (yes / **no** / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / **no** / don't know)
     - The S3 file system connector: (yes / **no** / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / **no**)
     - If yes, how is the feature documented? (not applicable / docs / **JavaDocs** / not documented)
   


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

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


[GitHub] [flink] fsk119 commented on a diff in pull request #19894: [FLINK-27931][sql-gateway] Introduce the SqlGateway to assemble all components

Posted by GitBox <gi...@apache.org>.
fsk119 commented on code in PR #19894:
URL: https://github.com/apache/flink/pull/19894#discussion_r926308243


##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/SqlGateway.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.table.gateway;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.ConfigurationUtils;
+import org.apache.flink.table.gateway.api.SqlGatewayService;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpoint;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpointFactoryUtils;
+import org.apache.flink.table.gateway.api.utils.SqlGatewayException;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptions;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptionsParser;
+import org.apache.flink.table.gateway.service.SqlGatewayServiceImpl;
+import org.apache.flink.table.gateway.service.context.DefaultContext;
+import org.apache.flink.table.gateway.service.session.SessionManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+
+/** Main entry point for the SQL Gateway. */
+public class SqlGateway {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SqlGateway.class);
+
+    private final CountDownLatch latch;
+
+    private SessionManager sessionManager;
+    private final List<SqlGatewayEndpoint> endpoints;
+    private final Properties dynamicConfig;
+
+    public SqlGateway(Properties dynamicConfig) {
+        endpoints = new ArrayList<>();
+        latch = new CountDownLatch(1);
+
+        this.dynamicConfig = dynamicConfig;
+    }
+
+    public void start() {

Review Comment:
   Ok. I have already implemented this feature.



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

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


[GitHub] [flink] flinkbot commented on pull request #19894: [FLINK-27931][sql-gateway] Introduce the SqlGateway to assemble all components

Posted by GitBox <gi...@apache.org>.
flinkbot commented on PR #19894:
URL: https://github.com/apache/flink/pull/19894#issuecomment-1148313493

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "5a2ac8133abffebb85aac92ff2142d31ec07caff",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "5a2ac8133abffebb85aac92ff2142d31ec07caff",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 5a2ac8133abffebb85aac92ff2142d31ec07caff UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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

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


[GitHub] [flink] lsyldliu commented on a diff in pull request #19894: [FLINK-27931][sql-gateway] Introduce the SqlGateway to assemble all components

Posted by GitBox <gi...@apache.org>.
lsyldliu commented on code in PR #19894:
URL: https://github.com/apache/flink/pull/19894#discussion_r925587246


##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/SqlGateway.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.table.gateway;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.ConfigurationUtils;
+import org.apache.flink.table.gateway.api.SqlGatewayService;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpoint;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpointFactoryUtils;
+import org.apache.flink.table.gateway.api.utils.SqlGatewayException;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptions;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptionsParser;
+import org.apache.flink.table.gateway.service.SqlGatewayServiceImpl;
+import org.apache.flink.table.gateway.service.context.DefaultContext;
+import org.apache.flink.table.gateway.service.session.SessionManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+
+/** Main entry point for the SQL Gateway. */
+public class SqlGateway {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SqlGateway.class);
+
+    private final CountDownLatch latch;
+
+    private SessionManager sessionManager;

Review Comment:
   Adjust it after `dynamicConfig `?



##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/SqlGateway.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.table.gateway;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.ConfigurationUtils;
+import org.apache.flink.table.gateway.api.SqlGatewayService;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpoint;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpointFactoryUtils;
+import org.apache.flink.table.gateway.api.utils.SqlGatewayException;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptions;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptionsParser;
+import org.apache.flink.table.gateway.service.SqlGatewayServiceImpl;
+import org.apache.flink.table.gateway.service.context.DefaultContext;
+import org.apache.flink.table.gateway.service.session.SessionManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+
+/** Main entry point for the SQL Gateway. */
+public class SqlGateway {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SqlGateway.class);
+
+    private final CountDownLatch latch;
+
+    private SessionManager sessionManager;
+    private final List<SqlGatewayEndpoint> endpoints;
+    private final Properties dynamicConfig;
+
+    public SqlGateway(Properties dynamicConfig) {
+        endpoints = new ArrayList<>();
+        latch = new CountDownLatch(1);
+
+        this.dynamicConfig = dynamicConfig;
+    }
+
+    public void start() {
+        DefaultContext context =
+                DefaultContext.load(ConfigurationUtils.createConfiguration(dynamicConfig));
+        sessionManager = new SessionManager(context);
+
+        sessionManager.start();
+        SqlGatewayService sqlGatewayService = new SqlGatewayServiceImpl(sessionManager);
+
+        Configuration conf = context.getFlinkConfig();
+        endpoints.addAll(
+                SqlGatewayEndpointFactoryUtils.createSqlGatewayEndpoint(sqlGatewayService, conf));
+
+        for (SqlGatewayEndpoint endpoint : endpoints) {
+            try {
+                endpoint.start();
+            } catch (Throwable t) {
+                LOG.error("Failed to start the endpoint.", t);
+                stop();
+                throw new SqlGatewayException("Failed to start the endpoint.", t);
+            }
+        }
+    }
+
+    public void stop() {
+        latch.countDown();
+        for (SqlGatewayEndpoint endpoint : endpoints) {
+            stopEndpointSilently(endpoint);
+        }
+        if (sessionManager != null) {
+            sessionManager.stop();
+        }
+    }
+
+    public static void main(String[] args) {
+        startSqlGateway(System.out, args);
+    }
+
+    @VisibleForTesting
+    public static void startSqlGateway(PrintStream stream, String[] args) {

Review Comment:
   ```suggestion
      static void startSqlGateway(PrintStream stream, String[] args) {
   ```



##########
flink-table/flink-sql-gateway-api/src/test/java/org/apache/flink/table/gateway/api/utils/MockedSqlGatewayEndpoint.java:
##########
@@ -20,29 +20,45 @@
 
 import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpoint;
 
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Objects;
 
 /** Mocked {@link SqlGatewayEndpoint}. */
 public class MockedSqlGatewayEndpoint implements SqlGatewayEndpoint {
 
+    private static final Map<String, Boolean> RUNNING_ENDPOINTS = new HashMap<>();

Review Comment:
   Why not use `Set` directly? add the id to this set when start,  remove the id from this set when stop.



##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/SqlGateway.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.table.gateway;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.ConfigurationUtils;
+import org.apache.flink.table.gateway.api.SqlGatewayService;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpoint;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpointFactoryUtils;
+import org.apache.flink.table.gateway.api.utils.SqlGatewayException;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptions;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptionsParser;
+import org.apache.flink.table.gateway.service.SqlGatewayServiceImpl;
+import org.apache.flink.table.gateway.service.context.DefaultContext;
+import org.apache.flink.table.gateway.service.session.SessionManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+
+/** Main entry point for the SQL Gateway. */
+public class SqlGateway {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SqlGateway.class);
+
+    private final CountDownLatch latch;
+
+    private SessionManager sessionManager;
+    private final List<SqlGatewayEndpoint> endpoints;
+    private final Properties dynamicConfig;
+
+    public SqlGateway(Properties dynamicConfig) {
+        endpoints = new ArrayList<>();
+        latch = new CountDownLatch(1);
+
+        this.dynamicConfig = dynamicConfig;
+    }
+
+    public void start() {
+        DefaultContext context =
+                DefaultContext.load(ConfigurationUtils.createConfiguration(dynamicConfig));
+        sessionManager = new SessionManager(context);
+
+        sessionManager.start();
+        SqlGatewayService sqlGatewayService = new SqlGatewayServiceImpl(sessionManager);
+
+        Configuration conf = context.getFlinkConfig();
+        endpoints.addAll(
+                SqlGatewayEndpointFactoryUtils.createSqlGatewayEndpoint(sqlGatewayService, conf));
+
+        for (SqlGatewayEndpoint endpoint : endpoints) {
+            try {
+                endpoint.start();
+            } catch (Throwable t) {
+                LOG.error("Failed to start the endpoint.", t);
+                stop();
+                throw new SqlGatewayException("Failed to start the endpoint.", t);
+            }
+        }
+    }
+
+    public void stop() {
+        latch.countDown();
+        for (SqlGatewayEndpoint endpoint : endpoints) {
+            stopEndpointSilently(endpoint);
+        }
+        if (sessionManager != null) {
+            sessionManager.stop();
+        }
+    }
+
+    public static void main(String[] args) {
+        startSqlGateway(System.out, args);
+    }
+
+    @VisibleForTesting
+    public static void startSqlGateway(PrintStream stream, String[] args) {
+        SqlGatewayOptions cliOptions = SqlGatewayOptionsParser.parseSqlGatewayOptions(args);
+
+        if (cliOptions.isPrintHelp()) {
+            SqlGatewayOptionsParser.printHelpSqlGateway(stream);
+            return;
+        }
+
+        SqlGateway gateway = new SqlGateway(cliOptions.getDynamicConfigs());
+        try {
+            Runtime.getRuntime().addShutdownHook(new ShutdownThread(gateway));
+            gateway.start();
+            gateway.waitUntilStop();
+        } catch (Throwable t) {
+            // make space in terminal
+            stream.println();
+            stream.println();
+            LOG.error(
+                    "SqlGateway must stop. Unexpected exception. This is a bug. Please consider filing an issue.",
+                    t);
+            throw new SqlGatewayException(
+                    "Unexpected exception. This is a bug. Please consider filing an issue.", t);
+        }
+    }
+
+    private void waitUntilStop() throws Exception {
+        latch.await();
+    }
+
+    private void stopEndpointSilently(SqlGatewayEndpoint endpoint) {
+        try {
+            endpoint.stop();
+        } catch (Exception e) {
+            LOG.error("Failed to stop the endpoint. Ignore.", e);
+        }
+    }
+
+    // --------------------------------------------------------------------------------------------
+
+    private static class ShutdownThread extends Thread {
+
+        private final SqlGateway gateway;
+
+        public ShutdownThread(SqlGateway gateway) {
+            this.gateway = gateway;
+        }
+
+        @Override
+        public void run() {
+            // Shutdown the gateway
+            System.out.println("\nShutting down the Flink SqlGateway...");
+            LOG.info("Shutting down the Flink SqlGateway...");
+
+            try {
+                gateway.stop();
+            } catch (Exception e) {
+                LOG.error("Failed to shut down the Flink SqlGateway: " + e.getMessage(), e);
+                System.out.println("Failed to shut down the Flink SqlGateway: " + e.getMessage());
+            }
+
+            LOG.info("Flink SqlServer has been shutdown.");

Review Comment:
   ```suggestion
               LOG.info("Flink SqlGateway has been shutdown.");
   ```



##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/SqlGateway.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.table.gateway;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.ConfigurationUtils;
+import org.apache.flink.table.gateway.api.SqlGatewayService;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpoint;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpointFactoryUtils;
+import org.apache.flink.table.gateway.api.utils.SqlGatewayException;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptions;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptionsParser;
+import org.apache.flink.table.gateway.service.SqlGatewayServiceImpl;
+import org.apache.flink.table.gateway.service.context.DefaultContext;
+import org.apache.flink.table.gateway.service.session.SessionManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+
+/** Main entry point for the SQL Gateway. */
+public class SqlGateway {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SqlGateway.class);
+
+    private final CountDownLatch latch;
+
+    private SessionManager sessionManager;
+    private final List<SqlGatewayEndpoint> endpoints;
+    private final Properties dynamicConfig;
+
+    public SqlGateway(Properties dynamicConfig) {
+        endpoints = new ArrayList<>();
+        latch = new CountDownLatch(1);

Review Comment:
   ```suggestion
           this.latch = new CountDownLatch(1);
   ```



##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/SqlGateway.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.table.gateway;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.ConfigurationUtils;
+import org.apache.flink.table.gateway.api.SqlGatewayService;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpoint;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpointFactoryUtils;
+import org.apache.flink.table.gateway.api.utils.SqlGatewayException;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptions;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptionsParser;
+import org.apache.flink.table.gateway.service.SqlGatewayServiceImpl;
+import org.apache.flink.table.gateway.service.context.DefaultContext;
+import org.apache.flink.table.gateway.service.session.SessionManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+
+/** Main entry point for the SQL Gateway. */
+public class SqlGateway {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SqlGateway.class);
+
+    private final CountDownLatch latch;
+
+    private SessionManager sessionManager;
+    private final List<SqlGatewayEndpoint> endpoints;
+    private final Properties dynamicConfig;
+
+    public SqlGateway(Properties dynamicConfig) {
+        endpoints = new ArrayList<>();
+        latch = new CountDownLatch(1);
+
+        this.dynamicConfig = dynamicConfig;
+    }
+
+    public void start() {
+        DefaultContext context =
+                DefaultContext.load(ConfigurationUtils.createConfiguration(dynamicConfig));
+        sessionManager = new SessionManager(context);
+
+        sessionManager.start();
+        SqlGatewayService sqlGatewayService = new SqlGatewayServiceImpl(sessionManager);
+
+        Configuration conf = context.getFlinkConfig();
+        endpoints.addAll(
+                SqlGatewayEndpointFactoryUtils.createSqlGatewayEndpoint(sqlGatewayService, conf));
+
+        for (SqlGatewayEndpoint endpoint : endpoints) {
+            try {
+                endpoint.start();
+            } catch (Throwable t) {
+                LOG.error("Failed to start the endpoint.", t);
+                stop();
+                throw new SqlGatewayException("Failed to start the endpoint.", t);
+            }
+        }
+    }
+
+    public void stop() {
+        latch.countDown();
+        for (SqlGatewayEndpoint endpoint : endpoints) {
+            stopEndpointSilently(endpoint);
+        }
+        if (sessionManager != null) {
+            sessionManager.stop();
+        }
+    }
+
+    public static void main(String[] args) {
+        startSqlGateway(System.out, args);
+    }
+
+    @VisibleForTesting
+    public static void startSqlGateway(PrintStream stream, String[] args) {
+        SqlGatewayOptions cliOptions = SqlGatewayOptionsParser.parseSqlGatewayOptions(args);
+
+        if (cliOptions.isPrintHelp()) {
+            SqlGatewayOptionsParser.printHelpSqlGateway(stream);
+            return;
+        }
+
+        SqlGateway gateway = new SqlGateway(cliOptions.getDynamicConfigs());
+        try {
+            Runtime.getRuntime().addShutdownHook(new ShutdownThread(gateway));
+            gateway.start();
+            gateway.waitUntilStop();
+        } catch (Throwable t) {
+            // make space in terminal
+            stream.println();
+            stream.println();
+            LOG.error(
+                    "SqlGateway must stop. Unexpected exception. This is a bug. Please consider filing an issue.",
+                    t);
+            throw new SqlGatewayException(
+                    "Unexpected exception. This is a bug. Please consider filing an issue.", t);
+        }
+    }
+
+    private void waitUntilStop() throws Exception {
+        latch.await();
+    }
+
+    private void stopEndpointSilently(SqlGatewayEndpoint endpoint) {
+        try {
+            endpoint.stop();
+        } catch (Exception e) {
+            LOG.error("Failed to stop the endpoint. Ignore.", e);
+        }
+    }
+
+    // --------------------------------------------------------------------------------------------
+
+    private static class ShutdownThread extends Thread {
+
+        private final SqlGateway gateway;
+
+        public ShutdownThread(SqlGateway gateway) {
+            this.gateway = gateway;
+        }
+
+        @Override
+        public void run() {
+            // Shutdown the gateway
+            System.out.println("\nShutting down the Flink SqlGateway...");
+            LOG.info("Shutting down the Flink SqlGateway...");
+
+            try {
+                gateway.stop();
+            } catch (Exception e) {
+                LOG.error("Failed to shut down the Flink SqlGateway: " + e.getMessage(), e);
+                System.out.println("Failed to shut down the Flink SqlGateway: " + e.getMessage());
+            }
+
+            LOG.info("Flink SqlServer has been shutdown.");
+            System.out.println("Flink SqlServer has been shutdown.");

Review Comment:
   ```suggestion
               System.out.println("Flink SqlGateway has been shutdown.");
   ```



##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/SqlGateway.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.table.gateway;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.ConfigurationUtils;
+import org.apache.flink.table.gateway.api.SqlGatewayService;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpoint;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpointFactoryUtils;
+import org.apache.flink.table.gateway.api.utils.SqlGatewayException;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptions;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptionsParser;
+import org.apache.flink.table.gateway.service.SqlGatewayServiceImpl;
+import org.apache.flink.table.gateway.service.context.DefaultContext;
+import org.apache.flink.table.gateway.service.session.SessionManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+
+/** Main entry point for the SQL Gateway. */
+public class SqlGateway {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SqlGateway.class);
+
+    private final CountDownLatch latch;
+
+    private SessionManager sessionManager;
+    private final List<SqlGatewayEndpoint> endpoints;
+    private final Properties dynamicConfig;
+
+    public SqlGateway(Properties dynamicConfig) {
+        endpoints = new ArrayList<>();

Review Comment:
   ```suggestion
           this.endpoints = new ArrayList<>();
   ```



##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/SqlGateway.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.table.gateway;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.ConfigurationUtils;
+import org.apache.flink.table.gateway.api.SqlGatewayService;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpoint;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpointFactoryUtils;
+import org.apache.flink.table.gateway.api.utils.SqlGatewayException;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptions;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptionsParser;
+import org.apache.flink.table.gateway.service.SqlGatewayServiceImpl;
+import org.apache.flink.table.gateway.service.context.DefaultContext;
+import org.apache.flink.table.gateway.service.session.SessionManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+
+/** Main entry point for the SQL Gateway. */
+public class SqlGateway {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SqlGateway.class);
+
+    private final CountDownLatch latch;
+
+    private SessionManager sessionManager;
+    private final List<SqlGatewayEndpoint> endpoints;
+    private final Properties dynamicConfig;
+
+    public SqlGateway(Properties dynamicConfig) {
+        endpoints = new ArrayList<>();
+        latch = new CountDownLatch(1);
+
+        this.dynamicConfig = dynamicConfig;
+    }
+
+    public void start() {

Review Comment:
   Introducing a awaitTerminal api of Endpoint, when anyone of endpoint exit, the gateway also should exit.



##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/SqlGateway.java:
##########
@@ -0,0 +1,163 @@
+/*
+ * 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.table.gateway;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.ConfigurationUtils;
+import org.apache.flink.table.gateway.api.SqlGatewayService;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpoint;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpointFactoryUtils;
+import org.apache.flink.table.gateway.api.utils.SqlGatewayException;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptions;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptionsParser;
+import org.apache.flink.table.gateway.service.SqlGatewayServiceImpl;
+import org.apache.flink.table.gateway.service.context.DefaultContext;
+import org.apache.flink.table.gateway.service.session.SessionManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+
+/** Main entry point for the SQL Gateway. */
+public class SqlGateway {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SqlGateway.class);
+
+    private final CountDownLatch latch;
+
+    private SessionManager sessionManager;
+    private final List<SqlGatewayEndpoint> endpoints;
+    private final Properties dynamicConfig;
+
+    public SqlGateway(Properties dynamicConfig) {
+        endpoints = new ArrayList<>();
+        latch = new CountDownLatch(1);
+
+        this.dynamicConfig = dynamicConfig;
+    }
+
+    public void start() {
+        DefaultContext context =
+                DefaultContext.load(ConfigurationUtils.createConfiguration(dynamicConfig));
+        sessionManager = new SessionManager(context);
+
+        sessionManager.start();
+        SqlGatewayService sqlGatewayService = new SqlGatewayServiceImpl(sessionManager);
+
+        Configuration conf = context.getFlinkConfig();
+        endpoints.addAll(
+                SqlGatewayEndpointFactoryUtils.createSqlGatewayEndpoint(sqlGatewayService, conf));

Review Comment:
   ```suggestion
                   SqlGatewayEndpointFactoryUtils.createSqlGatewayEndpoint(sqlGatewayService, context.getFlinkConfig()));
   ```



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

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


[GitHub] [flink] fsk119 closed pull request #19894: [FLINK-27931][sql-gateway] Introduce the SqlGateway to assemble all components

Posted by GitBox <gi...@apache.org>.
fsk119 closed pull request #19894: [FLINK-27931][sql-gateway] Introduce the SqlGateway to assemble all components
URL: https://github.com/apache/flink/pull/19894


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

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


[GitHub] [flink] wuchong commented on a diff in pull request #19894: [FLINK-27931][sql-gateway] Introduce the SqlGateway to assemble all components

Posted by GitBox <gi...@apache.org>.
wuchong commented on code in PR #19894:
URL: https://github.com/apache/flink/pull/19894#discussion_r926594347


##########
flink-table/flink-sql-gateway-api/src/main/java/org/apache/flink/table/gateway/api/endpoint/SqlGatewayEndpoint.java:
##########
@@ -29,4 +29,7 @@ public interface SqlGatewayEndpoint {
 
     /** Terminate the endpoint. */
     void stop() throws Exception;
+
+    /** Waits for the server to become terminated. */
+    void awaitTermination() throws Exception;

Review Comment:
   I thought about this again. It's error-prone for developers to implement this. For example, the implementation of this method may not block before termination (by mistake) which will result in the SqlGateway exit unexpected. 
   
   We can implement a simple `awaitTermination` in `SqlGateway` via `lock.wait()` and `lock.notifyAll()`.
   



##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/SqlGateway.java:
##########
@@ -0,0 +1,177 @@
+/*
+ * 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.table.gateway;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.configuration.ConfigurationUtils;
+import org.apache.flink.table.gateway.api.SqlGatewayService;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpoint;
+import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpointFactoryUtils;
+import org.apache.flink.table.gateway.api.utils.SqlGatewayException;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptions;
+import org.apache.flink.table.gateway.cli.SqlGatewayOptionsParser;
+import org.apache.flink.table.gateway.service.SqlGatewayServiceImpl;
+import org.apache.flink.table.gateway.service.context.DefaultContext;
+import org.apache.flink.table.gateway.service.session.SessionManager;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/** Main entry point for the SQL Gateway. */
+public class SqlGateway {
+
+    private static final Logger LOG = LoggerFactory.getLogger(SqlGateway.class);
+
+    private final List<SqlGatewayEndpoint> endpoints;
+    private final Properties dynamicConfig;
+
+    private SessionManager sessionManager;
+
+    public SqlGateway(Properties dynamicConfig) {
+        this.endpoints = new ArrayList<>();
+        this.dynamicConfig = dynamicConfig;
+    }
+
+    public void start() {
+        DefaultContext context =
+                DefaultContext.load(ConfigurationUtils.createConfiguration(dynamicConfig));
+        sessionManager = new SessionManager(context);
+
+        sessionManager.start();
+        SqlGatewayService sqlGatewayService = new SqlGatewayServiceImpl(sessionManager);
+
+        endpoints.addAll(
+                SqlGatewayEndpointFactoryUtils.createSqlGatewayEndpoint(
+                        sqlGatewayService, context.getFlinkConfig()));
+
+        for (SqlGatewayEndpoint endpoint : endpoints) {
+            try {
+                endpoint.start();
+            } catch (Throwable t) {
+                LOG.error("Failed to start the endpoint.", t);
+                stop();
+                throw new SqlGatewayException("Failed to start the endpoint.", t);
+            }
+        }
+    }
+
+    public void stop() {
+        for (SqlGatewayEndpoint endpoint : endpoints) {
+            stopEndpointSilently(endpoint);
+        }
+        if (sessionManager != null) {
+            sessionManager.stop();
+        }
+    }
+
+    public static void main(String[] args) {

Review Comment:
   I think we can follow `org.apache.flink.runtime.taskexecutor.TaskManagerRunner#main` to log some important environment information. 



##########
flink-table/flink-sql-gateway-api/src/test/java/org/apache/flink/table/gateway/api/utils/MockedSqlGatewayEndpoint.java:
##########
@@ -20,29 +20,54 @@
 
 import org.apache.flink.table.gateway.api.endpoint.SqlGatewayEndpoint;
 
+import java.util.HashSet;
 import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
 
 /** Mocked {@link SqlGatewayEndpoint}. */
 public class MockedSqlGatewayEndpoint implements SqlGatewayEndpoint {
 
+    private static final Set<String> RUNNING_ENDPOINTS = new HashSet<>();

Review Comment:
   The `HashSet` is not thread-safe but is modified and accessed by multiple threads. You can use `ConcurrentHashMap.newKeySet()` instead.



##########
flink-table/flink-sql-gateway/src/test/java/org/apache/flink/table/gateway/SqlGatewayTest.java:
##########
@@ -0,0 +1,120 @@
+/*
+ * 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.table.gateway;
+
+import org.apache.flink.core.testutils.CommonTestUtils;
+import org.apache.flink.table.gateway.api.utils.MockedSqlGatewayEndpoint;
+import org.apache.flink.util.concurrent.ExecutorThreadFactory;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.apache.flink.configuration.ConfigConstants.ENV_FLINK_CONF_DIR;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+/** Tests for the {@link SqlGateway}. */
+public class SqlGatewayTest {
+
+    private Map<String, String> originalEnv;
+    private ByteArrayOutputStream output;
+
+    @BeforeEach
+    public void before(@TempDir File tempFolder) throws IOException {
+        originalEnv = System.getenv();
+
+        // prepare yaml
+        File confYaml = new File(tempFolder, "flink-conf.yaml");
+        if (!confYaml.createNewFile()) {
+            throw new IOException("Can't create testing flink-conf.yaml file.");
+        }
+        // adjust the test environment for the purposes of this test
+        Map<String, String> map = new HashMap<>(System.getenv());
+        map.put(ENV_FLINK_CONF_DIR, tempFolder.getAbsolutePath());
+        CommonTestUtils.setEnv(map);
+
+        output = new ByteArrayOutputStream(256);
+    }
+
+    @AfterEach
+    public void cleanup() throws Exception {
+        CommonTestUtils.setEnv(originalEnv);
+        if (output != null) {
+            output.close();
+        }
+    }
+
+    @Test
+    public void testPrintStartGatewayHelp() {
+        String[] args = new String[] {"--help"};
+        SqlGateway.startSqlGateway(new PrintStream(output), args);
+
+        assertThat(output.toString())
+                .contains(
+                        "Start the Flink SQL Gateway as a daemon to submit Flink SQL.\n"
+                                + "\n"
+                                + "  Syntax: start [OPTIONS]\n"
+                                + "     -D <property=value>   use value for given property\n"

Review Comment:
   ```suggestion
                                   + "     -D<property=value>   use value for given property\n"
   ```
   
   Shouldn't have space between `-D` and properties? 



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

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


[GitHub] [flink] fsk119 commented on a diff in pull request #19894: [FLINK-27931][sql-gateway] Introduce the SqlGateway to assemble all components

Posted by GitBox <gi...@apache.org>.
fsk119 commented on code in PR #19894:
URL: https://github.com/apache/flink/pull/19894#discussion_r927262799


##########
flink-table/flink-sql-gateway-api/src/main/java/org/apache/flink/table/gateway/api/endpoint/SqlGatewayEndpoint.java:
##########
@@ -29,4 +29,7 @@ public interface SqlGatewayEndpoint {
 
     /** Terminate the endpoint. */
     void stop() throws Exception;
+
+    /** Waits for the server to become terminated. */
+    void awaitTermination() throws Exception;

Review Comment:
   Yes. I think you are right. I add a method named `waitUntilStop` and use `CountDownLatch` to control the termination.



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

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