以下是個flink簡化的例子,看flink的代碼時有點疑問宴卖,?env.execute(""),這句執(zhí)行任務(wù)席纽,是怎么跟上面的數(shù)據(jù)流text的相關(guān)操作關(guān)聯(lián)起來的,看了半天源碼終于有個大概的認識了屑彻。
public class SocketWindowWordCount {
? ? public static void main(String[] args) throws Exception {
? ? ? ? final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
DataStream text = env.socketTextStream("localhost", 9000, "\n");
? ? ? //對text各種操作验庙,之后提交任務(wù)
DataStream> wordCounts = text .flatMap(new FlatMapFunction>() {
? ? ? ? ? ? ? ? });
? ? ? ? env.execute("Socket Window WordCount");
? ? }
}
每個操作最后都會變?yōu)閠ransform,加到transform列表里社牲,代碼如下:
提交任務(wù)的時候會構(gòu)建streamgraph粪薛,構(gòu)建streamgraph時會用到上面的transform列表,這樣操作和提交任務(wù)就關(guān)聯(lián)起來了搏恤。