我正在以集群模式在YARN上运行一个Spark Streaming应用程序,我尝试实现优雅的关闭,这样当应用程序被杀死时,它将在停止之前完成当前微批处理的执行。
根据一些教程,我已经配置了
在执行者日志中,我看到以下错误:
根据一些教程,我已经配置了
spark.streaming.stopGracefullyOnShutdown
为true
,并且我已经添加了以下代码到我的应用程序:sys.ShutdownHookThread {
log.info("Gracefully stopping Spark Streaming Application")
ssc.stop(true, true)
log.info("Application stopped")
}
然而,当我使用
yarn application -kill application_1454432703118_3558
杀掉应用程序时,此时执行的微批处理未完成。
在驱动程序中,我看到打印了第一行日志(“优雅地停止Spark Streaming应用程序”),但没有打印最后一行日志(“应用程序已停止”)。
ERROR yarn.ApplicationMaster: RECEIVED SIGNAL 15: SIGTERM
INFO streaming.MySparkJob: Gracefully stopping Spark Streaming Application
INFO scheduler.JobGenerator: Stopping JobGenerator gracefully
INFO scheduler.JobGenerator: Waiting for all received blocks to be consumed for job generation
INFO scheduler.JobGenerator: Waited for all received blocks to be consumed for job generation
INFO streaming.StreamingContext: Invoking stop(stopGracefully=true) from shutdown hook
在执行者日志中,我看到以下错误:
ERROR executor.CoarseGrainedExecutorBackend: Driver 192.168.6.21:49767 disassociated! Shutting down.
INFO storage.DiskBlockManager: Shutdown hook called
WARN remote.ReliableDeliverySupervisor: Association with remote system [akka.tcp://sparkDriver@192.168.6.21:49767] has failed, address is now gated for [5000] ms. Reason: [Disassociated]
INFO util.ShutdownHookManager: Shutdown hook called
我认为问题与YARN如何发送终止信号给应用有关。你有什么想法可以让应用程序优雅地停止吗?