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或者终止进程。 –