Skip to content

Instantly share code, notes, and snippets.

@rssanders3
Last active January 24, 2019 17:13
Show Gist options
  • Select an option

  • Save rssanders3/46bc496d777092e4a6393a948dd3b165 to your computer and use it in GitHub Desktop.

Select an option

Save rssanders3/46bc496d777092e4a6393a948dd3b165 to your computer and use it in GitHub Desktop.
var TRIGGER_STOP = false
var ssc: StreamingContext = …
// Define Stream Creation, Transformations and Actions here.
ssc.start()
var isStopped = false
while (!isStopped) {
isStopped = ssc.awaitTerminationOrTimeout(SPARK_SHUTDOWN_CHECK_MILLIS)
if (isStopped)
LOGGER.info("The Spark Streaming context is stopped. Exiting application...")
else
LOGGER.info("Streaming App is still running. Timeout...")
checkShutdownMarker(ssc, SPARK_SHUTDOWN_RUNNING_MARKER_TOUCH_FILE_LOCATION)
if (!isStopped && TRIGGER_STOP) {
LOGGER.info("Stopping the ssc Spark Streaming Context...")
ssc.stop(stopSparkContext = true, stopGracefully = true)
LOGGER.info("Spark Streaming Context is Stopped!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment