【Flink精讲】Flink任务调度机制

Graph 的概念

Flink 中的执行图可以分成四层: StreamGraph -> JobGraph -> ExecutionGraph -> 物理执

行图。

  • StreamGraph:是根据用户通过 Stream API 编写的代码生成的最初的图。用来表示程序的拓扑结构。
  • JobGraph: StreamGraph 经过优化后生成了 JobGraph,提交给 JobManager 的数据结构。主要的优化为,将多个符合条件的节点 chain 在一起作为一个节点,这样可以减少数据在节点之间流动所需要的序列化/反序列化/传输消耗。
  • ExecutionGraph: JobManager 根据 JobGraph 生成 ExecutionGraph。 ExecutionGraph 是JobGraph 的并行化版本,是调度层最核心的数据结构。
  • 物 理 执 行 图 : JobManager 根据 ExecutionGraph 对 Job 进行调度后,在各个TaskManager 上部署 Task 后形成的"图",并不是一个具体的数据结构。

WordCount举例

java 复制代码
public static void main(String[] args) throws Exception {
// 检查输入
final ParameterTool params = ParameterTool.fromArgs(args);
...
// set up the execution environment
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
// get input data
DataStream<String> text =
env.socketTextStream(params.get("hostname"), params.getInt("port"), '\n', 0);
DataStream<Tuple2<String, Integer>> counts =
// split up the lines in pairs (2-tuples) containing: (word,1)
text.flatMap(new Tokenizer())
// group by the tuple field "0" and sum up tuple field "1"
.keyBy(0)
.sum(1);
counts.print();
// execute program
env.execute("WordCount from SocketTextStream Example");
}

StreamGraph在Client生成

分区器

JobGraph在Client生成

ExecutionGraph在JobManager生成

相关推荐
疯狂成瘾者5 小时前
上传到 GitHub 的步骤总结
大数据·elasticsearch·github
七夜zippoe9 小时前
OpenClaw 接入 WhatsApp:消息推送实战
大数据·人工智能·microsoft·whatsapp·openclaw
RFID科技的魅力9 小时前
从开箱到实战:CP300R触屏RFID打印机全场景使用测评
大数据·人工智能·物联网·rfid
Forrit11 小时前
Agent长期运行(Long-Running Tasks)实现方案与核心挑战
大数据·人工智能·深度学习
2601_9553631512 小时前
技术赋能B端拓客:号码核验的行业困局与破局路径氪迹科技法人股东筛选系统,阶梯式价格
大数据·人工智能
财经资讯数据_灵砚智能13 小时前
全球财经资讯日报(夜间-次晨)2026年3月28日
大数据·人工智能·python·语言模型·ai编程
@insist12313 小时前
数据库系统工程师-云计算与大数据核心知识
大数据·数据库·云计算·软考·数据库系统工程师·软件水平考试
scan72414 小时前
小龙虾模拟人的性格,需要带上历史信息作为上下文
大数据