|
@@ -42,6 +42,7 @@ import org.apache.hadoop.mapred.lib.HashPartitioner;
|
|
import org.apache.hadoop.mapred.lib.KeyFieldBasedComparator;
|
|
import org.apache.hadoop.mapred.lib.KeyFieldBasedComparator;
|
|
import org.apache.hadoop.mapred.lib.KeyFieldBasedPartitioner;
|
|
import org.apache.hadoop.mapred.lib.KeyFieldBasedPartitioner;
|
|
import org.apache.hadoop.security.Credentials;
|
|
import org.apache.hadoop.security.Credentials;
|
|
|
|
+import org.apache.hadoop.util.ClassUtil;
|
|
import org.apache.hadoop.util.ReflectionUtils;
|
|
import org.apache.hadoop.util.ReflectionUtils;
|
|
import org.apache.hadoop.util.Tool;
|
|
import org.apache.hadoop.util.Tool;
|
|
|
|
|
|
@@ -436,7 +437,7 @@ public class JobConf extends Configuration {
|
|
* @param cls the example class.
|
|
* @param cls the example class.
|
|
*/
|
|
*/
|
|
public void setJarByClass(Class cls) {
|
|
public void setJarByClass(Class cls) {
|
|
- String jar = findContainingJar(cls);
|
|
|
|
|
|
+ String jar = ClassUtil.findContainingJar(cls);
|
|
if (jar != null) {
|
|
if (jar != null) {
|
|
setJar(jar);
|
|
setJar(jar);
|
|
}
|
|
}
|
|
@@ -1788,38 +1789,6 @@ public class JobConf extends Configuration {
|
|
return
|
|
return
|
|
(int)(Math.ceil((float)getMemoryForReduceTask() / (float)slotSizePerReduce));
|
|
(int)(Math.ceil((float)getMemoryForReduceTask() / (float)slotSizePerReduce));
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Find a jar that contains a class of the same name, if any.
|
|
|
|
- * It will return a jar file, even if that is not the first thing
|
|
|
|
- * on the class path that has a class with the same name.
|
|
|
|
- *
|
|
|
|
- * @param my_class the class to find.
|
|
|
|
- * @return a jar file that contains the class, or null.
|
|
|
|
- * @throws IOException
|
|
|
|
- */
|
|
|
|
- private static String findContainingJar(Class my_class) {
|
|
|
|
- ClassLoader loader = my_class.getClassLoader();
|
|
|
|
- String class_file = my_class.getName().replaceAll("\\.", "/") + ".class";
|
|
|
|
- try {
|
|
|
|
- for(Enumeration itr = loader.getResources(class_file);
|
|
|
|
- itr.hasMoreElements();) {
|
|
|
|
- URL url = (URL) itr.nextElement();
|
|
|
|
- if ("jar".equals(url.getProtocol())) {
|
|
|
|
- String toReturn = url.getPath();
|
|
|
|
- if (toReturn.startsWith("file:")) {
|
|
|
|
- toReturn = toReturn.substring("file:".length());
|
|
|
|
- }
|
|
|
|
- toReturn = URLDecoder.decode(toReturn, "UTF-8");
|
|
|
|
- return toReturn.replaceAll("!.*$", "");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- throw new RuntimeException(e);
|
|
|
|
- }
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* Get the memory required to run a task of this job, in bytes. See
|
|
* Get the memory required to run a task of this job, in bytes. See
|