In the Hadoop API documentation it's given
that
setJarByClass public void setJarByClass(Class<?> cls) Set the Jar by finding where a given class came from.
What exactly does this explanation mean? does it creates a JAR file from the class file argument specified in the method above? and does that jar file is executed for the MapReduce task.?
setJarByClass(WordCount. class); Helps to identify the Jar which contains the Mapper and Reducer by specifying a class in that Jar.
A Hadoop Map Reduce job defines, schedules, monitors, and manages the execution of Hadoop Map Reduce . jar files. You can bundle your Map Reduce code in a . jar file and run it using this job.
Job Class. The Job class is the most important class in the MapReduce API. It allows the user to configure the job, submit it, control its execution, and query the state. The set methods only work until the job is submitted, afterwards they will throw an IllegalStateException.
This method sets the jar file in which each node will look for the Mapper and Reducer classes.
It does not create a jar from the given class. Rather, it identifies the jar containing the given class. And yes, that jar file is "executed" (really the Mapper and Reducer in that jar file are executed) for the MapReduce job.
(Also see Stanley Xu's answer to a similar question about the need for this method since you give the jar on the command line)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With