flink 源码调试

Last updated on November 22, 2024 pm

🧙 Questions

flink大版本区别比较大,当前以1.12.7版本为例子

☄️ Ideas

源码下载

选择tag:release-1.12.7
建议使用gitee下载,github下载太慢了
git clone -b release-1.12.7 https://gitee.com/apache/flink.git

git clone -b release-1.12.7 https://github.com/apache/flink.git

源码运行

建议使用idea进行调试
建议忽略大提交的commitId
git config blame.ignoreRevsFile .git-blame-ignore-revs

前提
  • idea安装scala插件
  • 安装maven
  • 安装jdk(11+)
本地编译
mvn clean package -DskipTests

20221130135948

生成的路径: flink/flink-dist/target/flink-1.12.7-bin/flink-1.12.7/

20221130140254

调试场景

本地启动flink服务

使用git bash,将编译后的程序启动起来,并运行本地的一个jar包,判断是否可行

vim flink-1.12.7/bin/flink-daemon.sh

移除 $INTERNAL_HADOOP_CLASSPATHS

$JAVA_RUN $JVM_ARGS ${FLINK_ENV_JAVA_OPTS} "${log_setting[@]}" -classpath "`manglePathList "$FLINK_TM_CLASSPATH"`" ${CLASS_TO_RUN} "${ARGS[@]}" > "$out" 200<&- 2>&1 < /dev/null &

20221130154927

关闭flink
bash bin/stop-cluster.sh

cd flink-dist/target/flink-1.12.7-bin/flink-1.12.7
bash bin/start-cluster.sh

20221130153908

vim flink-1.12.7/bin/flink

移除 $INTERNAL_HADOOP_CLASSPATHS

exec $JAVA_RUN $JVM_ARGS $FLINK_ENV_JAVA_OPTS "${log_setting[@]}" -classpath "`manglePathList "$CC_CLASSPATH"`" org.apache.flink.client.cli.CliFrontend "$@"
bash bin/flink run examples/streaming/WordCount.jar --output log/result.text
cat log/result.text

20221130154756

调试本地flink服务

调试flink源码,启动flink服务
本地启动为standalonesession模式,代码入口org.apache.flink.runtime.entrypoint.StandaloneSessionClusterEntrypoint

执行flinkSql调试flink源码

直接执行sql脚本,调试flink源码运行

目录结构


flink 源码调试
https://ispong.isxcode.com/hadoop/flink/flink 源码调试/
Author
ispong
Posted on
November 30, 2022
Licensed under