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?
Asked
Active
Viewed 1.1k times
2 Answers
8
You can use either
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();

vanekjar
- 2,386
- 14
- 23
3
You can use the awaitTermination()
method on the streamingContext
object to wait for a specified time. Refer this
-
Eclipse gives me this marker, The method awaitTermination(long) from the type JavaStreamingContext is deprecated! Spark 1.4.0. I used awaitTerminationOrTimeout(Long), still doesn't work..it keep printing. – Jun 29 '15 at 14:34
-
public void awaitTermination(long timeout) Deprecated. As of 1.3.0, replaced by awaitTerminationOrTimeout(Long). Wait for the execution to stop. Any exceptions that occurs during the execution will be thrown in this thread. Parameters: timeout - time to wait in milliseconds – urug Jun 29 '15 at 14:34