Search in sources :

Example 6 with MockContainerLauncher

use of org.apache.tez.dag.app.MockDAGAppMaster.MockContainerLauncher in project tez by apache.

the class TestMockDAGAppMaster method testDAGFinishedRecoveryError.

@Test(timeout = 5000)
public void testDAGFinishedRecoveryError() throws Exception {
    TezConfiguration tezconf = new TezConfiguration(defaultConf);
    MockTezClient tezClient = new MockTezClient("testMockAM", tezconf, true, null, null, null, null);
    tezClient.start();
    MockDAGAppMaster mockApp = tezClient.getLocalClient().getMockApp();
    mockApp.recoveryFatalError = true;
    MockContainerLauncher mockLauncher = mockApp.getContainerLauncher();
    mockLauncher.startScheduling(true);
    DAG dag = DAG.create("test");
    Vertex vA = Vertex.create("A", ProcessorDescriptor.create("Proc.class"), 5);
    dag.addVertex(vA);
    DAGClient dagClient = tezClient.submitDAG(dag);
    dagClient.waitForCompletion();
    while (!mockApp.getShutdownHandler().wasShutdownInvoked()) {
        Thread.sleep(100);
    }
    Assert.assertEquals(DAGState.SUCCEEDED, mockApp.getContext().getCurrentDAG().getState());
    Assert.assertEquals(DAGAppMasterState.FAILED, mockApp.getState());
    Assert.assertTrue(StringUtils.join(mockApp.getDiagnostics(), ",").contains("Recovery had a fatal error, shutting down session after" + " DAG completion"));
}
Also used : Vertex(org.apache.tez.dag.api.Vertex) DAGClient(org.apache.tez.dag.api.client.DAGClient) DAG(org.apache.tez.dag.api.DAG) MockContainerLauncher(org.apache.tez.dag.app.MockDAGAppMaster.MockContainerLauncher) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) Test(org.junit.Test)

Example 7 with MockContainerLauncher

use of org.apache.tez.dag.app.MockDAGAppMaster.MockContainerLauncher in project tez by apache.

the class TestMockDAGAppMaster method testBasicStatisticsMemory.

@Ignore
@Test(timeout = 60000)
public void testBasicStatisticsMemory() throws Exception {
    Logger.getRootLogger().setLevel(Level.WARN);
    TezConfiguration tezconf = new TezConfiguration(defaultConf);
    MockTezClient tezClient = new MockTezClient("testMockAM", tezconf, true, null, null, null, null, false, false);
    tezClient.start();
    final String vAName = "abcdefghijklmnopqrstuvwxyz";
    int numTasks = 10000;
    int numSources = 10;
    IOStatistics ioStats = new IOStatistics();
    ioStats.setDataSize(1);
    ioStats.setItemsProcessed(1);
    TaskStatistics vAStats = new TaskStatistics();
    DAG dag = DAG.create("testBasicStatisticsMemory");
    Vertex vA = Vertex.create(vAName, ProcessorDescriptor.create("Proc.class"), numTasks);
    for (int i = 0; i < numSources; ++i) {
        final String sourceName = i + vAName;
        vA.addDataSource(sourceName, DataSourceDescriptor.create(InputDescriptor.create(sourceName), null, null));
        vAStats.addIO(sourceName, ioStats);
    }
    dag.addVertex(vA);
    ByteArrayOutputStream bosA = new ByteArrayOutputStream();
    DataOutput outA = new DataOutputStream(bosA);
    vAStats.write(outA);
    final byte[] payloadA = bosA.toByteArray();
    MockDAGAppMaster mockApp = tezClient.getLocalClient().getMockApp();
    MockContainerLauncher mockLauncher = mockApp.getContainerLauncher();
    mockLauncher.startScheduling(false);
    mockApp.statsDelegate = new StatisticsDelegate() {

        @Override
        public TaskStatistics getStatistics(TaskSpec taskSpec) {
            byte[] payload = payloadA;
            TaskStatistics stats = new TaskStatistics();
            final DataInputByteBuffer in = new DataInputByteBuffer();
            in.reset(ByteBuffer.wrap(payload));
            try {
                // this ensures that the serde code path is covered.
                stats.readFields(in);
            } catch (IOException e) {
                Assert.fail(e.getMessage());
            }
            return stats;
        }
    };
    mockApp.doSleep = false;
    DAGClient dagClient = tezClient.submitDAG(dag);
    mockLauncher.waitTillContainersLaunched();
    DAGImpl dagImpl = (DAGImpl) mockApp.getContext().getCurrentDAG();
    mockLauncher.startScheduling(true);
    DAGStatus status = dagClient.waitForCompletion();
    Assert.assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
    Assert.assertEquals(numTasks, dagImpl.getVertex(vAName).getStatistics().getInputStatistics(0 + vAName).getDataSize());
    Assert.assertEquals(numTasks, dagImpl.getVertex(vAName).getStatistics().getInputStatistics(0 + vAName).getItemsProcessed());
    checkMemory(dag.getName(), mockApp);
    tezClient.stop();
}
Also used : IOStatistics(org.apache.tez.runtime.api.impl.IOStatistics) Vertex(org.apache.tez.dag.api.Vertex) DataOutput(java.io.DataOutput) StatisticsDelegate(org.apache.tez.dag.app.MockDAGAppMaster.StatisticsDelegate) DataOutputStream(java.io.DataOutputStream) DataInputByteBuffer(org.apache.hadoop.io.DataInputByteBuffer) TaskSpec(org.apache.tez.runtime.api.impl.TaskSpec) DAG(org.apache.tez.dag.api.DAG) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) MockContainerLauncher(org.apache.tez.dag.app.MockDAGAppMaster.MockContainerLauncher) DAGImpl(org.apache.tez.dag.app.dag.impl.DAGImpl) TaskStatistics(org.apache.tez.runtime.api.impl.TaskStatistics) DAGClient(org.apache.tez.dag.api.client.DAGClient) DAGStatus(org.apache.tez.dag.api.client.DAGStatus) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with MockContainerLauncher

