Search in sources :

Example 1 with InputFrameworkInterface

use of org.apache.tez.runtime.api.InputFrameworkInterface 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());
    }
}
Also used : LogicalOutputFrameworkInterface(org.apache.tez.runtime.api.LogicalOutputFrameworkInterface) Event(org.apache.tez.runtime.api.Event) TezEvent(org.apache.tez.runtime.api.impl.TezEvent) InputFrameworkInterface(org.apache.tez.runtime.api.InputFrameworkInterface) InputSpec(org.apache.tez.runtime.api.impl.InputSpec) GroupInputSpec(org.apache.tez.runtime.api.impl.GroupInputSpec) SimpleDateFormat(java.text.SimpleDateFormat) OutputSpec(org.apache.tez.runtime.api.impl.OutputSpec)

Aggregations

SimpleDateFormat (java.text.SimpleDateFormat)1 Event (org.apache.tez.runtime.api.Event)1 InputFrameworkInterface (org.apache.tez.runtime.api.InputFrameworkInterface)1 LogicalOutputFrameworkInterface (org.apache.tez.runtime.api.LogicalOutputFrameworkInterface)1 GroupInputSpec (org.apache.tez.runtime.api.impl.GroupInputSpec)1 InputSpec (org.apache.tez.runtime.api.impl.InputSpec)1 OutputSpec (org.apache.tez.runtime.api.impl.OutputSpec)1 TezEvent (org.apache.tez.runtime.api.impl.TezEvent)1