hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [47/50] [abbrv] git commit: YARN-2542. Fixed NPE when retrieving ApplicationReport from TimeLineServer. Contributed by Zhijie Shen
Date Sat, 13 Sep 2014 03:54:53 GMT
YARN-2542. Fixed NPE when retrieving ApplicationReport from TimeLineServer. Contributed by
Zhijie Shen


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

Branch: refs/heads/HDFS-6581
Commit: a0ad975ea1e70f9532cf6cb6c1d9d92736ca0ebc
Parents: e65ae57
Author: Jian He <jianhe@apache.org>
Authored: Fri Sep 12 15:24:17 2014 -0700
Committer: Jian He <jianhe@apache.org>
Committed: Fri Sep 12 15:27:13 2014 -0700

----------------------------------------------------------------------
 hadoop-yarn-project/CHANGES.txt                 |  3 +
 .../hadoop/yarn/client/cli/ApplicationCLI.java  | 12 ++-
 .../hadoop/yarn/client/cli/TestYarnCLI.java     | 80 ++++++++++----------
 3 files changed, 54 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/a0ad975e/hadoop-yarn-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index efc3e09..06d94ca 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -348,6 +348,9 @@ Release 2.6.0 - UNRELEASED
     YARN-2456. Possible livelock in CapacityScheduler when RM is recovering apps.
     (Jian He via xgong)
 
+    YARN-2542. Fixed NPE when retrieving ApplicationReport from TimeLineServer.
+    (Zhijie Shen via jianhe)
+
 Release 2.5.1 - 2014-09-05
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a0ad975e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/ApplicationCLI.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/ApplicationCLI.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/ApplicationCLI.java
index 54cfe91..a847cd5 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/ApplicationCLI.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/ApplicationCLI.java
@@ -463,9 +463,15 @@ public class ApplicationCLI extends YarnCLI {
       appReportStr.println(appReport.getHost());
       appReportStr.print("\tAggregate Resource Allocation : ");
 
-      ApplicationResourceUsageReport usageReport = appReport.getApplicationResourceUsageReport();
-      appReportStr.print(usageReport.getMemorySeconds() + " MB-seconds, ");
-      appReportStr.println(usageReport.getVcoreSeconds() + " vcore-seconds");
+      ApplicationResourceUsageReport usageReport =
+          appReport.getApplicationResourceUsageReport();
+      if (usageReport != null) {
+        //completed app report in the timeline server doesn't have usage report
+        appReportStr.print(usageReport.getMemorySeconds() + " MB-seconds, ");
+        appReportStr.println(usageReport.getVcoreSeconds() + " vcore-seconds");
+      } else {
+        appReportStr.println("N/A");
+      }
       appReportStr.print("\tDiagnostics : ");
       appReportStr.print(appReport.getDiagnostics());
     } else {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/a0ad975e/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java
index 1a593d2..980517f 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java
@@ -86,44 +86,48 @@ public class TestYarnCLI {
   
   @Test
   public void testGetApplicationReport() throws Exception {
-    ApplicationCLI cli = createAndGetAppCLI();
-    ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
-    ApplicationResourceUsageReport usageReport = 
-        ApplicationResourceUsageReport.newInstance(
-            2, 0, null, null, null, 123456, 4567);
-    ApplicationReport newApplicationReport = ApplicationReport.newInstance(
-        applicationId, ApplicationAttemptId.newInstance(applicationId, 1),
-        "user", "queue", "appname", "host", 124, null,
-        YarnApplicationState.FINISHED, "diagnostics", "url", 0, 0,
-        FinalApplicationStatus.SUCCEEDED, usageReport, "N/A", 0.53789f, "YARN",
-        null);
-    when(client.getApplicationReport(any(ApplicationId.class))).thenReturn(
-        newApplicationReport);
-    int result = cli.run(new String[] { "application", "-status", applicationId.toString()
});
-    assertEquals(0, result);
-    verify(client).getApplicationReport(applicationId);
-    ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    PrintWriter pw = new PrintWriter(baos);
-    pw.println("Application Report : ");
-    pw.println("\tApplication-Id : application_1234_0005");
-    pw.println("\tApplication-Name : appname");
-    pw.println("\tApplication-Type : YARN");
-    pw.println("\tUser : user");
-    pw.println("\tQueue : queue");
-    pw.println("\tStart-Time : 0");
-    pw.println("\tFinish-Time : 0");
-    pw.println("\tProgress : 53.79%");
-    pw.println("\tState : FINISHED");
-    pw.println("\tFinal-State : SUCCEEDED");
-    pw.println("\tTracking-URL : N/A");
-    pw.println("\tRPC Port : 124");
-    pw.println("\tAM Host : host");
-    pw.println("\tAggregate Resource Allocation : 123456 MB-seconds, 4567 vcore-seconds");
-    pw.println("\tDiagnostics : diagnostics");
-    pw.close();
-    String appReportStr = baos.toString("UTF-8");
-    Assert.assertEquals(appReportStr, sysOutStream.toString());
-    verify(sysOut, times(1)).println(isA(String.class));
+    for (int i = 0; i < 2; ++i) {
+      ApplicationCLI cli = createAndGetAppCLI();
+      ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
+      ApplicationResourceUsageReport usageReport = i == 0 ? null :
+          ApplicationResourceUsageReport.newInstance(
+              2, 0, null, null, null, 123456, 4567);
+      ApplicationReport newApplicationReport = ApplicationReport.newInstance(
+          applicationId, ApplicationAttemptId.newInstance(applicationId, 1),
+          "user", "queue", "appname", "host", 124, null,
+          YarnApplicationState.FINISHED, "diagnostics", "url", 0, 0,
+          FinalApplicationStatus.SUCCEEDED, usageReport, "N/A", 0.53789f, "YARN",
+          null);
+      when(client.getApplicationReport(any(ApplicationId.class))).thenReturn(
+          newApplicationReport);
+      int result = cli.run(new String[] { "application", "-status", applicationId.toString()
});
+      assertEquals(0, result);
+      verify(client, times(1 + i)).getApplicationReport(applicationId);
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      PrintWriter pw = new PrintWriter(baos);
+      pw.println("Application Report : ");
+      pw.println("\tApplication-Id : application_1234_0005");
+      pw.println("\tApplication-Name : appname");
+      pw.println("\tApplication-Type : YARN");
+      pw.println("\tUser : user");
+      pw.println("\tQueue : queue");
+      pw.println("\tStart-Time : 0");
+      pw.println("\tFinish-Time : 0");
+      pw.println("\tProgress : 53.79%");
+      pw.println("\tState : FINISHED");
+      pw.println("\tFinal-State : SUCCEEDED");
+      pw.println("\tTracking-URL : N/A");
+      pw.println("\tRPC Port : 124");
+      pw.println("\tAM Host : host");
+      pw.println("\tAggregate Resource Allocation : " +
+          (i == 0 ? "N/A" : "123456 MB-seconds, 4567 vcore-seconds"));
+      pw.println("\tDiagnostics : diagnostics");
+      pw.close();
+      String appReportStr = baos.toString("UTF-8");
+      Assert.assertEquals(appReportStr, sysOutStream.toString());
+      sysOutStream.reset();
+      verify(sysOut, times(1 + i)).println(isA(String.class));
+    }
   }
 
   @Test


Mime
View raw message