use of org.apache.tez.dag.app.MockDAGAppMaster.MockContainerLauncher in project tez by apache.

the class TestMemoryWithEvents method testMemory.

private void testMemory(DAG dag, boolean sendDMEvents) throws Exception {
    StopWatch stopwatch = new StopWatch();
    stopwatch.start();
    TezConfiguration tezconf = new TezConfiguration(defaultConf);
    MockTezClient tezClient = new MockTezClient("testMockAM", tezconf, true, null, null, null, null, false, false, numThreads, 1000);
    tezClient.start();
    MockDAGAppMaster mockApp = tezClient.getLocalClient().getMockApp();
    MockContainerLauncher mockLauncher = mockApp.getContainerLauncher();
    mockLauncher.startScheduling(false);
    mockApp.eventsDelegate = new TestMockDAGAppMaster.TestEventsDelegate();
    mockApp.doSleep = false;
    DAGClient dagClient = tezClient.submitDAG(dag);
    mockLauncher.waitTillContainersLaunched();
    mockLauncher.startScheduling(true);
    DAGStatus status = dagClient.waitForCompletion();
    Assert.assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
    checkMemory(dag.getName(), mockApp);
    stopwatch.stop();
    System.out.println("Time taken(ms): " + stopwatch.now(TimeUnit.MILLISECONDS));
    tezClient.stop();
}
Also used : DAGClient(org.apache.tez.dag.api.client.DAGClient) DAGStatus(org.apache.tez.dag.api.client.DAGStatus) MockContainerLauncher(org.apache.tez.dag.app.MockDAGAppMaster.MockContainerLauncher) StopWatch(org.apache.tez.util.StopWatch) TezConfiguration(org.apache.tez.dag.api.TezConfiguration)

Example 9 with MockContainerLauncher

use of org.apache.tez.dag.app.MockDAGAppMaster.MockContainerLauncher in project tez by apache.

the class TestMockDAGAppMaster method testBasicStatistics.

