man*_*sha 3 amazon-emr apache-spark
在火花工作。我正在使用如果文件未找到 system.exit(0)。它应该优雅地完成工作。本地 成功完成。但是当我在 EMR 上运行时。步骤失败。
EMR 使用YARN进行集群管理和启动 Spark 应用程序。因此,当您--deploy-mode: cluster
在 EMR 中运行 Spark 应用程序时,Spark 应用程序代码不会单独在 JVM 中运行,而是由ApplicationMaster
类执行。
浏览ApplicationMaster
代码可以解释当您尝试执行时会发生什么System.exit()
。用户应用程序在 中启动startUserApplication
,然后finish
在用户应用程序返回后调用该方法。但是,当您调用 时System.exit(0)
,执行的是关闭挂钩,它会看到您的代码尚未成功完成,并将其标记为EXIT_EARLY
失败。它也有这个有用的评论:
// The default state of ApplicationMaster is failed if it is invoked by shut down hook.
// This behavior is different compared to 1.x version.
// If user application is exited ahead of time by calling System.exit(N), here mark
// this application as failed with EXIT_EARLY. For a good shutdown, user shouldn't call
// System.exit(0) to terminate the application.
Run Code Online (Sandbox Code Playgroud)