Search in sources :

Example 1 with SimpleSessionExample

use of org.apache.tez.examples.SimpleSessionExample in project tez by apache.

the class TestTezJobs method testInvalidQueueSubmission.

@Test(timeout = 60000)
public void testInvalidQueueSubmission() throws Exception {
    TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig());
    YarnClient yarnClient = YarnClient.createYarnClient();
    try {
        yarnClient.init(mrrTezCluster.getConfig());
        yarnClient.start();
        SimpleSessionExample job = new SimpleSessionExample();
        tezConf.setBoolean(TezConfiguration.TEZ_AM_SESSION_MODE, false);
        tezConf.set(TezConfiguration.TEZ_QUEUE_NAME, "nonexistent");
        String[] inputPaths = new String[1];
        String[] outputPaths = new String[1];
        String inputDirStr = "/tmp/owc-input";
        inputPaths[0] = inputDirStr;
        Path inputDir = new Path(inputDirStr);
        remoteFs.mkdirs(inputDir);
        String outputDirStr = "/tmp/owc-output";
        outputPaths[0] = outputDirStr;
        int result = job.run(tezConf, new String[] { StringUtils.join(",", inputPaths), StringUtils.join(",", outputPaths), "2" }, null);
        Assert.assertTrue("Job should have failed", result != 0);
    } catch (TezException e) {
        Assert.assertTrue(e.getMessage().contains("Failed to submit application"));
    } finally {
        if (yarnClient != null) {
            yarnClient.stop();
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) TezException(org.apache.tez.dag.api.TezException) SimpleSessionExample(org.apache.tez.examples.SimpleSessionExample) YarnClient(org.apache.hadoop.yarn.client.api.YarnClient) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) Test(org.junit.Test)

Example 2 with SimpleSessionExample

use of org.apache.tez.examples.SimpleSessionExample in project tez by apache.

the class TestTezJobs method testInvalidQueueSubmissionToSession.

@Test(timeout = 60000)
public void testInvalidQueueSubmissionToSession() throws Exception {
    TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig());
    YarnClient yarnClient = YarnClient.createYarnClient();
    try {
        yarnClient.init(mrrTezCluster.getConfig());
        yarnClient.start();
        SimpleSessionExample job = new SimpleSessionExample();
        tezConf.setBoolean(TezConfiguration.TEZ_AM_SESSION_MODE, true);
        tezConf.set(TezConfiguration.TEZ_QUEUE_NAME, "nonexistent");
        String[] inputPaths = new String[1];
        String[] outputPaths = new String[1];
        String inputDirStr = "/tmp/owc-input";
        inputPaths[0] = inputDirStr;
        Path inputDir = new Path(inputDirStr);
        remoteFs.mkdirs(inputDir);
        String outputDirStr = "/tmp/owc-output";
        outputPaths[0] = outputDirStr;
        job.run(tezConf, new String[] { StringUtils.join(",", inputPaths), StringUtils.join(",", outputPaths), "2" }, null);
        fail("Job submission should have failed");
    } catch (SessionNotRunning e) {
        // Expected
        LOG.info("Session not running", e);
    } catch (TezException e) {
        Assert.assertTrue(e.getMessage().contains("Failed to submit application"));
    } finally {
        if (yarnClient != null) {
            yarnClient.stop();
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) TezException(org.apache.tez.dag.api.TezException) SessionNotRunning(org.apache.tez.dag.api.SessionNotRunning) SimpleSessionExample(org.apache.tez.examples.SimpleSessionExample) YarnClient(org.apache.hadoop.yarn.client.api.YarnClient) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) Test(org.junit.Test)

Example 3 with SimpleSessionExample

use of org.apache.tez.examples.SimpleSessionExample in project tez by apache.

the class TestTezJobs method testSimpleSessionExample.

@Test(timeout = 60000)
public void testSimpleSessionExample() throws Exception {
    Path stagingDirPath = new Path("/tmp/owc-staging-dir");
    remoteFs.mkdirs(stagingDirPath);
    int numIterations = 2;
    String[] inputPaths = new String[numIterations];
    String[] outputPaths = new String[numIterations];
    Path[] outputDirs = new Path[numIterations];
    for (int i = 0; i < numIterations; ++i) {
        String inputDirStr = "/tmp/owc-input-" + i + "/";
        inputPaths[i] = inputDirStr;
        Path inputDir = new Path(inputDirStr);
        remoteFs.mkdirs(inputDir);
        generateOrderedWordCountInput(inputDir, remoteFs);
        String outputDirStr = "/tmp/owc-output-" + i + "/";
        outputPaths[i] = outputDirStr;
        Path outputDir = new Path(outputDirStr);
        outputDirs[i] = outputDir;
    }
    TezConfiguration tezConf = new TezConfiguration(mrrTezCluster.getConfig());
    tezConf.set(TezConfiguration.TEZ_AM_STAGING_DIR, stagingDirPath.toString());
    YarnClient yarnClient = YarnClient.createYarnClient();
    try {
        yarnClient.init(mrrTezCluster.getConfig());
        yarnClient.start();
        List<ApplicationReport> apps = yarnClient.getApplications();
        int appsBeforeCount = apps != null ? apps.size() : 0;
        SimpleSessionExample job = new SimpleSessionExample();
        tezConf.setBoolean(TezConfiguration.TEZ_AM_SESSION_MODE, true);
        Assert.assertTrue("SimpleSessionExample failed", job.run(tezConf, new String[] { StringUtils.join(",", inputPaths), StringUtils.join(",", outputPaths), "2" }, null) == 0);
        for (int i = 0; i < numIterations; ++i) {
            verifyOutput(outputDirs[i], remoteFs);
        }
        apps = yarnClient.getApplications();
        int appsAfterCount = apps != null ? apps.size() : 0;
        // Running in session mode. So should only create 1 more app.
        Assert.assertEquals(appsBeforeCount + 1, appsAfterCount);
    } finally {
        remoteFs.delete(stagingDirPath, true);
        if (yarnClient != null) {
            yarnClient.stop();
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) SimpleSessionExample(org.apache.tez.examples.SimpleSessionExample) YarnClient(org.apache.hadoop.yarn.client.api.YarnClient) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) Test(org.junit.Test)

Aggregations

Path (org.apache.hadoop.fs.Path)3 YarnClient (org.apache.hadoop.yarn.client.api.YarnClient)3 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)3 SimpleSessionExample (org.apache.tez.examples.SimpleSessionExample)3 Test (org.junit.Test)3 TezException (org.apache.tez.dag.api.TezException)2 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)1 SessionNotRunning (org.apache.tez.dag.api.SessionNotRunning)1