我构建了一个从 Twitter 接收 DStream 的应用程序,停止流上下文的唯一方法是停止执行。我想知道是否有一种方法可以设置时间并终止流式套接字而不停止整个应用程序?
最佳答案
您可以使用其中之一
awaitTerminationOrTimeout(long)
如上一个答案中所述,或者您可以从其他线程手动停止流上下文:
// in the main thread
awaitTermination(); // will wait forever or until the context is stopped
// in another thread
streamingContext.stop();
关于stream - 一段时间后停止 Spark Streaming 中的流上下文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31116817/