Updated on 2022-08-16 GMT+08:00

MapReduce Action

Function

The MapReduce Action node is used to execute a map-reduce job.

Parameter Description

Table 1 describes parameters used on the MapReduce Action node.

Table 1 Parameters

Parameter

Meaning

name

Identifies a map-reduce action.

resourceManager

Indicates the MapReduce ResourceManager address.

name-node

Indicates the Hadoop distributed file system (HDFS) NameNode address.

queueName

Identifies the MapReduce queue where a job is executed.

mapred.mapper.class

Identifies the Mapper class.

mapred.reducer.class

Identifies the Reducer class.

mapred.input.dir

Indicates the input directory of MapReduce processed data.

mapred.output.dir

Indicates the output directory of MapReduce processing results.

mapred.map.tasks

Indicates the number of map tasks.

${variable name} indicates the value defined in job.properties.

For example, ${nameNode} indicates hdfs://hacluster. (See job.properties.)

Example Codes

<action name="mr-dataLoad">
     <map-reduce>
          <resource-manager>${resourceManager}</resource-manager>
          <name-node>${nameNode}</name-node>
          <prepare>
              <delete path="${nameNode}/user/${wf:user()}/${dataLoadRoot}/output-data/map-reduce"/>
          </prepare>
          <configuration>
              <property>
                  <name>mapred.job.queue.name</name>
                  <value>${queueName}</value>
              </property>
              <property>
                  <name>mapred.mapper.class</name>
                  <value>org.apache.oozie.example.SampleMapper</value>
              </property>
              <property>
                  <name>mapred.reducer.class</name>
                  <value>org.apache.oozie.example.SampleReducer</value>
              </property>
              <property>
                  <name>mapred.map.tasks</name>
                  <value>1</value>
              </property>
              <property>
                  <name>mapred.input.dir</name>
                  <value>/user/oozie/${dataLoadRoot}/input-data/text</value>
                </property>
                <property>
                    <name>mapred.output.dir</name>
                    <value>/user/${wf:user()}/${dataLoadRoot}/output-data/map-reduce</value>
                </property>
            </configuration>
        </map-reduce>
        <ok to="copyData"/>
        <error to="fail"/>
    </action>