Search in sources :

Example 21 with InputSpec

use of org.apache.tez.runtime.api.impl.InputSpec in project tez by apache.

the class ProtoConverters method getInputSpecFromProto.

public static InputSpec getInputSpecFromProto(IOSpecProto inputSpecProto) {
    InputDescriptor inputDescriptor = null;
    if (inputSpecProto.hasIoDescriptor()) {
        inputDescriptor = DagTypeConverters.convertInputDescriptorFromDAGPlan(inputSpecProto.getIoDescriptor());
    }
    InputSpec inputSpec = new InputSpec(inputSpecProto.getConnectedVertexName(), inputDescriptor, inputSpecProto.getPhysicalEdgeCount());
    return inputSpec;
}
Also used : InputDescriptor(org.apache.tez.dag.api.InputDescriptor) GroupInputSpec(org.apache.tez.runtime.api.impl.GroupInputSpec) InputSpec(org.apache.tez.runtime.api.impl.InputSpec)

Example 22 with InputSpec

use of org.apache.tez.runtime.api.impl.InputSpec in project tez by apache.

the class ProtoConverters method getTaskSpecfromProto.

public static TaskSpec getTaskSpecfromProto(TaskSpecProto taskSpecProto) {
    TezTaskAttemptID taskAttemptID = TezTaskAttemptID.fromString(taskSpecProto.getTaskAttemptIdString());
    ProcessorDescriptor processorDescriptor = null;
    if (taskSpecProto.hasProcessorDescriptor()) {
        processorDescriptor = DagTypeConverters.convertProcessorDescriptorFromDAGPlan(taskSpecProto.getProcessorDescriptor());
    }
    List<InputSpec> inputSpecList = new ArrayList<InputSpec>(taskSpecProto.getInputSpecsCount());
    if (taskSpecProto.getInputSpecsCount() > 0) {
        for (IOSpecProto inputSpecProto : taskSpecProto.getInputSpecsList()) {
            inputSpecList.add(getInputSpecFromProto(inputSpecProto));
        }
    }
    List<OutputSpec> outputSpecList = new ArrayList<OutputSpec>(taskSpecProto.getOutputSpecsCount());
    if (taskSpecProto.getOutputSpecsCount() > 0) {
        for (IOSpecProto outputSpecProto : taskSpecProto.getOutputSpecsList()) {
            outputSpecList.add(getOutputSpecFromProto(outputSpecProto));
        }
    }
    List<GroupInputSpec> groupInputSpecs = new ArrayList<GroupInputSpec>(taskSpecProto.getGroupedInputSpecsCount());
    if (taskSpecProto.getGroupedInputSpecsCount() > 0) {
        for (GroupInputSpecProto groupInputSpecProto : taskSpecProto.getGroupedInputSpecsList()) {
            groupInputSpecs.add(getGroupInputSpecFromProto(groupInputSpecProto));
        }
    }
    Configuration taskConf = null;
    if (taskSpecProto.hasTaskConf()) {
        taskConf = new Configuration(false);
        Map<String, String> confMap = DagTypeConverters.convertConfFromProto(taskSpecProto.getTaskConf());
        for (Entry<String, String> e : confMap.entrySet()) {
            taskConf.set(e.getKey(), e.getValue());
        }
    }
    TaskSpec taskSpec = new TaskSpec(taskAttemptID, taskSpecProto.getDagName(), taskSpecProto.getVertexName(), taskSpecProto.getVertexParallelism(), processorDescriptor, inputSpecList, outputSpecList, groupInputSpecs, taskConf);
    return taskSpec;
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) TaskSpec(org.apache.tez.runtime.api.impl.TaskSpec) ArrayList(java.util.ArrayList) ProcessorDescriptor(org.apache.tez.dag.api.ProcessorDescriptor) GroupInputSpec(org.apache.tez.runtime.api.impl.GroupInputSpec) InputSpec(org.apache.tez.runtime.api.impl.InputSpec) GroupInputSpecProto(org.apache.tez.test.service.rpc.TezTestServiceProtocolProtos.GroupInputSpecProto) IOSpecProto(org.apache.tez.test.service.rpc.TezTestServiceProtocolProtos.IOSpecProto) TezTaskAttemptID(org.apache.tez.dag.records.TezTaskAttemptID) OutputSpec(org.apache.tez.runtime.api.impl.OutputSpec) GroupInputSpec(org.apache.tez.runtime.api.impl.GroupInputSpec)

Example 23 with InputSpec

use of org.apache.tez.runtime.api.impl.InputSpec 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)

