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

相关推荐
Apache Flink3 小时前
克服Flink SQL限制的混合API方法
大数据·sql·flink
Hello.Reader3 小时前
Flink SQL 性能调优MiniBatch、两阶段聚合、Distinct 拆分、MultiJoin 与 Delta Join 一文打通
sql·spring·flink
Jackeyzhe14 小时前
Flink源码阅读:Watermark机制
flink
愤怒的苹果ext1 天前
Flink CDC MySQL同步到Elasticsearch
mysql·elasticsearch·flink·cdc·同步数据
天码-行空1 天前
【大数据环境安装指南】Flink的Standalone Cluster(独立集群)部署教程
大数据·linux·运维·flink
lhyzws1 天前
CENTOS上的网络安全工具(三十五)Portainer Kafka-Clickhouse部署 Flink安装部署与编程
clickhouse·flink·kafka
我爱娃哈哈1 天前
SpringBoot + Kafka + Flink:用户行为日志实时采集与实时画像构建实战
spring boot·flink·kafka
梦想画家1 天前
工业级方案:基于Flink+MQTT实现IOT数据实时可靠存储至S3
mqtt·flink·iot
Hello.Reader2 天前
Flink SQL Gateway 把 Flink SQL 变成“多客户端并发可用”的统一服务入口
sql·flink·gateway
Hello.Reader2 天前
Flink OLAP Quickstart把 Flink 当成“秒级交互查询”的 OLAP 服务来用
数据库·sql·flink