本篇我们看下flink以反压为问题带入,查看数据处理相关的源码
源码分析
之前再Task启动的过程中,Task的run方法中是任务执行的相关逻辑代码,其中有一行
network.registerTask(this);
这行代码就是给这个Task注册网络相关的堆栈
public void registerTask(Task task) throws IOException {
final ResultPartition[] producedPartitions = task.getProducedPartitions();
synchronized (lock) {
if (isShutdown) {
throw new IllegalStateException("NetworkEnvironment is shut down");
}
for (final ResultPartition partition : producedPartitions) {
setupPartition(partition);//注册输出
}
// Setup the buffer pool for each buffer reader
final SingleInputGate[] inputGates = task.getAllInputGates();
for (SingleInputGate gate : inputGates) {
setupInputGate(gate);//注册输入
}
}
}
输出类型为ResultPartition,代表单个任务生成数据的结果分区
输入类型为SingleInputGate(InputGate的子类),看下InputGate的类说明,画了一个很简单明了的图, operation到operation