2012-11-23 46 views
6

我有一個hadoop map-reduce作業作爲Oozie工作流程的一個步驟運行。 它使用實現org.apache.hadoop.util.Tool的java動作啓動。如何在Oozie中找到更多具體的錯誤信息

由於某種原因,當作業被殺害時,如果在處理過程中出現異常,我希望能夠通過電子郵件發送包含堆棧跟蹤的通知。

目前我做這種方式:

<action name="sendErrorNotifications"> 
    <email xmlns="uri:oozie:email-action:0.1"> 
     <to>[email protected]</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!] 

這是不是很實用:),我需要去檢查所有的節點記錄我自己。

如何獲得更具體的消息?我應該抓住我的異常,幷包裝成在工具的一些Oozie的-開捕一個,或者只是使用的東西,而不是$ {WF:...的errorMessage

感謝

回答

2

我找到了一種方法來處理錯誤,並通過使用計數器訪問的原因。也許這不是他們所設計的,但它似乎是唯一出路......

所以我抓住每一個在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(); 
} 

而且這些計數器很容易作業完成後,通過RunningJob在工具中訪問。 「例外」組包含displayName字段中包含所有所需信息的所有例外計數器。

如果您發現此方法存在任何問題或者您知道更好的方法,請發表評論。

2

一個建議是捕獲異常在主方法,然後導出一個屬性(例如'exceptionTrace'),並將異常序列化爲其值(與捕獲 - 輸出標誌組合),然後您可以使用EL函數進行引用。

http://oozie.apache.org/docs/3.2.0-incubating/WorkflowFunctionalSpec.html#a3.2.7_Java_Action

+0

問題是,它不可能在工具中捕獲reducer中發生的異常。我們在那裏有一份工作狀態,所以我們現在可以出現問題了......我將提供我用作解決方案的解決方案。 – Art

相關問題