MAPREDUCE-3370. Fixed MiniMRYarnCluster and related tests to not use a hard-coded path for the mr-app jar. Contributed by Ahmed Radwan.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1200776 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5c88a335b4
commit
838bb254fe
|
@ -1833,7 +1833,7 @@ public class JobConf extends Configuration {
|
|||
* @return a jar file that contains the class, or null.
|
||||
* @throws IOException
|
||||
*/
|
||||
static String findContainingJar(Class my_class) {
|
||||
public static String findContainingJar(Class my_class) {
|
||||
ClassLoader loader = my_class.getClassLoader();
|
||||
String class_file = my_class.getName().replaceAll("\\.", "/") + ".class";
|
||||
try {
|
||||
|
|
|
@ -101,6 +101,9 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<yarn.mr.jar>${project.build.directory}/${project.artifactId}-${project.version}.jar</yarn.mr.jar>
|
||||
</systemPropertyVariables>
|
||||
<additionalClasspathElements>
|
||||
<!-- workaround for JobConf#setJarByClass -->
|
||||
<additionalClasspathElement>${project.build.directory}/${project.artifactId}-${project.version}-tests.jar</additionalClasspathElement>
|
||||
|
|
|
@ -24,6 +24,8 @@ import java.io.IOException;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.mapred.JobConf;
|
||||
import org.apache.hadoop.mapred.LocalContainerLauncher;
|
||||
import org.apache.hadoop.mapred.ShuffleHandler;
|
||||
import org.apache.hadoop.mapreduce.MRConfig;
|
||||
import org.apache.hadoop.mapreduce.MRJobConfig;
|
||||
|
@ -43,15 +45,8 @@ import org.apache.hadoop.yarn.service.Service;
|
|||
*/
|
||||
public class MiniMRYarnCluster extends MiniYARNCluster {
|
||||
|
||||
public static final String HADOOP_MAPREDUCE_CLIENT_APP_JAR_NAME =
|
||||
"hadoop-mapreduce-client-app-0.23.0-SNAPSHOT.jar";
|
||||
|
||||
public static final String YARN_MAPREDUCE_APP_JAR_PATH =
|
||||
"$YARN_HOME/modules/" + HADOOP_MAPREDUCE_CLIENT_APP_JAR_NAME;
|
||||
|
||||
public static final String APPJAR =
|
||||
"../hadoop-mapreduce-client-app/target/"
|
||||
+ HADOOP_MAPREDUCE_CLIENT_APP_JAR_NAME;
|
||||
public static final String APPJAR = System.getProperty("yarn.mr.jar", JobConf
|
||||
.findContainingJar(LocalContainerLauncher.class));
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(MiniMRYarnCluster.class);
|
||||
private JobHistoryServer historyServer;
|
||||
|
|
|
@ -58,6 +58,12 @@
|
|||
<scope>test</scope>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
<artifactId>hadoop-mapreduce-client-core</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
<artifactId>hadoop-yarn-server-tests</artifactId>
|
||||
|
@ -99,6 +105,15 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<yarn.ds.jar>${project.build.directory}/${project.artifactId}-${project.version}.jar</yarn.ds.jar>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.io.IOException;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.mapred.JobConf;
|
||||
import org.apache.hadoop.yarn.server.MiniYARNCluster;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -36,7 +37,8 @@ public class TestDistributedShell {
|
|||
protected static MiniYARNCluster yarnCluster = null;
|
||||
protected static Configuration conf = new Configuration();
|
||||
|
||||
protected static String APPMASTER_JAR = "../hadoop-yarn-applications-distributedshell/target/hadoop-yarn-applications-distributedshell-0.23.0-SNAPSHOT.jar";
|
||||
protected static String APPMASTER_JAR = System.getProperty("yarn.ds.jar",
|
||||
JobConf.findContainingJar(ApplicationMaster.class));
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() throws InterruptedException, IOException {
|
||||
|
|
Loading…
Reference in New Issue