Search in sources :

Example 1 with DAGState

use of org.apache.tez.dag.app.dag.DAGState 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 2 with DAGState

use of org.apache.tez.dag.app.dag.DAGState in project tez by apache.

the class DAGImpl method handle.

@Override
public /**
 * The only entry point to change the DAG.
 */
void handle(DAGEvent event) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Processing DAGEvent " + event.getDAGId() + " of type " + event.getType() + " while in state " + getInternalState() + ". Event: " + event);
    }
    try {
        writeLock.lock();
        DAGState oldState = getInternalState();
        try {
            getStateMachine().doTransition(event.getType(), event);
        } catch (InvalidStateTransitonException e) {
            String message = "Invalid event " + event.getType() + " on Dag " + this.dagId + " at currentState=" + oldState;
            LOG.error("Can't handle " + message, e);
            addDiagnostic(message);
            eventHandler.handle(new DAGEvent(this.dagId, DAGEventType.INTERNAL_ERROR));
        } catch (RuntimeException e) {
            String message = "Uncaught Exception when handling event " + event.getType() + " on Dag " + this.dagId + " at currentState=" + oldState;
            LOG.error(message, e);
            addDiagnostic(message);
            if (!internalErrorTriggered.getAndSet(true)) {
                // to prevent a recursive loop
                eventHandler.handle(new DAGEvent(this.dagId, DAGEventType.INTERNAL_ERROR));
            }
        }
        // notify the eventhandler of state change
        if (oldState != getInternalState()) {
            LOG.info(dagId + " transitioned from " + oldState + " to " + getInternalState() + " due to event " + event.getType());
        }
    } finally {
        writeLock.unlock();
    }
}
Also used : DAGEvent(org.apache.tez.dag.app.dag.event.DAGEvent) DAGState(org.apache.tez.dag.app.dag.DAGState) InvalidStateTransitonException(org.apache.hadoop.yarn.state.InvalidStateTransitonException)

Example 3 with DAGState

use of org.apache.tez.dag.app.dag.DAGState in project tez by apache.

the class DAGImpl method getCompletedTaskProgress.

@Override
public float getCompletedTaskProgress() {
    this.readLock.lock();
    try {
        int totalTasks = 0;
        int completedTasks = 0;
        for (Vertex v : getVertices().values()) {
            int vTotalTasks = v.getTotalTasks();
            int vCompletedTasks = v.getSucceededTasks();
            if (vTotalTasks > 0) {
                totalTasks += vTotalTasks;
                completedTasks += vCompletedTasks;
            }
        }
        if (totalTasks == 0) {
            DAGState state = getStateMachine().getCurrentState();
            if (state == DAGState.ERROR || state == DAGState.FAILED || state == DAGState.KILLED || state == DAGState.SUCCEEDED) {
                return 1.0f;
            } else {
                return 0.0f;
            }
        }
        return ((float) completedTasks / totalTasks);
    } finally {
        this.readLock.unlock();
    }
}
Also used : VertexEventRecoverVertex(org.apache.tez.dag.app.dag.event.VertexEventRecoverVertex) Vertex(org.apache.tez.dag.app.dag.Vertex) DAGState(org.apache.tez.dag.app.dag.DAGState) VertexLocationHint(org.apache.tez.dag.api.VertexLocationHint)

Aggregations

DAGState (org.apache.tez.dag.app.dag.DAGState)3 InvalidStateTransitonException (org.apache.hadoop.yarn.state.InvalidStateTransitonException)1 TezCounters (org.apache.tez.common.counters.TezCounters)1 VertexLocationHint (org.apache.tez.dag.api.VertexLocationHint)1 Vertex (org.apache.tez.dag.app.dag.Vertex)1 DAGEvent (org.apache.tez.dag.app.dag.event.DAGEvent)1 VertexEventRecoverVertex (org.apache.tez.dag.app.dag.event.VertexEventRecoverVertex)1