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

提交任務(wù)的時(shí)候會(huì)構(gòu)建streamgraph,構(gòu)建streamgraph時(shí)會(huì)用到上面的transform列表,這樣操作和提交任務(wù)就關(guān)聯(lián)起來了。
