Search in sources :

Example 51 with TezClient

use of org.apache.tez.client.TezClient in project tez by apache.

the class TestTaskErrorsUsingLocalMode method testFatalErrorReported.

@Test(timeout = 20000)
public void testFatalErrorReported() throws IOException, TezException, InterruptedException {
    TezClient tezClient = getTezClient("testFatalErrorReported");
    DAGClient dagClient = null;
    try {
        FailingProcessor.configureForFatalFail();
        DAG dag = DAG.create("testFatalErrorReportedDag").addVertex(Vertex.create(VERTEX_NAME, ProcessorDescriptor.create(FailingProcessor.class.getName()), 1));
        dagClient = tezClient.submitDAG(dag);
        dagClient.waitForCompletion();
        assertEquals(DAGStatus.State.FAILED, dagClient.getDAGStatus(null).getState());
        assertEquals(1, dagClient.getVertexStatus(VERTEX_NAME, null).getProgress().getFailedTaskAttemptCount());
    } finally {
        if (dagClient != null) {
            dagClient.close();
        }
        tezClient.stop();
    }
}
Also used : DAGClient(org.apache.tez.dag.api.client.DAGClient) DAG(org.apache.tez.dag.api.DAG) TezClient(org.apache.tez.client.TezClient) Test(org.junit.Test)

Example 52 with TezClient

use of org.apache.tez.client.TezClient in project tez by apache.

the class TestHistoryParser method runWordCount.

private String runWordCount(String tokenizerProcessor, String summationProcessor, String dagName, boolean withTimeline) throws Exception {
    // HDFS path
    Path outputLoc = new Path("/tmp/outPath_" + System.currentTimeMillis());
    DataSourceDescriptor dataSource = MRInput.createConfigBuilder(conf, TextInputFormat.class, inputLoc.toString()).build();
    DataSinkDescriptor dataSink = MROutput.createConfigBuilder(conf, TextOutputFormat.class, outputLoc.toString()).build();
    Vertex tokenizerVertex = Vertex.create(TOKENIZER, ProcessorDescriptor.create(tokenizerProcessor)).addDataSource(INPUT, dataSource);
    OrderedPartitionedKVEdgeConfig edgeConf = OrderedPartitionedKVEdgeConfig.newBuilder(Text.class.getName(), IntWritable.class.getName(), HashPartitioner.class.getName()).build();
    Vertex summationVertex = Vertex.create(SUMMATION, ProcessorDescriptor.create(summationProcessor), 1).addDataSink(OUTPUT, dataSink);
    // Create DAG and add the vertices. Connect the producer and consumer vertices via the edge
    DAG dag = DAG.create(dagName);
    dag.addVertex(tokenizerVertex).addVertex(summationVertex).addEdge(Edge.create(tokenizerVertex, summationVertex, edgeConf.createDefaultEdgeProperty()));
    TezClient tezClient = getTezClient(withTimeline);
    // Update Caller Context
    CallerContext callerContext = CallerContext.create("TezExamples", "Tez WordCount Example Job");
    ApplicationId appId = tezClient.getAppMasterApplicationId();
    if (appId == null) {
        appId = ApplicationId.newInstance(1001l, 1);
    }
    callerContext.setCallerIdAndType(appId.toString(), "TezApplication");
    dag.setCallerContext(callerContext);
    DAGClient client = tezClient.submitDAG(dag);
    client.waitForCompletionWithStatusUpdates(Sets.newHashSet(StatusGetOpts.GET_COUNTERS));
    TezDAGID tezDAGID = TezDAGID.getInstance(tezClient.getAppMasterApplicationId(), 1);
    if (tezClient != null) {
        tezClient.stop();
    }
    return tezDAGID.toString();
}
Also used : Path(org.apache.hadoop.fs.Path) OrderedPartitionedKVEdgeConfig(org.apache.tez.runtime.library.conf.OrderedPartitionedKVEdgeConfig) Vertex(org.apache.tez.dag.api.Vertex) CallerContext(org.apache.tez.client.CallerContext) DAG(org.apache.tez.dag.api.DAG) DataSinkDescriptor(org.apache.tez.dag.api.DataSinkDescriptor) TezClient(org.apache.tez.client.TezClient) TextInputFormat(org.apache.hadoop.mapreduce.lib.input.TextInputFormat) TextOutputFormat(org.apache.hadoop.mapreduce.lib.output.TextOutputFormat) TezDAGID(org.apache.tez.dag.records.TezDAGID) DAGClient(org.apache.tez.dag.api.client.DAGClient) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) DataSourceDescriptor(org.apache.tez.dag.api.DataSourceDescriptor)

Example 53 with TezClient

use of org.apache.tez.client.TezClient in project tez by apache.

the class TestHistoryParser method getTezClient.

