From 5765eb1868cbd6b30619030c5cf6b8f2e08f7a85 Mon Sep 17 00:00:00 2001 From: Robert Joseph Evans Date: Tue, 1 May 2012 16:02:31 +0000 Subject: [PATCH] svn merge -c 1332716. FIXES: MAPREDUCE-4202. TestYarnClientProtocolProvider is broken (Daryn Sharp via bobby) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1332719 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-mapreduce-project/CHANGES.txt | 3 +++ .../mapred/LocalClientProtocolProvider.java | 5 +++-- .../TestYarnClientProtocolProvider.java | 20 ++++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index f2435bedf0c..1350d89321e 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -327,6 +327,9 @@ Release 0.23.3 - UNRELEASED MAPREDUCE-4211. Error conditions (missing appid, appid not found) are masked in the RM app page (Jonathan Eagles via bobby) + MAPREDUCE-4202. TestYarnClientProtocolProvider is broken (Daryn Sharp via + bobby) + Release 0.23.2 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapred/LocalClientProtocolProvider.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapred/LocalClientProtocolProvider.java index 2b6ad992ceb..cead4349db2 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapred/LocalClientProtocolProvider.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapred/LocalClientProtocolProvider.java @@ -33,8 +33,9 @@ public class LocalClientProtocolProvider extends ClientProtocolProvider { @Override public ClientProtocol create(Configuration conf) throws IOException { - String framework = conf.get(MRConfig.FRAMEWORK_NAME); - if (framework != null && !framework.equals(MRConfig.LOCAL_FRAMEWORK_NAME)) { + String framework = + conf.get(MRConfig.FRAMEWORK_NAME, MRConfig.LOCAL_FRAMEWORK_NAME); + if (!MRConfig.LOCAL_FRAMEWORK_NAME.equals(framework)) { return null; } String tracker = conf.get(JTConfig.JT_IPC_ADDRESS, "local"); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/TestYarnClientProtocolProvider.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/TestYarnClientProtocolProvider.java index 3a88e71cddc..7052c769023 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/TestYarnClientProtocolProvider.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/TestYarnClientProtocolProvider.java @@ -28,6 +28,7 @@ import junit.framework.TestCase; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.Text; +import org.apache.hadoop.mapred.LocalJobRunner; import org.apache.hadoop.mapred.ResourceMgrDelegate; import org.apache.hadoop.mapred.YARNRunner; import org.apache.hadoop.mapreduce.protocol.ClientProtocol; @@ -54,17 +55,26 @@ public class TestYarnClientProtocolProvider extends TestCase { try { cluster = new Cluster(conf); - fail("Cluster should not be initialized with out any framework name"); - } catch (IOException e) { - + } catch (Exception e) { + throw new Exception( + "Failed to initialize a local runner w/o a cluster framework key", e); } - + + try { + assertTrue("client is not a LocalJobRunner", + cluster.getClient() instanceof LocalJobRunner); + } finally { + if (cluster != null) { + cluster.close(); + } + } + try { conf = new Configuration(); conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.YARN_FRAMEWORK_NAME); cluster = new Cluster(conf); ClientProtocol client = cluster.getClient(); - assertTrue(client instanceof YARNRunner); + assertTrue("client is a YARNRunner", client instanceof YARNRunner); } catch (IOException e) { } finally {