我想寫一個火花流媒體程序,我想正常關閉我的應用程序,以防萬一我的應用程序收到關機掛鉤。我寫了下面的代碼片段來完成這個。火花流上下文掛在停止
sys.ShutdownHookThread {
println("Gracefully stopping MyStreamJob")
ssc.stop(stopSparkContext = true, stopGracefully = true)
println("Streaming stopped")
sys.exit(0)
}
在調用此代碼時,只調用第一個println。這是第二個println Streaming Stopped從未見過。我在控制檯上收到的最後一條消息是:
39790 [shutdownHook1] INFO org.spark-project.jetty.server.handler.ContextHandler - stopped o.s.j.s.ServletContextHandler{/streaming,null}
39791 [shutdownHook1] INFO org.spark-project.jetty.server.handler.ContextHandler - stopped o.s.j.s.ServletContextHandler{/streaming/batch,null}
39792 [shutdownHook1] INFO org.spark-project.jetty.server.handler.ContextHandler - stopped o.s.j.s.ServletContextHandler{/static/streaming,null}
15/10/19 19:59:43 INFO handler.ContextHandler: stopped o.s.j.s.ServletContextHandler{/static/streaming,null}
我正在使用spark 1.4.1。我必須使用kill -9
手動殺死火花才能結束的作業。這是預期的行爲還是我做錯了什麼?
我已經有了Spark 1.5的相同經驗。由於'stop()'仍然在文檔和API中,我認爲它有一定的價值,但現在可能只是爲了內部使用......我只是'awaitTermination()'。 – BAR