@Test(timeout = 10000)
public void testBasicStatistics() throws Exception {
    TezConfiguration tezconf = new TezConfiguration(defaultConf);
    MockTezClient tezClient = new MockTezClient("testMockAM", tezconf, true, null, null, null, null, false, false);
    tezClient.start();
    final String vAName = "A";
    final String vBName = "B";
    final String sourceName = "In";
    final String sinkName = "Out";
    DAG dag = DAG.create("testBasisStatistics");
    Vertex vA = Vertex.create(vAName, ProcessorDescriptor.create("Proc.class"), 3);
    Vertex vB = Vertex.create(vBName, ProcessorDescriptor.create("Proc.class"), 2);
    vA.addDataSource(sourceName, DataSourceDescriptor.create(InputDescriptor.create("In"), null, null));
    vB.addDataSink(sinkName, DataSinkDescriptor.create(OutputDescriptor.create("Out"), null, null));
    dag.addVertex(vA).addVertex(vB).addEdge(Edge.create(vA, vB, EdgeProperty.create(DataMovementType.SCATTER_GATHER, DataSourceType.PERSISTED, SchedulingType.SEQUENTIAL, OutputDescriptor.create("Out"), InputDescriptor.create("In"))));
    IOStatistics ioStats = new IOStatistics();
    ioStats.setDataSize(1);
    ioStats.setItemsProcessed(1);
    TaskStatistics vAStats = new TaskStatistics();
    vAStats.addIO(vBName, ioStats);
    vAStats.addIO(sourceName, ioStats);
    TaskStatistics vBStats = new TaskStatistics();
    vBStats.addIO(vAName, ioStats);
    vBStats.addIO(sinkName, ioStats);
    ByteArrayOutputStream bosA = new ByteArrayOutputStream();
    DataOutput outA = new DataOutputStream(bosA);
    vAStats.write(outA);
    final byte[] payloadA = bosA.toByteArray();
    ByteArrayOutputStream bosB = new ByteArrayOutputStream();
    DataOutput outB = new DataOutputStream(bosB);
    vBStats.write(outB);
    final byte[] payloadB = bosB.toByteArray();
    MockDAGAppMaster mockApp = tezClient.getLocalClient().getMockApp();
    MockContainerLauncher mockLauncher = mockApp.getContainerLauncher();
    mockLauncher.startScheduling(false);
    mockApp.statsDelegate = new StatisticsDelegate() {

        @Override
        public TaskStatistics getStatistics(TaskSpec taskSpec) {
            byte[] payload = payloadA;
            TaskStatistics stats = new TaskStatistics();
            if (taskSpec.getVertexName().equals(vBName)) {
                payload = payloadB;
            }
            final DataInputByteBuffer in = new DataInputByteBuffer();
            in.reset(ByteBuffer.wrap(payload));
            try {
                // this ensures that the serde code path is covered.
                stats.readFields(in);
            } catch (IOException e) {
                Assert.fail(e.getMessage());
            }
            return stats;
        }
    };
    mockApp.doSleep = false;
    DAGClient dagClient = tezClient.submitDAG(dag);
    mockLauncher.waitTillContainersLaunched();
    DAGImpl dagImpl = (DAGImpl) mockApp.getContext().getCurrentDAG();
    mockLauncher.startScheduling(true);
    DAGStatus status = dagClient.waitForCompletion();
    Assert.assertEquals(DAGStatus.State.SUCCEEDED, status.getState());
    // verify that the values have been correct aggregated
    for (org.apache.tez.dag.app.dag.Vertex v : dagImpl.getVertices().values()) {
        VertexStatistics vStats = v.getStatistics();
        if (v.getName().equals(vAName)) {
            Assert.assertEquals(3, vStats.getOutputStatistics(vBName).getDataSize());
            Assert.assertEquals(3, vStats.getInputStatistics(sourceName).getDataSize());
            Assert.assertEquals(3, vStats.getOutputStatistics(vBName).getItemsProcessed());
            Assert.assertEquals(3, vStats.getInputStatistics(sourceName).getItemsProcessed());
        } else {
            Assert.assertEquals(2, vStats.getInputStatistics(vAName).getDataSize());
            Assert.assertEquals(2, vStats.getOutputStatistics(sinkName).getDataSize());
            Assert.assertEquals(2, vStats.getInputStatistics(vAName).getItemsProcessed());
            Assert.assertEquals(2, vStats.getOutputStatistics(sinkName).getItemsProcessed());
        }
    }
    tezClient.stop();
}
Also used : IOStatistics(org.apache.tez.runtime.api.impl.IOStatistics) Vertex(org.apache.tez.dag.api.Vertex) DataOutput(java.io.DataOutput) StatisticsDelegate(org.apache.tez.dag.app.MockDAGAppMaster.StatisticsDelegate) DataOutputStream(java.io.DataOutputStream) DataInputByteBuffer(org.apache.hadoop.io.DataInputByteBuffer) MockContainerLauncher(org.apache.tez.dag.app.MockDAGAppMaster.MockContainerLauncher) TaskStatistics(org.apache.tez.runtime.api.impl.TaskStatistics) DAGStatus(org.apache.tez.dag.api.client.DAGStatus) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) TaskSpec(org.apache.tez.runtime.api.impl.TaskSpec) DAG(org.apache.tez.dag.api.DAG) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) VertexStatistics(org.apache.tez.runtime.api.VertexStatistics) DAGImpl(org.apache.tez.dag.app.dag.impl.DAGImpl) DAGClient(org.apache.tez.dag.api.client.DAGClient) Test(org.junit.Test)

