Search in sources :

Example 6 with ApplicationTimeout

use of org.apache.hadoop.yarn.api.records.ApplicationTimeout in project hadoop by apache.

the class TestYarnCLI method testGetApplicationReport.

@Test
public void testGetApplicationReport() throws Exception {
    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, 0, 0, 1111, 2222);
        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, null, false, Priority.newInstance(0), "high-mem", "high-mem");
        newApplicationReport.setLogAggregationStatus(LogAggregationStatus.SUCCEEDED);
        newApplicationReport.setPriority(Priority.newInstance(0));
        ApplicationTimeout timeout = ApplicationTimeout.newInstance(ApplicationTimeoutType.LIFETIME, "UNLIMITED", -1);
        newApplicationReport.setApplicationTimeouts(Collections.singletonMap(timeout.getTimeoutType(), timeout));
        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("\tApplication Priority : 0");
        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("\tAggregate Resource Preempted : " + (i == 0 ? "N/A" : "1111 MB-seconds, 2222 vcore-seconds"));
        pw.println("\tLog Aggregation Status : SUCCEEDED");
        pw.println("\tDiagnostics : diagnostics");
        pw.println("\tUnmanaged Application : false");
        pw.println("\tApplication Node Label Expression : high-mem");
        pw.println("\tAM container Node Label Expression : high-mem");
        pw.print("\tTimeoutType : LIFETIME");
        pw.print("\tExpiryTime : UNLIMITED");
        pw.println("\tRemainingTime : -1seconds");
        pw.println();
        pw.close();
        String appReportStr = baos.toString("UTF-8");
        Assert.assertEquals(appReportStr, sysOutStream.toString());
        sysOutStream.reset();
        verify(sysOut, times(1 + i)).println(isA(String.class));
    }
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) ApplicationResourceUsageReport(org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport) ApplicationTimeout(org.apache.hadoop.yarn.api.records.ApplicationTimeout) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Aggregations

ApplicationTimeout (org.apache.hadoop.yarn.api.records.ApplicationTimeout)6 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)4 ApplicationResourceUsageReport (org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport)3 Test (org.junit.Test)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 PrintWriter (java.io.PrintWriter)2 UpdateApplicationTimeoutsRequest (org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsRequest)2 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)2 ApplicationTimeoutType (org.apache.hadoop.yarn.api.records.ApplicationTimeoutType)2 OutputStreamWriter (java.io.OutputStreamWriter)1 DecimalFormat (java.text.DecimalFormat)1 HashMap (java.util.HashMap)1 GetApplicationReportRequest (org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest)1 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)1 FinalApplicationStatus (org.apache.hadoop.yarn.api.records.FinalApplicationStatus)1 LogAggregationStatus (org.apache.hadoop.yarn.api.records.LogAggregationStatus)1 Priority (org.apache.hadoop.yarn.api.records.Priority)1 ApplicationNotFoundException (org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException)1 RecordFactory (org.apache.hadoop.yarn.factories.RecordFactory)1 AppTimeoutsMapProto (org.apache.hadoop.yarn.proto.YarnProtos.AppTimeoutsMapProto)1