Search in sources :

Example 61 with TezCounters

use of org.apache.tez.common.counters.TezCounters in project tez by apache.

the class TestTaskReporter method testStatusUpdateAfterInitializationAndCounterFlag.

@Test(timeout = 5000)
public void testStatusUpdateAfterInitializationAndCounterFlag() {
    TezTaskAttemptID mockTaskAttemptId = mock(TezTaskAttemptID.class);
    LogicalIOProcessorRuntimeTask mockTask = mock(LogicalIOProcessorRuntimeTask.class);
    doReturn("vertexName").when(mockTask).getVertexName();
    doReturn(mockTaskAttemptId).when(mockTask).getTaskAttemptID();
    boolean progressNotified = false;
    doReturn(progressNotified).when(mockTask).getAndClearProgressNotification();
    TezTaskUmbilicalProtocol mockUmbilical = mock(TezTaskUmbilicalProtocol.class);
    float progress = 0.5f;
    TaskStatistics stats = new TaskStatistics();
    TezCounters counters = new TezCounters();
    doReturn(progress).when(mockTask).getProgress();
    doReturn(stats).when(mockTask).getTaskStatistics();
    doReturn(counters).when(mockTask).getCounters();
    // Setup the sleep time to be way higher than the test timeout
    TaskReporter.HeartbeatCallable heartbeatCallable = new TaskReporter.HeartbeatCallable(mockTask, mockUmbilical, 100000, 100000, 5, new AtomicLong(0), "containerIdStr");
    // task not initialized - nothing obtained from task
    doReturn(false).when(mockTask).hasInitialized();
    TaskStatusUpdateEvent event = heartbeatCallable.getStatusUpdateEvent(true);
    verify(mockTask, times(1)).hasInitialized();
    verify(mockTask, times(0)).getProgress();
    verify(mockTask, times(0)).getAndClearProgressNotification();
    verify(mockTask, times(0)).getTaskStatistics();
    verify(mockTask, times(0)).getCounters();
    Assert.assertEquals(0, event.getProgress(), 0);
    Assert.assertEquals(false, event.getProgressNotified());
    Assert.assertNull(event.getCounters());
    Assert.assertNull(event.getStatistics());
    // task is initialized - progress obtained but not counters since flag is false
    doReturn(true).when(mockTask).hasInitialized();
    event = heartbeatCallable.getStatusUpdateEvent(false);
    verify(mockTask, times(2)).hasInitialized();
    verify(mockTask, times(1)).getProgress();
    verify(mockTask, times(1)).getAndClearProgressNotification();
    verify(mockTask, times(0)).getTaskStatistics();
    verify(mockTask, times(0)).getCounters();
    Assert.assertEquals(progress, event.getProgress(), 0);
    Assert.assertEquals(progressNotified, event.getProgressNotified());
    Assert.assertNull(event.getCounters());
    Assert.assertNull(event.getStatistics());
    // task is initialized - progress obtained and also counters since flag is true
    progressNotified = true;
    doReturn(progressNotified).when(mockTask).getAndClearProgressNotification();
    doReturn(true).when(mockTask).hasInitialized();
    event = heartbeatCallable.getStatusUpdateEvent(true);
    verify(mockTask, times(3)).hasInitialized();
    verify(mockTask, times(2)).getProgress();
    verify(mockTask, times(2)).getAndClearProgressNotification();
    verify(mockTask, times(1)).getTaskStatistics();
    verify(mockTask, times(1)).getCounters();
    Assert.assertEquals(progress, event.getProgress(), 0);
    Assert.assertEquals(progressNotified, event.getProgressNotified());
    Assert.assertEquals(counters, event.getCounters());
    Assert.assertEquals(stats, event.getStatistics());
}
Also used : LogicalIOProcessorRuntimeTask(org.apache.tez.runtime.LogicalIOProcessorRuntimeTask) AtomicLong(java.util.concurrent.atomic.AtomicLong) TezTaskUmbilicalProtocol(org.apache.tez.common.TezTaskUmbilicalProtocol) TaskStatistics(org.apache.tez.runtime.api.impl.TaskStatistics) TaskStatusUpdateEvent(org.apache.tez.runtime.api.events.TaskStatusUpdateEvent) TezCounters(org.apache.tez.common.counters.TezCounters) TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID) Test(org.junit.Test)

