hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjs...@apache.org
Subject hadoop git commit: YARN-3123. Made YARN CLI show a single completed container even if the app is running. Contributed by Naganarasimha G R.
Date Thu, 05 Feb 2015 00:08:25 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 17797c73c -> 2db56a493


YARN-3123. Made YARN CLI show a single completed container even if the app is running. Contributed
by Naganarasimha G R.

(cherry picked from commit 30510cff75d3bf4c030c215318b5611600a5b4ee)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/2db56a49
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/2db56a49
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/2db56a49

Branch: refs/heads/branch-2
Commit: 2db56a4932f937c0b72a3aae3458bf1c6b8cd2d8
Parents: 17797c7
Author: Zhijie Shen <zjshen@apache.org>
Authored: Wed Feb 4 16:02:52 2015 -0800
Committer: Zhijie Shen <zjshen@apache.org>
Committed: Wed Feb 4 16:07:24 2015 -0800

----------------------------------------------------------------------
 hadoop-yarn-project/CHANGES.txt                 |  3 ++
 .../yarn/client/api/impl/YarnClientImpl.java    |  4 +-
 .../yarn/client/api/impl/TestYarnClient.java    | 51 ++++++++++++++++++--
 3 files changed, 53 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/2db56a49/hadoop-yarn-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index 9bd3861..11f5a6d 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -208,6 +208,9 @@ Release 2.7.0 - UNRELEASED
     YARN-1723. AMRMClientAsync missing blacklist addition and removal
     functionality. (Bartosz Ɓugowski via sseth)
 
+    YARN-3123. Made YARN CLI show a single completed container even if the app
+    is running. (Naganarasimha G R via zjshen)
+
   OPTIMIZATIONS
 
   BUG FIXES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/2db56a49/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java
index 99c0f02..975c267 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java
@@ -100,6 +100,7 @@ import org.apache.hadoop.yarn.client.api.YarnClientApplication;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.exceptions.ApplicationIdNotProvidedException;
 import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException;
+import org.apache.hadoop.yarn.exceptions.ContainerNotFoundException;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
 import org.apache.hadoop.yarn.security.AMRMTokenIdentifier;
@@ -638,7 +639,8 @@ public class YarnClientImpl extends YarnClient {
       }
       // Even if history-service is enabled, treat all exceptions still the same
       // except the following
-      if (e.getClass() != ApplicationNotFoundException.class) {
+      if (e.getClass() != ApplicationNotFoundException.class
+          && e.getClass() != ContainerNotFoundException.class) {
         throw e;
       }
       return historyClient.getContainerReport(containerId);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/2db56a49/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java
index 7859688..eb8ca48 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java
@@ -35,6 +35,7 @@ import java.util.Collections;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -97,6 +98,8 @@ import org.apache.hadoop.yarn.client.api.YarnClient;
 import org.apache.hadoop.yarn.client.api.YarnClientApplication;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.exceptions.ApplicationIdNotProvidedException;
+import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException;
+import org.apache.hadoop.yarn.exceptions.ContainerNotFoundException;
 import org.apache.hadoop.yarn.exceptions.YarnException;
 import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier;
 import org.apache.hadoop.yarn.server.MiniYARNCluster;
@@ -372,6 +375,8 @@ public class TestYarnClient {
   @Test(timeout = 10000)
   public void testGetContainerReport() throws YarnException, IOException {
     Configuration conf = new Configuration();
+    conf.setBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED,
+        true);
     final YarnClient client = new MockYarnClient();
     client.init(conf);
     client.start();
@@ -388,6 +393,12 @@ public class TestYarnClient {
     Assert.assertEquals(report.getContainerId().toString(),
         (ContainerId.newContainerId(expectedReports.get(0)
             .getCurrentApplicationAttemptId(), 1)).toString());
+    containerId = ContainerId.newContainerId(appAttemptId, 3);
+    report = client.getContainerReport(containerId);
+    Assert.assertNotNull(report);
+    Assert.assertEquals(report.getContainerId().toString(),
+        (ContainerId.newContainerId(expectedReports.get(0)
+            .getCurrentApplicationAttemptId(), 3)).toString());
     client.stop();
   }
 
@@ -642,8 +653,23 @@ public class TestYarnClient {
     @Override
     public ContainerReport getContainerReport(ContainerId containerId)
         throws YarnException, IOException {
-      when(mockContainerResponse.getContainerReport()).thenReturn(
-        getContainer(containerId));
+      try {
+        ContainerReport container = getContainer(containerId, containers);
+        when(mockContainerResponse.getContainerReport()).thenReturn(container);
+      } catch (YarnException e) {
+        when(rmClient.getContainerReport(any(GetContainerReportRequest.class)))
+        .thenThrow(e).thenReturn(mockContainerResponse);
+      }
+      try {
+        ContainerReport container =
+            getContainer(containerId, containersFromAHS);
+        when(historyClient.getContainerReport(any(ContainerId.class)))
+            .thenReturn(container);
+      } catch (YarnException e) {
+        when(historyClient.getContainerReport(any(ContainerId.class)))
+            .thenThrow(e);
+      }
+
       return super.getContainerReport(containerId);
     }
     
@@ -661,8 +687,25 @@ public class TestYarnClient {
       return containers.get(appAttemptId);
     }
 
-    public ContainerReport getContainer(ContainerId containerId) {
-      return containers.get(containerId.getApplicationAttemptId()).get(0);
+    private ContainerReport getContainer(
+        ContainerId containerId,
+        HashMap<ApplicationAttemptId, List<ContainerReport>> containersToAppAttemptMapping)
+        throws YarnException, IOException {
+      List<ContainerReport> containersForAppAttempt =
+          containersToAppAttemptMapping.get(containerId
+              .getApplicationAttemptId());
+      if (containersForAppAttempt == null) {
+        throw new ApplicationNotFoundException(containerId
+            .getApplicationAttemptId().getApplicationId() + " is not found ");
+      }
+      Iterator<ContainerReport> iterator = containersForAppAttempt.iterator();
+      while (iterator.hasNext()) {
+        ContainerReport next = iterator.next();
+        if (next.getContainerId().equals(containerId)) {
+          return next;
+        }
+      }
+      throw new ContainerNotFoundException(containerId + " is not found ");
     }
   }
 


Mime
View raw message