Example usage for org.apache.hadoop.yarn.server.resourcemanager ClientRMService getApplicationReport

List of usage examples for org.apache.hadoop.yarn.server.resourcemanager ClientRMService getApplicationReport

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.server.resourcemanager ClientRMService getApplicationReport.

Prototype

@Override
public GetApplicationReportResponse getApplicationReport(GetApplicationReportRequest request)
        throws YarnException 

Source Link

Document

It gives response which includes application report if the application present otherwise throws ApplicationNotFoundException.

Usage

From source file:org.apache.tez.auxservices.TestShuffleHandlerJobs.java

License:Apache License

@Test(timeout = 300000)
public void testOrderedWordCount() throws Exception {
    String inputDirStr = "/tmp/owc-input/";
    Path inputDir = new Path(inputDirStr);
    Path stagingDirPath = new Path("/tmp/owc-staging-dir");
    remoteFs.mkdirs(inputDir);/*w  w  w.  ja  v a2 s .  c o m*/
    remoteFs.mkdirs(stagingDirPath);
    generateOrderedWordCountInput(inputDir, remoteFs);

    String outputDirStr = "/tmp/owc-output/";
    Path outputDir = new Path(outputDirStr);

    TezConfiguration tezConf = new TezConfiguration(tezCluster.getConfig());
    tezConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, stagingDirPath.toString());
    tezConf.set(TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID, ShuffleHandler.TEZ_SHUFFLE_SERVICEID);
    tezConf.setBoolean(TezConfiguration.TEZ_AM_DAG_CLEANUP_ON_COMPLETION, true);
    tezConf.setBoolean(TezConfiguration.TEZ_AM_SESSION_MODE, true);
    tezConf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_OPTIMIZE_LOCAL_FETCH, false);
    tezConf.setBoolean(TezConfiguration.TEZ_AM_CONTAINER_REUSE_ENABLED, false);
    TezClient tezSession = TezClient.create("WordCountTest", tezConf);
    tezSession.start();
    try {
        final OrderedWordCount job = new OrderedWordCount();
        Assert.assertTrue("OrderedWordCount failed", job.run(tezConf,
                new String[] { "-counter", inputDirStr, outputDirStr, "10" }, tezSession) == 0);
        verifyOutput(outputDir, remoteFs);
        tezSession.stop();
        ClientRMService rmService = tezCluster.getResourceManager().getClientRMService();
        boolean isAppComplete = false;
        while (!isAppComplete) {
            GetApplicationReportResponse resp = rmService
                    .getApplicationReport(new GetApplicationReportRequest() {
                        @Override
                        public ApplicationId getApplicationId() {
                            return job.getAppId();
                        }

                        @Override
                        public void setApplicationId(ApplicationId applicationId) {
                        }
                    });
            if (resp.getApplicationReport().getYarnApplicationState() == YarnApplicationState.FINISHED) {
                isAppComplete = true;
            }
            Thread.sleep(100);
        }
        for (int i = 0; i < NUM_NMS; i++) {
            String appPath = tezCluster.getTestWorkDir() + "/" + this.getClass().getName() + "-localDir-nm-" + i
                    + "_0/usercache/" + UserGroupInformation.getCurrentUser().getUserName() + "/appcache/"
                    + job.getAppId();
            String dagPathStr = appPath + "/dag_1";

            File fs = new File(dagPathStr);
            Assert.assertFalse(fs.exists());
            fs = new File(appPath);
            Assert.assertTrue(fs.exists());
        }
    } finally {
        remoteFs.delete(stagingDirPath, true);
    }
}