Example 10 with MockContainerLauncher

use of org.apache.tez.dag.app.MockDAGAppMaster.MockContainerLauncher in project tez by apache.

the class TestMockDAGAppMaster method testLocalResourceSetup.

@Test(timeout = 5000)
public void testLocalResourceSetup() throws Exception {
    TezConfiguration tezconf = new TezConfiguration(defaultConf);
    MockTezClient tezClient = new MockTezClient("testMockAM", tezconf, true, null, null, null, null);
    tezClient.start();
    MockDAGAppMaster mockApp = tezClient.getLocalClient().getMockApp();
    MockContainerLauncher mockLauncher = mockApp.getContainerLauncher();
    mockLauncher.startScheduling(false);
    Map<String, LocalResource> lrDAG = Maps.newHashMap();
    String lrName1 = "LR1";
    lrDAG.put(lrName1, LocalResource.newInstance(URL.newInstance("file", "localhost", 0, "/test"), LocalResourceType.FILE, LocalResourceVisibility.PUBLIC, 1, 1));
    Map<String, LocalResource> lrVertex = Maps.newHashMap();
    String lrName2 = "LR2";
    lrVertex.put(lrName2, LocalResource.newInstance(URL.newInstance("file", "localhost", 0, "/test1"), LocalResourceType.FILE, LocalResourceVisibility.PUBLIC, 1, 1));
    DAG dag = DAG.create("testLocalResourceSetup").addTaskLocalFiles(lrDAG);
    Vertex vA = Vertex.create("A", ProcessorDescriptor.create("Proc.class"), 5).addTaskLocalFiles(lrVertex);
    dag.addVertex(vA);
    DAGClient dagClient = tezClient.submitDAG(dag);
    mockLauncher.waitTillContainersLaunched();
    ContainerData cData = mockLauncher.getContainers().values().iterator().next();
    ContainerLaunchContext launchContext = cData.launchContext;
    Map<String, LocalResource> taskLR = launchContext.getLocalResources();
    // verify tasks are launched with both DAG and task resources.
    Assert.assertTrue(taskLR.containsKey(lrName1));
    Assert.assertTrue(taskLR.containsKey(lrName2));
    mockLauncher.startScheduling(true);
    dagClient.waitForCompletion();
    Assert.assertEquals(DAGStatus.State.SUCCEEDED, dagClient.getDAGStatus(null).getState());
    tezClient.stop();
}
Also used : Vertex(org.apache.tez.dag.api.Vertex) DAGClient(org.apache.tez.dag.api.client.DAGClient) DAG(org.apache.tez.dag.api.DAG) ContainerLaunchContext(org.apache.hadoop.yarn.api.records.ContainerLaunchContext) MockContainerLauncher(org.apache.tez.dag.app.MockDAGAppMaster.MockContainerLauncher) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource) ContainerData(org.apache.tez.dag.app.MockDAGAppMaster.MockContainerLauncher.ContainerData) Test(org.junit.Test)

Aggregations

TezConfiguration (org.apache.tez.dag.api.TezConfiguration)12 MockContainerLauncher (org.apache.tez.dag.app.MockDAGAppMaster.MockContainerLauncher)12 DAG (org.apache.tez.dag.api.DAG)11 Vertex (org.apache.tez.dag.api.Vertex)11 DAGClient (org.apache.tez.dag.api.client.DAGClient)11 Test (org.junit.Test)11 DAGImpl (org.apache.tez.dag.app.dag.impl.DAGImpl)7 DAGStatus (org.apache.tez.dag.api.client.DAGStatus)5 TaskSpec (org.apache.tez.runtime.api.impl.TaskSpec)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 DataOutput (java.io.DataOutput)3 DataOutputStream (java.io.DataOutputStream)3 IOException (java.io.IOException)3 DataInputByteBuffer (org.apache.hadoop.io.DataInputByteBuffer)3 VertexImpl (org.apache.tez.dag.app.dag.impl.VertexImpl)3 TezTaskAttemptID (org.apache.tez.dag.records.TezTaskAttemptID)3 TezCounters (org.apache.tez.common.counters.TezCounters)2 CountersDelegate (org.apache.tez.dag.app.MockDAGAppMaster.CountersDelegate)2 ContainerData (org.apache.tez.dag.app.MockDAGAppMaster.MockContainerLauncher.ContainerData)2 StatisticsDelegate (org.apache.tez.dag.app.MockDAGAppMaster.StatisticsDelegate)2