FlinkSQL源码解析1--提交任务过程

提交入口

org.apache.flink.table.api.internal.TableEnvironmentImpl#executeSql

@Override

public TableResult executeSql(String statement) {

List<Operation> operations = getParser().parse(statement);

if (operations.size() != 1) {

throw new TableException(UNSUPPORTED_QUERY_IN_EXECUTE_SQL_MSG);

}

Operation operation = operations.get(0);

return executeInternal(operation);

}

提交过程概述

sql--》operation--》Transformation--》pipeline(StreamGraph)--》JobGraph--》deployJobCluster

具体过程

1、查询转成operation

sql-->SqlNodeList-->flinkPlanner.validate(sqlNode)-->Optional<Operation> operation = SqlNodeConverters.convertSqlNode(validated, context);

2、operation转成pipeline(StreamGraph)

org.apache.flink.table.api.internal.TableEnvironmentImpl#executeQueryOperation

executeQueryOperation--》

2.1、operation转成Transformation

List<Transformation<?>> transformations = translate(Collections.singletonList(sinkOperation));--》

org.apache.flink.table.planner.delegation.PlannerBase#translate

2.2、Transformation转成pipeline

Pipeline pipeline =

execEnv.createPipeline(

transformations, tableConfig.getConfiguration(), defaultJobName);

2.3、pipeline转成streamGraph

final StreamGraph streamGraph = executionEnvironment.generateStreamGraph(transformations); // StreamGraph是Pipeline接口的实现类

3、将StreamGraph转成JobGraph

org.apache.flink.streaming.api.environment.StreamExecutionEnvironment#executeAsync(org.apache.flink.streaming.api.graph.StreamGraph)

JobClient jobClient = execEnv.executeAsync(pipeline);

3.1、final PipelineExecutor executor = getPipelineExecutor();

CompletableFuture<JobClient> jobClientFuture =

executor.execute(streamGraph, configuration, userClassloader);

3.2、createJobGraph#new StreamingJobGraphGenerator(

userClassLoader, streamGraph, jobID, serializationExecutor)

.createJobGraph();

4、将jobGraph提交到集群

org.apache.flink.client.deployment.executors.AbstractJobClusterExecutor#execute

4.1、获取集群信息

final ClusterClientProvider<ClusterID> clusterClientProvider =

clusterDescriptor.deployJobCluster(

clusterSpecification, jobGraph, configAccessor.getDetachedMode

4.2、提交任务到集群

return CompletableFuture.completedFuture(

new ClusterClientJobClientAdapter<>(

clusterClientProvider, jobGraph.getJobID(), userCodeClassloader));

相关推荐
亚马逊云开发者1 天前
EMR Core 节点部署 Flink Client 实战:Bootstrap Action 一次打包多次复用,解决调度系统提交任务的痛点
大数据·flink·bootstrap
juniperhan2 天前
Flink 系列第20篇:Flink SQL 语法全解:从 DDL 到 DML,窗口、聚合、列转行一网打尽
大数据·数据仓库·分布式·sql·flink
大大大大晴天2 天前
Flink技术实践——Flink资源扩缩容方案演进
flink
csgo打的菜又爱玩2 天前
9.Dispatcher 启动流程解析
大数据·flink·源代码管理
大大大大晴天️2 天前
Flink技术实践——Flink资源扩缩容方案演进
大数据·flink
阿里云大数据AI技术2 天前
Agentic风控:Flink+Fluss+大模型构建Agent全链路风险感知与实时告警
人工智能·flink
juniperhan3 天前
Flink 系列第18篇:Flink 动态表、连续查询与 Changelog 机制
java·大数据·数据仓库·分布式·flink
juniperhan3 天前
Flink 系列第19篇:深入理解 Flink SQL 的时间语义与时区处理:从原理到实战
java·大数据·数据仓库·分布式·sql·flink
渣渣盟4 天前
Flink流处理:实时计算URL访问量TopN(基于时间窗口)
大数据·flink·scala