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();
}
}
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();
}
}
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();
}
}
Aggregations