Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding default hadoop jars in class path

I've seen many manifestations of ways to use the user class path as precedent to the hadoop one. Often times this is done if an m/r job needs a specific version of a library that hadoop coincidentally already uses an older version of (for example jackson's json parser or commons http , etc.)

In any case : I've seen :

mapreduce.task.classpath.user.precedence
mapreduce.task.classpath.first
mapreduce.job.user.classpath.first

Which one of these parameters is the right one to set in my job configuration, in order to force mappers and reducers to have a class path which puts my user defined hadoop_classpath jars BEFORE the hadoop default dependency jars ?

By the way, this is related to this question : Dynamodb requestHandler acception which I recently have found is due to a jar conflict.

like image 658
jayunit100 Avatar asked Jul 27 '12 10:07

jayunit100


2 Answers

So, assuming you're using 0.20.203, this is handled in the TaskRunner.java code as follows:

  • The property you're looking for is on line 94 - mapreduce.user.classpath.first
  • Line 214 is where the call is made to build the list of classpaths, which delegates to a method called getClassPaths(..)
  • getClassPaths() is defined on line 524, and you should be able to see that the configuration property is used to decide on whether your job + dist cache libraries, or the hadoop libraries go on the classpath first

For other versions of hadoop, you're best to check the TaskRunner.java class to confirm the name of the config property after all this is a "semi hidden config":

static final String MAPREDUCE_USER_CLASSPATH_FIRST =
        "mapreduce.user.classpath.first"; //a semi-hidden config
like image 85
Chris White Avatar answered Oct 06 '22 00:10

Chris White


As in the latest Hadoop version (2.2+), you should set:

    conf.setBoolean(MRJobConfig.MAPREDUCE_JOB_USER_CLASSPATH_FIRST, true);
like image 42
fengyun Avatar answered Oct 05 '22 22:10

fengyun