Search code examples
javahadoopmapreduceassert

How to use Java assertion in Hadoop MapReduce java API?


for java program, we can use

java -ea

to enable assertion check. is it available in hadoop command:

hadoop jar some-mapreduce-program.jar org.foo.bar.MainJob ...

is it possible?


Solution

  • Assuming Hadoop 2+, you can set this property in your mapred-site.xml

    <property>
        <name>mapreduce.map.java.opts</name>
        <value>-ea</value>
    </property>
    

    Alternatively, you can try exporting it in the client opts:

    export HADOOP_CLIENT_OPTS="-ea ${HADOOP_CLIENT_OPTS}"
    hadoop jar some-mapreduce-program.jar org.foo.bar.MainJob ...
    

    Note that if you are using a cluster, this variable should be set in all nodes.