一段时间后停止 Spark Streaming 中的流上下文 [英] Stop streaming context in Spark Streaming after a period of time
本文介绍了一段时间后停止 Spark Streaming 中的流上下文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我构建了一个从 Twitter 接收 DStream 的应用程序,停止 Streaming 上下文的唯一方法是停止执行.我想知道是否有一种方法可以在不停止整个应用程序的情况下设置时间并终止流式套接字?
I building an application which receives DStreams from Twitter, the only way to stop the Streaming context is by stoping the execution. I wonder if there is a way to set a time and terminate the streaming socket without stoping the entire application?
推荐答案
您可以使用任一
awaitTerminationOrTimeout(long)
如上一个答案中所述,或者您可以从其他线程手动停止流上下文:
as mentioned in the previous answer, or you can stop the streaming context manually from your other thread:
// in the main thread
awaitTermination(); // will wait forever or until the context is stopped
// in another thread
streamingContext.stop();
这篇关于一段时间后停止 Spark Streaming 中的流上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文