【Flink系列二十】Flink Example AsyncIOExample long running 应用程序的应用
1.【Flink系列二十】Flink Example AsyncIOExample long running 应用程序的应用
2.【Flink系列二十一】深入理解 JVM的类型加载约束,解决 Flink 类型加载冲突问题的通用方法3.【Flink系列十九】Flink 作业Hadoop 依赖冲突解决NoSuchMethodError4.HDFS_DELEGATION_TOKEN过期的问题解决汇总5.【Flink系列十八】History Server 重新登场,如何实现Yarn日志集成6.【Flink系列十七】Flink 最新yarn-application和yarn-per-job部署模式的Classpath传递分析7.【Flink系列十六】PrometheusPushGatewayReporter 限流压力过大解决8.【Flink系列十五】FLINK-24950 registerTemporaryFunction NullPointerException9.【Flink系列十四】Flink JVM参数不生效的问题分析和解决10.【Flink系列十三】Flink-Kafka-Connector KafkaSource FlinkKafkaConsumer没有上报指标11.【Flink系列十二】使用OpenResty 在InfluxDB协议层拦截Flink指标12.【Flink系列十一】FlinkSQL Gateway以及支持Kerberos多租户的实现思路13.【Flink系列十】Flink作业提交过程的调试和诊断14.【Flink系列九】Flink 作业提交遇到的问题记录以及原理15.【Flink系列八】构建实时计算平台——动态加载Catalog中的UDF16.【Flink系列零】构建实时计算平台——FlinkSQL 作业菜鸟笔记17.【Flink系列七】构建实时计算平台——校验FlinkSQL18.【Flink系列六】构建实时计算平台——Flink 1.10+通过Kerberos连接HiveCatalog19.【Flink系列五】构建实时计算平台——flink-connector-hive连接HiveMetastore遇到问题20.【Flink系列四】构建实时计算平台——Flink SQLClient启动失败的问题笔记21.【Flink系列三】构建实时计算平台——特别篇,Influxdb Java客户端访问指标数据22.【Flink系列二】构建实时计算平台——特别篇,用InfluxDb收集Flink Metrics23.【Flink系列一】构建实时计算平台——Flink开启和恢复CheckpointFlink AsyncIOExample
Flink 的源码内有这么一个AsyncIOExample程序,非常好用,可以用来无限跑流。
用英文说就是long running或者runs forever。
同时可以用来测试checkpoints,metricReporter。
如何找到这个程序
这个程序在源码内,但很不幸,官方可能忘记加到maven ant插件的构建过程中。
以Flink-1.13.0为例:
使用方法
private static void printUsage() {
System.out.println(
"To customize example, use: AsyncIOExample [--fsStatePath <path to fs state>] "
+ "[--checkpointMode <exactly_once or at_least_once>] "
+ "[--maxCount <max number of input from source, -1 for infinite input>] "
+ "[--sleepFactor <interval to sleep for each stream element>] [--failRatio <possibility to throw exception>] "
+ "[--waitMode <ordered or unordered>] [--waitOperatorParallelism <parallelism for async wait operator>] "
+ "[--eventType <EventTime or IngestionTime>] [--shutdownWaitTS <milli sec to wait for thread pool>]"
+ "[--timeout <Timeout for the asynchronous operations>]");
}
为什么下载的flink examples文件夹内没有AsyncIO.jar
flink-examples/flink-examples-streaming/pom.xml
仅仅因为下方的代码忘记写一行copy了。
<!--simplify the name of example JARs for build-target/examples -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>rename</id>
<configuration>
<target>
<copy file="${project.basedir}/target/flink-examples-streaming_${scala.binary.version}-${project.version}-Iteration.jar" tofile="${project.basedir}/target/Iteration.jar" />
<copy file="${project.basedir}/target/flink-examples-streaming_${scala.binary.version}-${project.version}-SessionWindowing.jar" tofile="${project.basedir}/target/SessionWindowing.jar" />
<copy file="${project.basedir}/target/flink-examples-streaming_${scala.binary.version}-${project.version}-TopSpeedWindowing.jar" tofile="${project.basedir}/target/TopSpeedWindowing.jar" />
<copy file="${project.basedir}/target/flink-examples-streaming_${scala.binary.version}-${project.version}-WindowJoin.jar" tofile="${project.basedir}/target/WindowJoin.jar" />
<copy file="${project.basedir}/target/flink-examples-streaming_${scala.binary.version}-${project.version}-WordCount.jar" tofile="${project.basedir}/target/WordCount.jar" />
<copy file="${project.basedir}/target/flink-examples-streaming_${scala.binary.version}-${project.version}-SocketWindowWordCount.jar" tofile="${project.basedir}/target/SocketWindowWordCount.jar" />
</target>
</configuration>
</execution>
</executions>
</plugin>
如何运行
可以直接复制源码,进行编译,无需compile任何依赖(可能需要rocksdb的依赖)
编译完成以后复制到任何位置,例如本应该存在于下方的路径:
./bin/flink run-application examples/streaming/AsyncIO.jar \
-D "state.checkpoints.num-retained=5"
--class org.apache.flink.streaming.examples.async.AsyncIOExample \
--fsStatePath viewfs://slankka_hdfs/user/slankka/flink_checkpoints \
--checkpointMode exactly_once \
--maxCount \
-1
提示
注意这个程序的流有点快,可能导致打印大量console日志写盘,可修改数据源流的间隔时间。
注意 maxCount=-1时,这个程序将长时间运行下去,否则运行一段时间达到maxCount则会FINISHED退出,可根据这个参数选择是否长时间运行。
注意checkpoint的间隔是1秒一个,如果使用了External Checkpoint Storage,则可能会写入大量Checkpoint,可以修改checkpoint保留个数。
如果需要测试MetricReporter, 则需要配置相应的flink-conf。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!