hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rohithsharm...@apache.org
Subject [hadoop] 05/05: YARN-8567. Fetching yarn logs fails for long running application if it is not present in timeline store. Contributed by Tarun Parimi.
Date Thu, 05 Sep 2019 12:52:21 GMT
This is an automated email from the ASF dual-hosted git repository.

rohithsharmaks pushed a commit to branch branch-3.2
in repository https://gitbox.apache.org/repos/asf/hadoop.git

commit 4d9c5300e2341e954e3c01bd364388df265276cc
Author: Rohith Sharma K S <rohithsharmaks@apache.org>
AuthorDate: Fri Jan 4 14:01:24 2019 +0530

    YARN-8567. Fetching yarn logs fails for long running application if it is not present
in timeline store. Contributed by Tarun Parimi.
---
 .../yarn/client/api/impl/YarnClientImpl.java       |  2 +-
 .../yarn/client/api/impl/TestYarnClient.java       | 50 ++++++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletion(-)

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 227f7ed..76cd196 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
@@ -870,7 +870,7 @@ public class YarnClientImpl extends YarnClient {
     try {
       containersListFromAHS =
           getContainerReportFromHistory(applicationAttemptId);
-    } catch (IOException e) {
+    } catch (IOException | YarnException e) {
       if (appNotFoundInRM) {
         throw e;
       }
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 17e43ca..7ad7e3a 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
@@ -531,6 +531,44 @@ public class TestYarnClient extends ParameterizedSchedulerTestBase {
   }
 
   @Test(timeout = 10000)
+  public void testGetContainersOnAHSFail() throws YarnException, IOException {
+    Configuration conf = getConf();
+    conf.setBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED,
+        true);
+
+    final YarnClient client = new MockYarnClient() {
+      @Override
+      public List<ContainerReport> getContainers(
+          ApplicationAttemptId appAttemptId) throws YarnException,
+          IOException  {
+        return getContainersOnAHSFail(appAttemptId);
+      }
+    };
+
+    client.init(conf);
+    client.start();
+
+    ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
+    ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
+        applicationId, 1);
+    List<ContainerReport> reports = client.getContainers(appAttemptId);
+    Assert.assertNotNull(reports);
+    Assert.assertTrue(reports.size() == 2);
+    Assert.assertEquals(reports.get(0).getContainerId(),
+        (ContainerId.newContainerId(appAttemptId, 1)));
+    Assert.assertEquals(reports.get(1).getContainerId(),
+        (ContainerId.newContainerId(appAttemptId, 2)));
+
+    //Only 2 running containers from RM are present when AHS throws exception
+    Assert.assertEquals(ContainerState.RUNNING,
+        (reports.get(0).getContainerState()));
+    Assert.assertEquals(ContainerState.RUNNING,
+        (reports.get(1).getContainerState()));
+    client.stop();
+  }
+
+
+  @Test(timeout = 10000)
   public void testGetContainerReport() throws YarnException, IOException {
     Configuration conf = getConf();
     conf.setBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED,
@@ -914,6 +952,18 @@ public class TestYarnClient extends ParameterizedSchedulerTestBase {
       return super.getContainers(appAttemptId);
     }
 
+    protected List<ContainerReport>
+        getContainersOnAHSFail(ApplicationAttemptId appAttemptId)
+          throws YarnException, IOException {
+      when(mockContainersResponse.getContainerList()).thenReturn(
+          getContainersReport(appAttemptId));
+      when(historyClient.getContainers(any(ApplicationAttemptId.class)))
+          .thenThrow(new ApplicationNotFoundException(
+              appAttemptId.getApplicationId() +
+                  " does not exist in the timeline store"));
+      return super.getContainers(appAttemptId);
+    }
+
     private List<ContainerReport> getContainersFromAHS(
         ApplicationAttemptId appAttemptId) {
       return containersFromAHS.get(appAttemptId);


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message