如何在oozie中获取有关已终止作业的更具体错误信息

webghufk  于 2021-06-03  发布在  Hadoop
关注(0)|答案(2)|浏览(353)

我有一个hadoop map reduce作业作为oozie工作流中的一个步骤运行。它是使用java操作启动的,java操作实现org.apache.hadoop.util.tool。
当作业由于某种原因被终止时,我希望能够通过电子邮件发送通知,如果处理过程中出现异常,该通知应包含stacktrace。
目前我是这样做的:

<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>

但我得到的只是:

Job execution failed, error message: [Job failed!]

这不是很有用:)我需要自己去检查所有节点的日志。
如何获得更具体的消息?我应该捕获我的异常并 Package 到工具中的某个oozie可捕获的异常中,还是只使用某些东西而不是${wf:errormessage。。。
谢谢

xqnpmsa8

xqnpmsa81#

我找到了一种通过使用计数器来处理错误和访问原因的方法。也许这不是他们设计的目的,但这似乎是唯一的出路。。。
所以我在mapper和reducer中捕捉每一个被丢弃的东西,就像这样:

} 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();
}

作业完成后,这些计数器可以通过runningjob在工具中轻松访问。”“异常”组包含所有异常的计数器,在displayname字段中包含所有需要的信息。
如果你发现这个方法有什么问题,或者你知道更好的方法,请发表评论。

b1uwtaje

b1uwtaje2#

一个建议是在main方法中捕获异常,然后导出一个属性('exceptiontrace',将异常序列化为其值(与捕获输出标志结合使用),然后可以使用 wf:actionData('myJavaAction')['exceptionTrace'] el函数。
http://oozie.apache.org/docs/3.2.0-incubating/workflowfunctionalspec.html#a3.2.7_java_action

相关问题