Example 62 with TezCounters

use of org.apache.tez.common.counters.TezCounters in project tez by apache.

the class RuntimeTask method getCounters.

public TezCounters getCounters() {
    TezCounters fullCounters = new TezCounters();
    fullCounters.incrAllCounters(tezCounters);
    for (TezCounters counter : counterMap.values()) {
        fullCounters.incrAllCounters(counter);
    }
    return fullCounters;
}
Also used : TezCounters(org.apache.tez.common.counters.TezCounters)

Example 63 with TezCounters

use of org.apache.tez.common.counters.TezCounters in project tez by apache.

the class RuntimeTask method addAndGetTezCounter.

public TezCounters addAndGetTezCounter(String name) {
    TezCounters counter = new TezCounters();
    counterMap.put(name, counter);
    return counter;
}
Also used : TezCounters(org.apache.tez.common.counters.TezCounters)

Example 64 with TezCounters

use of org.apache.tez.common.counters.TezCounters in project tez by apache.

the class TaskImpl method getCounters.

@Override
public TezCounters getCounters() {
    TezCounters counters = new TezCounters();
    counters.incrAllCounters(this.counters);
    readLock.lock();
    try {
        TaskAttempt bestAttempt = selectBestAttempt();
        if (bestAttempt != null) {
            counters.incrAllCounters(bestAttempt.getCounters());
        }
        return counters;
    } finally {
        readLock.unlock();
    }
}
Also used : TaskAttempt(org.apache.tez.dag.app.dag.TaskAttempt) TezCounters(org.apache.tez.common.counters.TezCounters)

Example 65 with TezCounters

use of org.apache.tez.common.counters.TezCounters in project tez by apache.

the class VertexImpl method logJobHistoryVertexFailedEvent.

void logJobHistoryVertexFailedEvent(VertexState state) throws IOException {
    if (recoveryData == null || !recoveryData.isVertexFinished()) {
        TezCounters counters = null;
        try {
            counters = getAllCounters();
        } catch (LimitExceededException e) {
            // Ignore as failed vertex
            addDiagnostic("Counters limit exceeded: " + e.getMessage());
        }
        logJobHistoryVertexCompletedHelper(state, clock.getTime(), StringUtils.join(getDiagnostics(), LINE_SEPARATOR), counters);
    }
}
Also used : LimitExceededException(org.apache.tez.common.counters.LimitExceededException) TezCounters(org.apache.tez.common.counters.TezCounters)

Aggregations

TezCounters (org.apache.tez.common.counters.TezCounters)100 Test (org.junit.Test)33 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)22 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)20 InputContext (org.apache.tez.runtime.api.InputContext)20 TezCounter (org.apache.tez.common.counters.TezCounter)18 Configuration (org.apache.hadoop.conf.Configuration)17 InvocationOnMock (org.mockito.invocation.InvocationOnMock)14 OutputContext (org.apache.tez.runtime.api.OutputContext)13 TezRuntimeConfiguration (org.apache.tez.runtime.library.api.TezRuntimeConfiguration)12 IOException (java.io.IOException)10 Path (org.apache.hadoop.fs.Path)10 DAG (org.apache.tez.dag.api.DAG)10 HashMap (java.util.HashMap)9 CounterGroup (org.apache.tez.common.counters.CounterGroup)9 StatusGetOpts (org.apache.tez.dag.api.client.StatusGetOpts)8 ByteString (com.google.protobuf.ByteString)7 Map (java.util.Map)7 Set (java.util.Set)7 LimitExceededException (org.apache.tez.common.counters.LimitExceededException)7