|
| 1 | +#!/usr/bin/env bash |
| 2 | +################################################################################ |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 4 | +# or more contributor license agreements. See the NOTICE file |
| 5 | +# distributed with this work for additional information |
| 6 | +# regarding copyright ownership. The ASF licenses this file |
| 7 | +# to you under the Apache License, Version 2.0 (the |
| 8 | +# "License"); you may not use this file except in compliance |
| 9 | +# with the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, software |
| 14 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +# See the License for the specific language governing permissions and |
| 17 | +# limitations under the License. |
| 18 | +################################################################################ |
| 19 | + |
| 20 | +################################################################################ |
| 21 | +# Adopted from "flink" bash script |
| 22 | +################################################################################ |
| 23 | + |
| 24 | +if [[ -z "$FLINK_HOME" || ! -d "$FLINK_HOME" ]]; then |
| 25 | + (>&2 echo "Invalid FLINK_HOME: ${FLINK_HOME:-unset}") |
| 26 | + exit 1 |
| 27 | +fi |
| 28 | + |
| 29 | +FLINK_SQL_ENGINE_HOME="$(cd `dirname $0`/..; pwd)" |
| 30 | +if [[ "$FLINK_SQL_ENGINE_HOME" == "$KYUUBI_HOME/externals/engines/flink" ]]; then |
| 31 | + FLINK_SQL_ENGINE_CONF_DIR="$FLINK_SQL_ENGINE_HOME/conf" |
| 32 | + FLINK_SQL_ENGINE_LIB_DIR="$FLINK_SQL_ENGINE_HOME/lib" |
| 33 | + FLINK_SQL_ENGINE_LOG_DIR="$KYUUBI_LOG_DIR" |
| 34 | + FLINK_SQL_ENGINE_JAR=$(find "$FLINK_SQL_ENGINE_LIB_DIR" -regex ".*/kyuubi-flink-sql-engine_.*\.jar") |
| 35 | + FLINK_HADOOP_CLASSPATH="$INTERNAL_HADOOP_CLASSPATHS" |
| 36 | +else |
| 37 | + echo -e "\nFLINK_SQL_ENGINE_HOME $FLINK_SQL_ENGINE_HOME doesn't match production directory, assuming in development environment..." |
| 38 | + FLINK_SQL_ENGINE_CONF_DIR="$FLINK_SQL_ENGINE_HOME/conf" |
| 39 | + FLINK_SQL_ENGINE_LIB_DIR="$FLINK_SQL_ENGINE_HOME/target" |
| 40 | + FLINK_SQL_ENGINE_LOG_DIR="$FLINK_SQL_ENGINE_HOME/target" |
| 41 | + FLINK_SQL_ENGINE_JAR=$(find "$FLINK_SQL_ENGINE_LIB_DIR" -regex '.*/kyuubi-flink-sql-engine_.*\.jar$' | grep -v '\-javadoc.jar$' | grep -v '\-tests.jar$') |
| 42 | + _FLINK_SQL_ENGINE_HADOOP_CLIENT_JARS=$(find $FLINK_SQL_ENGINE_LIB_DIR -regex '.*/hadoop-client-.*\.jar$' | tr '\n' ':') |
| 43 | + FLINK_HADOOP_CLASSPATH="${_FLINK_SQL_ENGINE_HADOOP_CLIENT_JARS%:}" |
| 44 | +fi |
| 45 | + |
| 46 | +# do NOT let config.sh detect FLINK_HOME |
| 47 | +_FLINK_HOME_DETERMINED=1 . "$FLINK_HOME/bin/config.sh" |
| 48 | + |
| 49 | +FLINK_IDENT_STRING=${FLINK_IDENT_STRING:-"$USER"} |
| 50 | +FLINK_SQL_CLIENT_JAR=$(find "$FLINK_OPT_DIR" -regex ".*flink-sql-client.*.jar") |
| 51 | +CC_CLASSPATH=`constructFlinkClassPath` |
| 52 | + |
| 53 | +FULL_CLASSPATH="$FLINK_SQL_ENGINE_JAR:$FLINK_SQL_CLIENT_JAR:$CC_CLASSPATH:$FLINK_HADOOP_CLASSPATH" |
| 54 | + |
| 55 | +log_file="$FLINK_SQL_ENGINE_LOG_DIR/kyuubi-flink-sql-engine-$FLINK_IDENT_STRING-$HOSTNAME.log" |
| 56 | +log_setting=( |
| 57 | + -Dlog.file="$log_file" |
| 58 | + -Dlog4j.configurationFile=file:"$FLINK_SQL_ENGINE_CONF_DIR/log4j.properties" |
| 59 | + -Dlog4j.configuration=file:"$FLINK_SQL_ENGINE_CONF_DIR/log4j.properties" |
| 60 | + -Dlogback.configurationFile=file:"$FLINK_SQL_ENGINE_CONF_DIR/logback.xml" |
| 61 | +) |
| 62 | + |
| 63 | +if [ -n "$FLINK_SQL_ENGINE_JAR" ]; then |
| 64 | + exec $JAVA_RUN ${FLINK_SQL_ENGINE_DYNAMIC_ARGS} "${log_setting[@]}" -cp ${FULL_CLASSPATH} \ |
| 65 | + org.apache.kyuubi.engine.flink.FlinkSQLEngine "$@" |
| 66 | +else |
| 67 | + (>&2 echo "[ERROR] Flink SQL Engine JAR file 'kyuubi-flink-sql-engine*.jar' should be located in $FLINK_SQL_ENGINE_LIB_DIR.") |
| 68 | + exit 1 |
| 69 | +fi |
0 commit comments