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

相关推荐
清平乐的技术专栏2 小时前
【FlinkSQL笔记】(二)Flink SQL 基础语法详解
笔记·sql·flink
码上滚雪球2 小时前
Flink Agents 深度解读:当实时数据流遇上 AI 智能体
大数据·人工智能·flink·滚雪球
若兰幽竹2 小时前
【Flink 电商用户行为分析】从数据采集到实时决策:构建全链路用户行为分析系统设计
大数据·flink·实时数据分析·电商用户行为数据分析
清平乐的技术专栏2 小时前
【FlinkSQL笔记】(一)什么是Flink SQL
笔记·sql·flink
清平乐的技术专栏3 小时前
【FlinkSQL笔记】(三)Flink SQL 核心重难点(窗口函数、水印)
笔记·sql·flink
清平乐的技术专栏18 小时前
【Flink学习】(五)Flink 并行度与任务链,任务运行核心原理
flink
清平乐的技术专栏1 天前
【Flink学习】(六)Flink 三大时间语义 + 水位线 Watermark
大数据·学习·flink
清平乐的技术专栏1 天前
【Flink学习】(一)初识 Flink,大数据实时计算核心认知
大数据·flink
大大大大晴天1 天前
告别混淆!一文讲透 Flink State Backend 与 Checkpoint Storage
flink
docsz1 天前
Ambari3.0集成Flink 2.2+Paimon1.4
大数据·flink