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

相关推荐
D愿你归来仍是少年2 天前
Apache Flink Checkpoint 与 Chandy-Lamport 算法深度解析
算法·flink·apache
docsz2 天前
Flink-1.20集群部署
linux·服务器·flink
念陌曦4 天前
Flink总结
大数据·flink
岁岁种桃花儿5 天前
Flink从入门到上天系列第二十五篇:Flink和Kafka连接时的精准一次性
大数据·flink·kafka
岁岁种桃花儿6 天前
Flink从入门到上天系列第二十四篇:Flink中的保存点
大数据·flink
yumgpkpm6 天前
华为昇腾910B 开源软件GPUStack的介绍(Cloudera CDH、CDP)
人工智能·hadoop·elasticsearch·flink·kafka·企业微信·big data
岁岁种桃花儿7 天前
Flink从入门到上天系列第二十二篇:Flink中通过UI查看检查点
大数据·ui·flink
D愿你归来仍是少年7 天前
Apache Flink 算子(Operator)深度解析
大数据·flink·apache
岁岁种桃花儿7 天前
Flink从入门到上天系列第二十一篇:Flink当中的检查点配置
大数据·flink
岁岁种桃花儿7 天前
Flink从入门到上天系列第二十三篇:Flink中增量检查点和最终检查点
大数据·flink