【发布时间】:2020-04-28 14:33:50
【问题描述】:
我正在学习 Apache Flink,这里是字数示例: https://ci.apache.org/projects/flink/flink-docs-stable/getting-started/tutorials/local_setup.html
我在工作,但我有些东西看不懂。
Flink 包含三个部分:JobManager、TaskManager 和 JobClient。据我了解,SocketWindowWordCount 类的 java 代码应该是JobClient 的一部分,这个类应该将它要求做的事情发送到JobClient 然后JobClient 可以将任务发送到JobManager .
我说的对吗?
如果我是对的,我不知道文件SocketWindowWordCount.java 中的哪一部分代码负责将它要求做的事情发送到JobClient。
监听端口是否也是任务的一部分,该任务将发送到JobManager,然后发送到TaskManager?
// get input data by connecting to the socket
DataStream<String> text = env.socketTextStream("localhost", port, "\n");
// parse the data, group it, window it, and aggregate the counts
DataStream<WordWithCount> windowCounts = text
.flatMap(new FlatMapFunction<String, WordWithCount>() {
@Override
public void flatMap(String value, Collector<WordWithCount> out) {
for (String word : value.split("\\s")) {
out.collect(new WordWithCount(word, 1L));
}
}
})
.keyBy("word")
.timeWindow(Time.seconds(5), Time.seconds(1))
.reduce(new ReduceFunction<WordWithCount>() {
@Override
public WordWithCount reduce(WordWithCount a, WordWithCount b) {
return new WordWithCount(a.word, a.count + b.count);
}
});
// print the results with a single thread, rather than in parallel
windowCounts.print().setParallelism(1);
上面的所有代码都是任务的一部分吗?
总之,我有点了解 Flink 的架构,但我想了解更多关于 JobClient 工作原理的细节。
【问题讨论】:
标签: apache-flink