2012-07-16 50 views
1

在我Oozie的coordinator.xml文件,我有以下定義爲輸入目錄:oozie可以忽略缺少的輸入文件嗎?

<property> 
    <name>countingHourlyInputDir</name> 
    <value>${coord:dataIn('hourly-input')}/*Pattern1*,${coord:dataIn('hourly-input')}/*Pattern2*</value> 
</property> 

這在文件名匹配的是「樣式1」或「模式2」的目錄中匹配的文件。如果目錄包含文件Pattern1文件和Pattern2文件,我的作業運行沒有問題。但是,如果該目錄僅包含型式1文件或文件模式2,我的工作失敗,我得到這樣一個錯誤:

失敗了Oozie啓動,主要類 [org.apache.oozie.action.hadoop.MapReduceMain ],主()拋出異常 ,輸入圖案 HDFS:// hdfsPath /日誌/ 2012/07/09/02/型式1匹配0文件 org.apache.hadoop.mapreduce.lib.input.InvalidInputException:輸入 模式 hdfs:// hdfsPath/logs/2012/07/09/02/模式1匹配0個文件

有沒有辦法告訴Oozie忽略此錯誤,以便MapReduce作業仍在與Pattern2匹配的文件上執行,而不是失敗整個作業?


UPDATE:

我想出解決這個我自己,我會記錄我做了什麼萬一別人運行到這個問題後。

我創建了一個名爲RegexPathFilter的類來實現PathFilter和Configurable。通過在oozie workflow.xml中指定mapred.input.pathFilter.class屬性,我將此過濾器傳遞到hadoop作業。這裏是我的課,我的配置片段:

public class RegexPathFilter implements PathFilter, Configurable { 

    public static final String CONF_REGEX_PROPERTY = "regexPathFilter.regex"; 
    private static final Log LOG = LogFactory.getLog(RegexPathFilter.class); 
    private String _regex; 
    private Configuration _conf; 

    public RegexPathFilter() { 

    } 

    @Override 
    public void setConf(Configuration conf) { 
     _conf = conf; 
     //get regex from Configuration 
     _regex = _conf.get(CONF_REGEX_PROPERTY); 
    } 

    @Override 
    public Configuration getConf() { 
     return _conf; 
    } 

    public boolean accept(Path path) { 
     if(_regex == null) { 
      throw new IllegalStateException("RegexPathFilter must be given a regex to filter with."); 
     } 

     boolean matches = path.toString().matches(_regex); 

     LOG.info(path + (matches ? " matches " : " does NOT match ") + _regex); 
     return matches; 
    } 
} 

workflow.xml:

<property> 
    <name>mapred.input.pathFilter.class</name> 
    <value>com.company.project.hadoop.util.RegexPathFilter</value> 
</property> 
<property> 
    <name>regexPathFilter.regex</name> 
    <value>.*(Pattern1|Pattern2).*</value> 
</property> 

回答

0

後面這個問題的原因是https://issues.apache.org/jira/browse/HADOOP-8870

我也面臨着同樣的問題,並通過製作解決它模式和零代碼略有變化。

更換

<property> 
    <name>countingHourlyInputDir</name> 
    <value>${coord:dataIn('hourly-input')}/*Pattern1*,${coord:dataIn('hourly-input')}/*Pattern2*</value> 
</property> 

<property> 
    <name>countingHourlyInputDir</name> 
    <value>{${coord:dataIn('hourly-input')}}/{*Pattern1*,*Pattern2*}</value> 
</property> 

這種替換後,只有當目錄中包含的文件匹配既不模式1還是模式2的Hadoop將拋出一個錯誤。

相關問題