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/07/25 12:33:26 UTC

[GitHub] [flink] fsk119 commented on a diff in pull request #20174: [FLINK-27770][sql-gateway] Introduce the script to start/stop/stop-all gateway

fsk119 commented on code in PR #20174:
URL: https://github.com/apache/flink/pull/20174#discussion_r928814365


##########
flink-table/flink-sql-gateway/bin/sql-gateway.sh:
##########
@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+#
+# 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.
+#
+
+# Start/stop a Flink SQL Gateway.
+USAGE="Usage: sql-gateway.sh (start|start-foreground|stop|stop-all)"
+
+STARTSTOP=$1
+
+if [[ $STARTSTOP != "start" ]] && [[ $STARTSTOP != "start-foreground" ]] && [[ $STARTSTOP != "stop" ]] && [[ $STARTSTOP != "stop-all" ]]; then
+  echo $USAGE
+  exit 1
+fi
+
+bin=`dirname "$0"`
+bin=`cd "$bin"; pwd`
+
+. "$bin"/config.sh
+
+ENTRYPOINT=sqlgateway
+
+if [[ $STARTSTOP == "start" ]] || [[ $STARTSTOP == "start-foreground" ]]; then
+    # Add SqlGateway-specific JVM options
+    export FLINK_ENV_JAVA_OPTS="${FLINK_ENV_JAVA_OPTS} ${FLINK_ENV_JAVA_OPTS_JM}"
+    parseJmArgsAndExportLogs "${ARGS[@]}"
+
+    args=("--configDir" "${FLINK_CONF_DIR}" "--executionMode" "cluster")
+fi
+
+if [[ $STARTSTOP == "start-foreground" ]]; then
+    exec "${FLINK_BIN_DIR}"/flink-console.sh $ENTRYPOINT "${args[@]}"

Review Comment:
   If so, we also need to modify `flink-console.sh` to support sql-gateway. I think we can delay the support of the command `start-foreground.` 



##########
flink-table/flink-sql-gateway/bin/sql-gateway.sh:
##########
@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+#
+# 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.
+#
+
+# Start/stop a Flink SQL Gateway.
+USAGE="Usage: sql-gateway.sh (start|start-foreground|stop|stop-all)"
+
+STARTSTOP=$1
+
+if [[ $STARTSTOP != "start" ]] && [[ $STARTSTOP != "start-foreground" ]] && [[ $STARTSTOP != "stop" ]] && [[ $STARTSTOP != "stop-all" ]]; then
+  echo $USAGE
+  exit 1
+fi
+
+bin=`dirname "$0"`
+bin=`cd "$bin"; pwd`
+
+. "$bin"/config.sh
+
+ENTRYPOINT=sqlgateway
+
+if [[ $STARTSTOP == "start" ]] || [[ $STARTSTOP == "start-foreground" ]]; then
+    # Add SqlGateway-specific JVM options
+    export FLINK_ENV_JAVA_OPTS="${FLINK_ENV_JAVA_OPTS} ${FLINK_ENV_JAVA_OPTS_JM}"
+    parseJmArgsAndExportLogs "${ARGS[@]}"
+
+    args=("--configDir" "${FLINK_CONF_DIR}" "--executionMode" "cluster")
+fi
+
+if [[ $STARTSTOP == "start-foreground" ]]; then
+    exec "${FLINK_BIN_DIR}"/flink-console.sh $ENTRYPOINT "${args[@]}"
+else
+    "${FLINK_BIN_DIR}"/flink-daemon.sh $STARTSTOP $ENTRYPOINT "${args[@]}"

Review Comment:
   It seems we can't convey the parameter, e.g. "-Dkey=value" to the gateway.



##########
flink-table/flink-sql-gateway/bin/sql-gateway.sh:
##########
@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+#
+# 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.
+#
+
+# Start/stop a Flink SQL Gateway.
+USAGE="Usage: sql-gateway.sh (start|start-foreground|stop|stop-all)"
+

Review Comment:
   Why don't copy these lines from sql-client.sh?
   
   ```
   ################################################################################
   # Adopted from "flink" bash script
   ################################################################################
   
   target="$0"
   # For the case, the executable has been directly symlinked, figure out
   # the correct bin path by following its symlink up to an upper bound.
   # Note: we can't use the readlink utility here if we want to be POSIX
   # compatible.
   iteration=0
   while [ -L "$target" ]; do
       if [ "$iteration" -gt 100 ]; then
           echo "Cannot resolve path: You have a cyclic symlink in $target."
           break
       fi
       ls=`ls -ld -- "$target"`
       target=`expr "$ls" : '.* -> \(.*\)$'`
       iteration=$((iteration + 1))
   done
   
   # Convert relative path to absolute path
   bin=`dirname "$target"`
   
   # get flink config
   . "$bin"/config.sh
   
   if [ "$FLINK_IDENT_STRING" = "" ]; then
           FLINK_IDENT_STRING="$USER"
   fi
   
   CC_CLASSPATH=`constructFlinkClassPath`
   ```



##########
flink-table/flink-sql-gateway/bin/sql-gateway.sh:
##########
@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+#
+# 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.
+#
+
+# Start/stop a Flink SQL Gateway.
+USAGE="Usage: sql-gateway.sh (start|start-foreground|stop|stop-all)"
+
+STARTSTOP=$1
+
+if [[ $STARTSTOP != "start" ]] && [[ $STARTSTOP != "start-foreground" ]] && [[ $STARTSTOP != "stop" ]] && [[ $STARTSTOP != "stop-all" ]]; then
+  echo $USAGE
+  exit 1
+fi
+
+bin=`dirname "$0"`
+bin=`cd "$bin"; pwd`
+
+. "$bin"/config.sh
+
+ENTRYPOINT=sqlgateway
+
+if [[ $STARTSTOP == "start" ]] || [[ $STARTSTOP == "start-foreground" ]]; then
+    # Add SqlGateway-specific JVM options
+    export FLINK_ENV_JAVA_OPTS="${FLINK_ENV_JAVA_OPTS} ${FLINK_ENV_JAVA_OPTS_JM}"
+    parseJmArgsAndExportLogs "${ARGS[@]}"
+
+    args=("--configDir" "${FLINK_CONF_DIR}" "--executionMode" "cluster")

Review Comment:
   Do we need this? It parse jobmanager args. You can cc BashJavaUtils for more details. I think we can do as sql-client.sh and make it simple.



-- 
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