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秒做了手術。或者等到終止。
我們該如何終止流。是通過中斷接收線程嗎? –
通過調用REST API或者終止進程。 –