TezClient getTezClient(boolean withTimeline) throws Exception {
    TezConfiguration tezConf = new TezConfiguration(miniTezCluster.getConfig());
    if (withTimeline) {
        tezConf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, withTimeline);
        tezConf.set(TezConfiguration.TEZ_HISTORY_LOGGING_SERVICE_CLASS, ATSHistoryLoggingService.class.getName());
    } else {
        tezConf.set(TezConfiguration.TEZ_HISTORY_LOGGING_SERVICE_CLASS, SimpleHistoryLoggingService.class.getName());
    }
    tezConf.setBoolean(TezConfiguration.TEZ_AM_ALLOW_DISABLED_TIMELINE_DOMAINS, true);
    TezClient tezClient = TezClient.create("WordCount", tezConf, false);
    tezClient.start();
    tezClient.waitTillReady();
    return tezClient;
}
Also used : ATSHistoryLoggingService(org.apache.tez.dag.history.logging.ats.ATSHistoryLoggingService) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) SimpleHistoryLoggingService(org.apache.tez.dag.history.logging.impl.SimpleHistoryLoggingService) TezClient(org.apache.tez.client.TezClient)

Example 54 with TezClient

use of org.apache.tez.client.TezClient in project hive by apache.

the class TestTezTask method testSubmitOnPoolSession.

@Test
public void testSubmitOnPoolSession() throws Exception {
    DAG dag = DAG.create("test");
    // Move session to TezSessionPool, reopen will handle it
    SampleTezSessionState tezSessionPoolSession = mock(SampleTezSessionState.class);
    TezClient tezClient = mock(TezClient.class);
    when(tezSessionPoolSession.reopen()).thenThrow(new HiveException("Dag cannot be submitted"));
    doNothing().when(tezSessionPoolSession).returnToSessionManager();
    when(tezSessionPoolSession.getSession()).thenReturn(tezClient);
    when(tezSessionPoolSession.isDefault()).thenReturn(true);
    when(tezClient.submitDAG(any(DAG.class))).thenThrow(new SessionNotRunning(""));
    boolean isException = false;
    try {
        task.submit(dag, Ref.from(tezSessionPoolSession));
    } catch (Exception e) {
        isException = true;
        verify(tezClient, times(1)).submitDAG(any(DAG.class));
        verify(tezSessionPoolSession, times(2)).reopen();
        verify(tezSessionPoolSession, times(0)).destroy();
        verify(tezSessionPoolSession, times(1)).returnToSessionManager();
    }
    assertTrue(isException);
}
Also used : HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) SessionNotRunning(org.apache.tez.dag.api.SessionNotRunning) DAG(org.apache.tez.dag.api.DAG) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) IOException(java.io.IOException) TezClient(org.apache.tez.client.TezClient) Test(org.junit.Test)

Example 55 with TezClient

use of org.apache.tez.client.TezClient in project hive by apache.

the class TestTezTask method testSubmitOnNonPoolSession.

@Test
public void testSubmitOnNonPoolSession() throws Exception {
    DAG dag = DAG.create("test");
    // Destroy session incase of non-pool tez session
    TezSessionState tezSessionState = mock(TezSessionState.class);
    TezClient tezClient = mock(TezClient.class);
    when(tezSessionState.reopen()).thenThrow(new HiveException("Dag cannot be submitted"));
    when(tezSessionState.getSession()).thenReturn(tezClient);
    when(tezClient.submitDAG(any(DAG.class))).thenThrow(new SessionNotRunning(""));
    doNothing().when(tezSessionState).destroy();
    boolean isException = false;
    try {
        task.submit(dag, Ref.from(tezSessionState));
    } catch (Exception e) {
        isException = true;
        verify(tezClient, times(1)).submitDAG(any(DAG.class));
        verify(tezSessionState, times(2)).reopen();
        verify(tezSessionState, times(1)).destroy();
        verify(tezSessionState, times(0)).returnToSessionManager();
    }
    assertTrue(isException);
}
Also used : HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) SessionNotRunning(org.apache.tez.dag.api.SessionNotRunning) DAG(org.apache.tez.dag.api.DAG) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) IOException(java.io.IOException) TezClient(org.apache.tez.client.TezClient) Test(org.junit.Test)

Aggregations

TezClient (org.apache.tez.client.TezClient)58 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)44 Test (org.junit.Test)38 Path (org.apache.hadoop.fs.Path)34 DAG (org.apache.tez.dag.api.DAG)32 DAGClient (org.apache.tez.dag.api.client.DAGClient)29 DAGStatus (org.apache.tez.dag.api.client.DAGStatus)18 Vertex (org.apache.tez.dag.api.Vertex)15 SleepProcessor (org.apache.tez.runtime.library.processor.SleepProcessor)12 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)10 SleepProcessorConfig (org.apache.tez.runtime.library.processor.SleepProcessor.SleepProcessorConfig)9 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)8 FileSystem (org.apache.hadoop.fs.FileSystem)7 IOException (java.io.IOException)6 Random (java.util.Random)6 TezException (org.apache.tez.dag.api.TezException)6 UserPayload (org.apache.tez.dag.api.UserPayload)6 YarnApplicationState (org.apache.hadoop.yarn.api.records.YarnApplicationState)5 HashMap (java.util.HashMap)4 ExecutionException (java.util.concurrent.ExecutionException)4