Example usage for org.apache.hadoop.yarn.api.records ApplicationReport getApplicationId

List of usage examples for org.apache.hadoop.yarn.api.records ApplicationReport getApplicationId

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.api.records ApplicationReport getApplicationId.

Prototype

@Public
@Stable
public abstract ApplicationId getApplicationId();

Source Link

Document

Get the ApplicationId of the application.

Usage

From source file:org.springframework.yarn.client.CommandLineClientRunner.java

License:Apache License

/**
 * Gets the application report table.//from   ww  w .j a  va  2s . c  om
 *
 * @param applications the applications
 * @return the application report table
 */
private static Table getApplicationReportTable(List<ApplicationReport> applications) {
    Table table = new Table();
    table.addHeader(1, new TableHeader("Id")).addHeader(2, new TableHeader("User"))
            .addHeader(3, new TableHeader("Name")).addHeader(4, new TableHeader("Queue"))
            .addHeader(5, new TableHeader("StartTime")).addHeader(6, new TableHeader("FinishTime"))
            .addHeader(7, new TableHeader("State")).addHeader(8, new TableHeader("FinalStatus"));

    for (ApplicationReport a : applications) {
        final TableRow row = new TableRow();
        row.addValue(1, a.getApplicationId().toString()).addValue(2, a.getUser()).addValue(3, a.getName())
                .addValue(4, a.getQueue())
                .addValue(5,
                        DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)
                                .format(new Date(a.getStartTime())))
                .addValue(6,
                        DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)
                                .format(new Date(a.getFinishTime())))
                .addValue(7, a.getYarnApplicationState().toString())
                .addValue(8, a.getFinalApplicationStatus().toString());
        table.getRows().add(row);
    }
    return table;
}

From source file:org.springframework.yarn.test.junit.AbstractYarnClusterTests.java

License:Apache License

/**
 * Finds the current application state.//from  ww  w.  ja v a 2 s .c o m
 *
 * @param client the Yarn client
 * @param applicationId Yarn app application id
 * @return Current application state or <code>NULL</code> if not found
 */
private YarnApplicationState findState(YarnClient client, ApplicationId applicationId) {
    YarnApplicationState state = null;
    for (ApplicationReport report : client.listApplications()) {
        if (report.getApplicationId().equals(applicationId)) {
            state = report.getYarnApplicationState();
            break;
        }
    }
    return state;
}

From source file:org.springframework.yarn.test.YarnClusterTests.java

License:Apache License

private YarnApplicationState findState(YarnClient client, ApplicationId applicationId) {
    YarnApplicationState state = null;/* w  w w  .ja  va 2 s .c om*/
    for (ApplicationReport report : client.listApplications()) {
        if (report.getApplicationId().equals(applicationId)) {
            state = report.getYarnApplicationState();
            break;
        }
    }
    return state;
}

From source file:org.trustedanalytics.servicebroker.h2oprovisioner.cdhclients.DeprovisionerYarnClientTest.java

License:Apache License

@Before
public void setUp() {
    expectedYarnJobId1 = mock(ApplicationId.class);
    ApplicationReport yarnJobMetadata1 = mock(ApplicationReport.class);
    when(yarnJobMetadata1.getName()).thenReturn(expectedH2oJobName);
    when(yarnJobMetadata1.getApplicationId()).thenReturn(expectedYarnJobId1);

    // another YarnJob with the same name
    expectedYarnJobId2 = mock(ApplicationId.class);
    ApplicationReport yarnJobMetadata2 = mock(ApplicationReport.class);
    when(yarnJobMetadata2.getName()).thenReturn(expectedH2oJobName);
    when(yarnJobMetadata2.getApplicationId()).thenReturn(expectedYarnJobId2);

    yarnReportWithOneJob = ImmutableList.of(yarnJobMetadata1);
    yarnReportWithNoJobs = ImmutableList.of();
    yarnReportWithTwoJobs = ImmutableList.of(yarnJobMetadata1, yarnJobMetadata2);
}

From source file:yrun.commands.Yps.java

License:Apache License

public static void main(String[] args) throws YarnException, IOException {
    YarnClient yarnClient = YarnClient.createYarnClient();
    YarnConfiguration yarnConfiguration = new YarnConfiguration();
    yarnClient.init(yarnConfiguration);//from   www .  j  a v a  2s . c o  m
    yarnClient.start();
    try {
        List<ApplicationReport> applications = yarnClient.getApplications();
        for (ApplicationReport applicationReport : applications) {
            ApplicationId applicationId = applicationReport.getApplicationId();
            String user = applicationReport.getUser();
            String queue = applicationReport.getQueue();
            String name = applicationReport.getName();
            YarnApplicationState yarnApplicationState = applicationReport.getYarnApplicationState();
            float progress = applicationReport.getProgress();
            System.out.printf("%s\t%s\t%s\t%s\t%s\t%f%n", toString(applicationId), user, queue, name,
                    yarnApplicationState.name(), progress);
        }
    } finally {
        yarnClient.stop();
        yarnClient.close();
    }
}