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));

相关推荐
暴躁小师兄数据学院4 小时前
【AI大数据工程师特训笔记】第16讲:大数据环境安装
大数据·hadoop·笔记·flink·spark·database
阿里云大数据AI技术6 小时前
Skill即服务:用Agent安全玩转云上Flink
人工智能·flink
代码匠心1 天前
从零开始学Flink:Flink CDC 入门
大数据·数据仓库·flink
Volunteer Technology1 天前
Flink的 Side Output侧输出和 ProcessFunction
大数据·flink
Volunteer Technology2 天前
Flink的DataStream分区操作
大数据·linux·flink
Volunteer Technology2 天前
Flink Sink
大数据·数据库·flink
段一凡-华北理工大学3 天前
工业领域的Hadoop架构学习~系列文章08:Flink流处理引擎
人工智能·hadoop·学习·架构·flink·高炉炼铁·高炉炼铁智能化
Volunteer Technology3 天前
Flink的函数接口与富函数类
大数据·flink
Volunteer Technology3 天前
Flink编程模型与API(四)
大数据·flink
大大大大晴天️4 天前
告别数据重复与丢失:Flink Exactly-Once 原理解析
大数据·flink