Search in sources :

Example 6 with TaskSpec

use of org.apache.tez.runtime.api.impl.TaskSpec in project hive by apache.

the class TestLlapTaskCommunicator method testFinishableStateUpdateFailure.

@Test(timeout = 5000)
public void testFinishableStateUpdateFailure() throws Exception {
    LlapTaskCommunicatorWrapperForTest wrapper = null;
    Lock lock = new ReentrantLock();
    Condition condition = lock.newCondition();
    final AtomicBoolean opDone = new AtomicBoolean(false);
    LlapProtocolClientProxy proxy = mock(LlapProtocolClientProxy.class, new FinishableStatusUpdateTestAnswer(lock, condition, opDone));
    try {
        wrapper = new LlapTaskCommunicatorWrapperForTest(proxy);
        // Register tasks on 2 nodes, with a dependency on vertex1 completing.
        ContainerId cId11 = wrapper.registerContainer(1, 0);
        TaskSpec ts11 = wrapper.registerRunningTaskAttemptWithSourceVertex(cId11, 1);
        ContainerId cId12 = wrapper.registerContainer(2, 0);
        TaskSpec ts12 = wrapper.registerRunningTaskAttemptWithSourceVertex(cId12, 2);
        ContainerId cId21 = wrapper.registerContainer(3, 1);
        TaskSpec ts21 = wrapper.registerRunningTaskAttemptWithSourceVertex(cId21, 3);
        // Send a state update for vertex1 completion. This triggers a status update to be sent out.
        VertexStateUpdate vertexStateUpdate = new VertexStateUpdate(LlapTaskCommunicatorWrapperForTest.VERTEX_NAME1, VertexState.SUCCEEDED);
        wrapper.getTaskCommunicator().onVertexStateUpdated(vertexStateUpdate);
        // Wait for all invocations to complete.
        lock.lock();
        try {
            while (!opDone.get()) {
                condition.await();
            }
        } finally {
            lock.unlock();
        }
        // Verify that a task kill went out for all nodes running on the specified host.
        verify(wrapper.getTaskCommunicatorContext(), times(2)).taskKilled(any(TezTaskAttemptID.class), any(TaskAttemptEndReason.class), any(String.class));
        verify(wrapper.getTaskCommunicatorContext()).taskKilled(eq(ts11.getTaskAttemptID()), eq(TaskAttemptEndReason.NODE_FAILED), any(String.class));
        verify(wrapper.getTaskCommunicatorContext()).taskKilled(eq(ts12.getTaskAttemptID()), eq(TaskAttemptEndReason.NODE_FAILED), any(String.class));
        wrapper.getTaskCommunicator().sendStateUpdate(LlapNodeId.getInstance(LlapTaskCommunicatorWrapperForTest.HOSTS[1], LlapTaskCommunicatorWrapperForTest.RPC_PORT), LlapDaemonProtocolProtos.SourceStateUpdatedRequestProto.getDefaultInstance());
        // Verify no more invocations in case of success.
        verify(wrapper.getTaskCommunicatorContext(), times(2)).taskKilled(any(TezTaskAttemptID.class), any(TaskAttemptEndReason.class), any(String.class));
    } finally {
        if (wrapper != null) {
            wrapper.shutdown();
        }
    }
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) Condition(java.util.concurrent.locks.Condition) TaskSpec(org.apache.tez.runtime.api.impl.TaskSpec) TaskAttemptEndReason(org.apache.tez.serviceplugins.api.TaskAttemptEndReason) ReentrantLock(java.util.concurrent.locks.ReentrantLock) Lock(java.util.concurrent.locks.Lock) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) VertexStateUpdate(org.apache.tez.dag.api.event.VertexStateUpdate) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) LlapProtocolClientProxy(org.apache.hadoop.hive.llap.tez.LlapProtocolClientProxy) TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID) Test(org.junit.Test)

Aggregations

TaskSpec (org.apache.tez.runtime.api.impl.TaskSpec)6 TezTaskAttemptID (org.apache.tez.dag.records.TezTaskAttemptID)5 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)3 TezDAGID (org.apache.tez.dag.records.TezDAGID)3 TezTaskID (org.apache.tez.dag.records.TezTaskID)3 TezVertexID (org.apache.tez.dag.records.TezVertexID)3 InputSpec (org.apache.tez.runtime.api.impl.InputSpec)3 OutputSpec (org.apache.tez.runtime.api.impl.OutputSpec)3 Test (org.junit.Test)3 ByteBuffer (java.nio.ByteBuffer)2 ArrayList (java.util.ArrayList)2 QueryIdentifierProto (org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos.QueryIdentifierProto)2 SignableVertexSpec (org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos.SignableVertexSpec)2 ProcessorDescriptor (org.apache.tez.dag.api.ProcessorDescriptor)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Condition (java.util.concurrent.locks.Condition)1 Lock (java.util.concurrent.locks.Lock)1