Art*_*Art 6 hadoop exception-handling mapreduce exception oozie
我有一个hadoop map-reduce作为Oozie工作流程中的一个步骤运行.它是使用实现org.apache.hadoop.util.Tool的java动作开始的.
当作业因某种原因被杀死时,如果在处理过程中出现异常,我希望能够通过电子邮件发送应包含堆栈跟踪的通知.
目前我是这样做的:
<action name="sendErrorNotifications">
<email xmlns="uri:oozie:email-action:0.1">
<to>some-dl@company.com</to>
<subject>Job execution failed ${wf:id()}</subject>
<body>Job execution failed, error message: [${wf:errorMessage(wf:lastErrorNode())}]</body>
</email>
<ok to="fail" />
<error to="fail" />
</action>
Run Code Online (Sandbox Code Playgroud)
但我收到的只是:
Job execution failed, error message: [Job failed!]
Run Code Online (Sandbox Code Playgroud)
哪个不是很有用:)我需要自己检查所有节点的日志.
如何获得更具体的消息?我应该抓住我的异常并将其包含在工具中的一些oozie-catchable中,或者只使用一些东西而不是$ {wf:errorMessage ...
谢谢
我找到了一种使用计数器来处理错误并访问原因的方法。也许这不是他们设计的目的,但这似乎是唯一的出路......
所以我在映射器和减速器中捕获每个 Throwable,如下所示:
} catch (Throwable t) {
Counters.Counter counter = reporter.getCounter("Exceptions", t.getClass().getSimpleName());
counter.increment(1);
counter.setDisplayName(t.getClass().getSimpleName() + "\n last failed key: " + key.toString() + "\n " + ExceptionUtils.getStackTrace(t));
reporter.incrCounter("Exceptions", "TOTAL_COUNT", 1);
reporter.progress();
}
Run Code Online (Sandbox Code Playgroud)
作业完成后,可以通过 RunningJob 在工具中轻松访问这些计数器。“异常”组包含所有异常计数器以及显示名称字段中的所有所需信息。
如果您发现这种方法有任何问题或者您知道更好的方法,请发表评论。