MAPREDUCE-5083. MiniMRCluster should use a random component when creating an actual cluster. Contributed by Siddharth Seth.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1459935 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hitesh Shah 2013-03-22 19:14:07 +00:00
parent 6af4449beb
commit c983b07753
3 changed files with 17 additions and 5 deletions

View File

@ -64,6 +64,9 @@ Release 2.0.5-beta - UNRELEASED
MAPREDUCE-3872. Fix an event handling races in ContainerLauncherImpl. MAPREDUCE-3872. Fix an event handling races in ContainerLauncherImpl.
(Robert Kanter via sseth) (Robert Kanter via sseth)
MAPREDUCE-5083. MiniMRCluster should use a random component when creating an
actual cluster (Siddharth Seth via hitesh)
Release 2.0.4-alpha - UNRELEASED Release 2.0.4-alpha - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -38,6 +38,12 @@ public class MiniMRClientClusterFactory {
public static MiniMRClientCluster create(Class<?> caller, int noOfNMs, public static MiniMRClientCluster create(Class<?> caller, int noOfNMs,
Configuration conf) throws IOException { Configuration conf) throws IOException {
return create(caller, caller.getName(), noOfNMs, conf);
}
public static MiniMRClientCluster create(Class<?> caller, String identifier,
int noOfNMs,
Configuration conf) throws IOException {
if (conf == null) { if (conf == null) {
conf = new Configuration(); conf = new Configuration();
@ -45,7 +51,7 @@ public class MiniMRClientClusterFactory {
FileSystem fs = FileSystem.get(conf); FileSystem fs = FileSystem.get(conf);
Path testRootDir = new Path("target", caller.getName() + "-tmpDir") Path testRootDir = new Path("target", identifier + "-tmpDir")
.makeQualified(fs); .makeQualified(fs);
Path appJar = new Path(testRootDir, "MRAppJar.jar"); Path appJar = new Path(testRootDir, "MRAppJar.jar");
@ -65,10 +71,10 @@ public class MiniMRClientClusterFactory {
fs.setPermission(remoteCallerJar, new FsPermission("744")); fs.setPermission(remoteCallerJar, new FsPermission("744"));
job.addFileToClassPath(remoteCallerJar); job.addFileToClassPath(remoteCallerJar);
MiniMRYarnCluster miniMRYarnCluster = new MiniMRYarnCluster(caller MiniMRYarnCluster miniMRYarnCluster =
.getName(), noOfNMs); new MiniMRYarnCluster(identifier, noOfNMs);
job.getConfiguration().set("minimrclientcluster.caller.name", job.getConfiguration().set("minimrclientcluster.caller.name",
caller.getName()); identifier);
job.getConfiguration().setInt("minimrclientcluster.nodemanagers.number", job.getConfiguration().setInt("minimrclientcluster.nodemanagers.number",
noOfNMs); noOfNMs);
miniMRYarnCluster.init(job.getConfiguration()); miniMRYarnCluster.init(job.getConfiguration());

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.mapred; package org.apache.hadoop.mapred;
import java.io.IOException; import java.io.IOException;
import java.util.Random;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -177,8 +178,10 @@ public class MiniMRCluster {
int numTrackerToExclude, Clock clock) throws IOException { int numTrackerToExclude, Clock clock) throws IOException {
if (conf == null) conf = new JobConf(); if (conf == null) conf = new JobConf();
FileSystem.setDefaultUri(conf, namenode); FileSystem.setDefaultUri(conf, namenode);
String identifier = this.getClass().getName() + "_"
+ Integer.toString(new Random().nextInt(Integer.MAX_VALUE));
mrClientCluster = MiniMRClientClusterFactory.create(this.getClass(), mrClientCluster = MiniMRClientClusterFactory.create(this.getClass(),
numTaskTrackers, conf); identifier, numTaskTrackers, conf);
} }
public UserGroupInformation getUgi() { public UserGroupInformation getUgi() {