use of org.apache.tez.runtime.api.LogicalOutputFrameworkInterface in project tez by apache.
the class LogicalIOProcessorRuntimeTask method close.
public void close() throws Exception {
try {
Preconditions.checkState(this.state.get() == State.RUNNING, "Can only run while in RUNNING state. Current: " + this.state);
this.state.set(State.CLOSED);
// Close the Inputs.
for (InputSpec inputSpec : inputSpecs) {
String srcVertexName = inputSpec.getSourceVertexName();
initializedInputs.remove(srcVertexName);
List<Event> closeInputEvents = ((InputFrameworkInterface) inputsMap.get(srcVertexName)).close();
sendTaskGeneratedEvents(closeInputEvents, EventProducerConsumerType.INPUT, taskSpec.getVertexName(), srcVertexName, taskSpec.getTaskAttemptID());
}
// Close the Outputs.
for (OutputSpec outputSpec : outputSpecs) {
String destVertexName = outputSpec.getDestinationVertexName();
initializedOutputs.remove(destVertexName);
List<Event> closeOutputEvents = ((LogicalOutputFrameworkInterface) outputsMap.get(destVertexName)).close();
sendTaskGeneratedEvents(closeOutputEvents, EventProducerConsumerType.OUTPUT, taskSpec.getVertexName(), destVertexName, taskSpec.getTaskAttemptID());
}
// Close the Processor.
processorClosed = true;
processor.close();
} finally {
setTaskDone();
// Clear the interrupt status since the task execution is done.
Thread.interrupted();
if (eventRouterThread != null) {
eventRouterThread.interrupt();
LOG.info("Joining on EventRouter");
try {
eventRouterThread.join();
} catch (InterruptedException e) {
LOG.info("Ignoring interrupt while waiting for the router thread to die");
Thread.currentThread().interrupt();
}
eventRouterThread = null;
}
String timeStamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
System.err.println(timeStamp + " Completed running task attempt: " + taskSpec.getTaskAttemptID().toString());
System.out.println(timeStamp + " Completed running task attempt: " + taskSpec.getTaskAttemptID().toString());
}
}
Aggregations