私の oozie coordinator.xml ファイルでは、入力ディレクトリとして次のように定義されています。
<property>
<name>countingHourlyInputDir</name>
<value>${coord:dataIn('hourly-input')}/*Pattern1*,${coord:dataIn('hourly-input')}/*Pattern2*</value>
</property>
これは、ファイル名が「Pattern1」または「Pattern2」のいずれかに一致するディレクトリ内のファイルに一致します。ディレクトリにファイル Pattern1 ファイルと Pattern2 ファイルが含まれている場合、私のジョブは問題なく実行されます。ただし、ディレクトリに Pattern1 ファイルまたは Pattern2 ファイルのみが含まれている場合、ジョブは失敗し、次のようなエラーが発生します。
Oozie Launcher の失敗、メイン クラス [org.apache.oozie.action.hadoop.MapReduceMain]、main() が例外をスロー、入力パターン hdfs://hdfsPath/logs/2012/07/09/02/パターン1 は 0 ファイル org に一致します。 apache.hadoop.mapreduce.lib.input.InvalidInputException: 入力パターン hdfs://hdfsPath/logs/2012/07/09/02/ Pattern1は 0 ファイルに一致します
ジョブ全体が失敗するのではなく、パターン 2 に一致するファイルに対して MapReduce ジョブが実行されるように、Oozie にこのエラーを無視するように指示する方法はありますか?
アップデート:
私は自分でこれに対する解決策を見つけました。後で他の誰かがこの問題に遭遇した場合に備えて、私がしたことを文書化します.
PathFilter と Configurable を実装する RegexPathFilter というクラスを作成しました。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;
}
}
ワークフロー.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>