Search in sources :

Example 1 with LlapProtocolClientProxy

use of org.apache.hadoop.hive.llap.tez.LlapProtocolClientProxy 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

AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Condition (java.util.concurrent.locks.Condition)1 Lock (java.util.concurrent.locks.Lock)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 LlapProtocolClientProxy (org.apache.hadoop.hive.llap.tez.LlapProtocolClientProxy)1 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)1 VertexStateUpdate (org.apache.tez.dag.api.event.VertexStateUpdate)1 TezTaskAttemptID (org.apache.tez.dag.records.TezTaskAttemptID)1 TaskSpec (org.apache.tez.runtime.api.impl.TaskSpec)1 TaskAttemptEndReason (org.apache.tez.serviceplugins.api.TaskAttemptEndReason)1 Test (org.junit.Test)1