Example 24 with InputSpec

use of org.apache.tez.runtime.api.impl.InputSpec in project tez by apache.

the class TestTezTaskRunner2 method testTaskConfUsage.

@Test(timeout = 5000)
public void testTaskConfUsage() throws Exception {
    Configuration conf = new Configuration(false);
    conf.set("global", "global1");
    conf.set("global_override", "global1");
    String[] localDirs = null;
    Configuration taskConf = new Configuration(false);
    conf.set("global_override", "task1");
    conf.set("task", "task1");
    List<InputSpec> inputSpecList = new ArrayList<>();
    List<OutputSpec> outputSpecList = new ArrayList<>();
    TaskSpec taskSpec = new TaskSpec("dagName", "vertexName", 1, mock(ProcessorDescriptor.class), inputSpecList, outputSpecList, null, taskConf);
    TezExecutors sharedExecutor = new TezSharedExecutor(conf);
    TezTaskRunner2 taskRunner2 = new TezTaskRunner2(conf, mock(UserGroupInformation.class), localDirs, taskSpec, 1, null, null, null, mock(TaskReporter.class), null, null, "pid", null, 1000, false, new DefaultHadoopShim(), sharedExecutor);
    Assert.assertEquals("global1", taskRunner2.task.getTaskConf().get("global"));
    Assert.assertEquals("task1", taskRunner2.task.getTaskConf().get("global_override"));
    Assert.assertEquals("task1", taskRunner2.task.getTaskConf().get("task"));
    sharedExecutor.shutdownNow();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) TaskSpec(org.apache.tez.runtime.api.impl.TaskSpec) ArrayList(java.util.ArrayList) ProcessorDescriptor(org.apache.tez.dag.api.ProcessorDescriptor) InputSpec(org.apache.tez.runtime.api.impl.InputSpec) DefaultHadoopShim(org.apache.tez.hadoop.shim.DefaultHadoopShim) TezExecutors(org.apache.tez.common.TezExecutors) TezSharedExecutor(org.apache.tez.common.TezSharedExecutor) OutputSpec(org.apache.tez.runtime.api.impl.OutputSpec) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Test(org.junit.Test)

Example 25 with InputSpec

use of org.apache.tez.runtime.api.impl.InputSpec in project tez by apache.

the class TestLogicalIOProcessorRuntimeTask method createInputSpecList.

private List<InputSpec> createInputSpecList() {
    InputDescriptor inputDesc = InputDescriptor.create(TestInput.class.getName());
    InputSpec inputSpec = new InputSpec("inedge", inputDesc, 1);
    return Lists.newArrayList(inputSpec);
}
Also used : InputDescriptor(org.apache.tez.dag.api.InputDescriptor) InputSpec(org.apache.tez.runtime.api.impl.InputSpec)

Aggregations

InputSpec (org.apache.tez.runtime.api.impl.InputSpec)27 OutputSpec (org.apache.tez.runtime.api.impl.OutputSpec)18 GroupInputSpec (org.apache.tez.runtime.api.impl.GroupInputSpec)15 TaskSpec (org.apache.tez.runtime.api.impl.TaskSpec)12 Test (org.junit.Test)12 TezTaskAttemptID (org.apache.tez.dag.records.TezTaskAttemptID)10 ProcessorDescriptor (org.apache.tez.dag.api.ProcessorDescriptor)9 TaskLocationHint (org.apache.tez.dag.api.TaskLocationHint)7 TezTaskID (org.apache.tez.dag.records.TezTaskID)7 PlanTaskLocationHint (org.apache.tez.dag.api.records.DAGProtos.PlanTaskLocationHint)6 StateChangeNotifierForTest (org.apache.tez.dag.app.dag.TestStateChangeNotifier.StateChangeNotifierForTest)6 EdgeManagerForTest (org.apache.tez.test.EdgeManagerForTest)6 GraceShuffleVertexManagerForTest (org.apache.tez.test.GraceShuffleVertexManagerForTest)6 VertexManagerPluginForTest (org.apache.tez.test.VertexManagerPluginForTest)6 Path (org.apache.hadoop.fs.Path)5 TezSharedExecutor (org.apache.tez.common.TezSharedExecutor)5 ArrayList (java.util.ArrayList)4 InputDescriptor (org.apache.tez.dag.api.InputDescriptor)4 VertexLocationHint (org.apache.tez.dag.api.VertexLocationHint)4 VertexEvent (org.apache.tez.dag.app.dag.event.VertexEvent)4