2016-09-27 50 views
1

我正在研究Spark Streaming編程指南。我有一個基本的疑問,比如它將執行/計算Dstream輸出操作。 例如(我是從一個例子):當火花流將在Dstream執行輸出操作

val ssc = new StreamingContext(conf, Seconds(1)) 
val lines = ssc.socketTextStream("localhost", 7777) 
lines.foreachRDD { rdd => 
    rdd.foreachPartition { partitionOfRecords => 
    val connection = createNewConnection() 
    partitionOfRecords.foreach(record => connection.send(record)) 
    connection.close() 
    } 
} 
// Start the computation 
ssc.start() 
// Wait for the computation to terminate 
ssc.awaitTermination() 

它會在每個batch-iterval這裏1秒做了手術。或者等到終止。

回答

2

它會在1秒鐘的時間內執行每個批處理操作嗎?或者等到終止。

它會每隔1秒讀取一個批次並每次運行整個圖形。在Spark術語中,它被稱爲在每個時間間隔執行作業

串流作業只會在您停止播放時終止。

+0

我們該如何終止流。是通過中斷接收線程嗎? –

+0

通過調用REST API或者終止進程。 –