Search in sources :

Example 1 with TezCounters

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

the class VertexImpl method getAllCounters.

@Override
public TezCounters getAllCounters() {
    readLock.lock();
    try {
        if (inTerminalState()) {
            this.mayBeConstructFinalFullCounters();
            return fullCounters;
        }
        TezCounters counters = new TezCounters();
        counters.incrAllCounters(this.counters);
        return incrTaskCounters(counters, tasks.values());
    } finally {
        readLock.unlock();
    }
}
Also used : TezCounters(org.apache.tez.common.counters.TezCounters)

Example 2 with TezCounters

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

the class TaskAttemptImpl method getCounters.

@Override
public TezCounters getCounters() {
    readLock.lock();
    try {
        reportedStatus.setLocalityCounter(this.localityCounter);
        TezCounters counters = reportedStatus.counters;
        if (counters == null) {
            counters = EMPTY_COUNTERS;
        }
        return counters;
    } finally {
        readLock.unlock();
    }
}
Also used : TezCounters(org.apache.tez.common.counters.TezCounters)

Example 3 with TezCounters

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

the class DAGImpl method getAllCounters.

@Override
public TezCounters getAllCounters() {
    readLock.lock();
    try {
        DAGState state = getInternalState();
        if (state == DAGState.ERROR || state == DAGState.FAILED || state == DAGState.KILLED || state == DAGState.SUCCEEDED) {
            this.mayBeConstructFinalFullCounters();
            return fullCounters;
        }
        // dag not yet finished. update cpu time counters
        updateCpuCounters();
        TezCounters counters = new TezCounters();
        counters.incrAllCounters(dagCounters);
        return incrTaskCounters(counters, vertices.values());
    } finally {
        readLock.unlock();
    }
}
Also used : DAGState(org.apache.tez.dag.app.dag.DAGState) TezCounters(org.apache.tez.common.counters.TezCounters)

Example 4 with TezCounters

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

the class DAGImpl method finished.

private DAGState finished(DAGState finalState) {
    if (finishTime == 0) {
        setFinishTime();
    }
    entityUpdateTracker.stop();
    boolean recoveryError = false;
    // update cpu time counters before finishing the dag
    updateCpuCounters();
    TezCounters counters = null;
    try {
        counters = getAllCounters();
    } catch (LimitExceededException e) {
        addDiagnostic("Counters limit exceeded: " + e.getMessage());
        finalState = DAGState.FAILED;
    }
    try {
        if (finalState == DAGState.SUCCEEDED) {
            logJobHistoryFinishedEvent(counters);
        } else {
            logJobHistoryUnsuccesfulEvent(finalState, counters);
        }
    } catch (IOException e) {
        LOG.warn("Failed to persist recovery event for DAG completion" + ", dagId=" + dagId + ", finalState=" + finalState);
        recoveryError = true;
    }
    if (finalState != DAGState.SUCCEEDED) {
        abortOutputs();
    }
    if (recoveryError) {
        eventHandler.handle(new DAGAppMasterEventDAGFinished(getID(), DAGState.ERROR));
    } else {
        eventHandler.handle(new DAGAppMasterEventDAGFinished(getID(), finalState));
    }
    LOG.info("DAG: " + getID() + " finished with state: " + finalState);
    return finalState;
}
Also used : DAGAppMasterEventDAGFinished(org.apache.tez.dag.app.dag.event.DAGAppMasterEventDAGFinished) LimitExceededException(org.apache.tez.common.counters.LimitExceededException) IOException(java.io.IOException) TezCounters(org.apache.tez.common.counters.TezCounters)

Example 5 with TezCounters

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

the class DAGImpl method getCachedCounters.

@Override
public TezCounters getCachedCounters() {
    readLock.lock();
    try {
        // FIXME a better lightweight approach for counters is needed
        if (fullCounters == null && cachedCounters != null && ((cachedCountersTimestamp + 10000) > System.currentTimeMillis())) {
            LOG.info("Asked for counters" + ", cachedCountersTimestamp=" + cachedCountersTimestamp + ", currentTime=" + System.currentTimeMillis());
            return cachedCounters;
        }
        cachedCountersTimestamp = System.currentTimeMillis();
        if (inTerminalState()) {
            this.mayBeConstructFinalFullCounters();
            return fullCounters;
        }
        // dag not yet finished. update cpu time counters
        updateCpuCounters();
        TezCounters counters = new TezCounters();
        counters.incrAllCounters(dagCounters);
        return incrTaskCounters(counters, vertices.values());
    } finally {
        readLock.unlock();
    }
}
Also used : 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