-
Notifications
You must be signed in to change notification settings - Fork 938
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[KYUUBI #1629] Flink backend implementation
### _Why are the changes needed?_ This PR covers #1619. Overall, this PR contains the following changs, 1. change `build/dist` script to support flink sql engine 2. enhance `externals/flink-sql-engine/pom.xml` to support create a shaded jar 3. simplify `externals/kyuubi-flink-sql-engine/bin/flink-sql-engine.sh` 4. introduce `FlinkSQLEngine`(flink sql engine entrypoint) and `FlinkProcessBuilder`(kyuubi server launcher) 5. add ut in kyuubi server side After this PR, we can run the basic query e.g. `select now()` from beeline and get result, and Kyuubi Server can auto launch flink engine if there is no proper one. The Flink engine also supports other engine share levels defined in Kyuubi. The implementation based on Flink 1.14 codebase. ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [x] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #1629 from pan3793/flink-backend. Closes #1629 b7e5f0e [Cheng Pan] revert tgz name change a4496c3 [Cheng Pan] Fix reflection 3b4e86a [Cheng Pan] deps 68efa42 [Cheng Pan] log 8a9e37f [Cheng Pan] nit 10fb2bc [Cheng Pan] CI c1560fd [Cheng Pan] nit 303e2f1 [Cheng Pan] Restore log conf d84720b [Cheng Pan] SessionContext b258d81 [Cheng Pan] cleanup 16edd52 [Cheng Pan] Cleanup 9ae5455 [Cheng Pan] Fix CI 25b6b57 [Cheng Pan] hadoop-client-api c12b5ca [Cheng Pan] Server UT pass 502d3f0 [Cheng Pan] pass dac4323 [yanghua] Laungh local flink engine container successfully Lead-authored-by: Cheng Pan <[email protected]> Co-authored-by: yanghua <[email protected]> Signed-off-by: Kent Yao <[email protected]>
- Loading branch information
Showing
32 changed files
with
1,249 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/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. | ||
################################################################################ | ||
|
||
################################################################################ | ||
# Adopted from "flink" bash script | ||
################################################################################ | ||
|
||
if [[ -z "$FLINK_HOME" || ! -d "$FLINK_HOME" ]]; then | ||
(>&2 echo "Invalid FLINK_HOME: ${FLINK_HOME:-unset}") | ||
exit 1 | ||
fi | ||
|
||
FLINK_SQL_ENGINE_HOME="$(cd `dirname $0`/..; pwd)" | ||
if [[ "$FLINK_SQL_ENGINE_HOME" == "$KYUUBI_HOME/externals/engines/flink" ]]; then | ||
FLINK_SQL_ENGINE_CONF_DIR="$FLINK_SQL_ENGINE_HOME/conf" | ||
FLINK_SQL_ENGINE_LIB_DIR="$FLINK_SQL_ENGINE_HOME/lib" | ||
FLINK_SQL_ENGINE_LOG_DIR="$KYUUBI_LOG_DIR" | ||
FLINK_SQL_ENGINE_JAR=$(find "$FLINK_SQL_ENGINE_LIB_DIR" -regex ".*/kyuubi-flink-sql-engine_.*\.jar") | ||
FLINK_HADOOP_CLASSPATH="$INTERNAL_HADOOP_CLASSPATHS" | ||
else | ||
echo -e "\nFLINK_SQL_ENGINE_HOME $FLINK_SQL_ENGINE_HOME doesn't match production directory, assuming in development environment..." | ||
FLINK_SQL_ENGINE_CONF_DIR="$FLINK_SQL_ENGINE_HOME/conf" | ||
FLINK_SQL_ENGINE_LIB_DIR="$FLINK_SQL_ENGINE_HOME/target" | ||
FLINK_SQL_ENGINE_LOG_DIR="$FLINK_SQL_ENGINE_HOME/target" | ||
FLINK_SQL_ENGINE_JAR=$(find "$FLINK_SQL_ENGINE_LIB_DIR" -regex '.*/kyuubi-flink-sql-engine_.*\.jar$' | grep -v '\-javadoc.jar$' | grep -v '\-tests.jar$') | ||
_FLINK_SQL_ENGINE_HADOOP_CLIENT_JARS=$(find $FLINK_SQL_ENGINE_LIB_DIR -regex '.*/hadoop-client-.*\.jar$' | tr '\n' ':') | ||
FLINK_HADOOP_CLASSPATH="${_FLINK_SQL_ENGINE_HADOOP_CLIENT_JARS%:}" | ||
fi | ||
|
||
# do NOT let config.sh detect FLINK_HOME | ||
_FLINK_HOME_DETERMINED=1 . "$FLINK_HOME/bin/config.sh" | ||
|
||
FLINK_IDENT_STRING=${FLINK_IDENT_STRING:-"$USER"} | ||
FLINK_SQL_CLIENT_JAR=$(find "$FLINK_OPT_DIR" -regex ".*flink-sql-client.*.jar") | ||
CC_CLASSPATH=`constructFlinkClassPath` | ||
|
||
FULL_CLASSPATH="$FLINK_SQL_ENGINE_JAR:$FLINK_SQL_CLIENT_JAR:$CC_CLASSPATH:$FLINK_HADOOP_CLASSPATH" | ||
|
||
log_file="$FLINK_SQL_ENGINE_LOG_DIR/kyuubi-flink-sql-engine-$FLINK_IDENT_STRING-$HOSTNAME.log" | ||
log_setting=( | ||
-Dlog.file="$log_file" | ||
-Dlog4j.configurationFile=file:"$FLINK_SQL_ENGINE_CONF_DIR/log4j.properties" | ||
-Dlog4j.configuration=file:"$FLINK_SQL_ENGINE_CONF_DIR/log4j.properties" | ||
-Dlogback.configurationFile=file:"$FLINK_SQL_ENGINE_CONF_DIR/logback.xml" | ||
) | ||
|
||
if [ -n "$FLINK_SQL_ENGINE_JAR" ]; then | ||
exec $JAVA_RUN ${FLINK_SQL_ENGINE_DYNAMIC_ARGS} "${log_setting[@]}" -cp ${FULL_CLASSPATH} \ | ||
org.apache.kyuubi.engine.flink.FlinkSQLEngine "$@" | ||
else | ||
(>&2 echo "[ERROR] Flink SQL Engine JAR file 'kyuubi-flink-sql-engine*.jar' should be located in $FLINK_SQL_ENGINE_LIB_DIR.") | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
################################################################################ | ||
# 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. | ||
################################################################################ | ||
|
||
# This affects logging for both kyuubi-flink-sql-engine and Flink | ||
log4j.rootLogger=INFO, CA | ||
|
||
#Console Appender | ||
log4j.appender.CA=org.apache.log4j.ConsoleAppender | ||
log4j.appender.CA.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.CA.layout.ConversionPattern=%d{HH:mm:ss.SSS} %p %c: %m%n | ||
log4j.appender.CA.Threshold = FATAL | ||
|
||
# Log all infos in the given file | ||
log4j.appender.file=org.apache.log4j.FileAppender | ||
log4j.appender.file.file=${log.file} | ||
log4j.appender.file.append=false | ||
log4j.appender.file.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %-60c %x - %m%n | ||
|
||
#File Appender | ||
log4j.appender.FA=org.apache.log4j.FileAppender | ||
log4j.appender.FA.append=false | ||
log4j.appender.FA.file=target/unit-tests.log | ||
log4j.appender.FA.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.FA.layout.ConversionPattern=%d{HH:mm:ss.SSS} %t %p %c{2}: %m%n | ||
|
||
# Set the logger level of File Appender to DEBUG | ||
log4j.appender.FA.Threshold = DEBUG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!-- | ||
~ 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. | ||
--> | ||
|
||
<configuration> | ||
<appender name="file" class="ch.qos.logback.core.FileAppender"> | ||
<file>${log.file}</file> | ||
<append>false</append> | ||
<encoder> | ||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{60} %X{sourceThread} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<!-- # This affects logging for both kyuubi-flink-sql-engine and Flink --> | ||
<root level="INFO"> | ||
<appender-ref ref="file"/> | ||
</root> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.