Search in sources :

Example 1 with VertexExecutionContext

use of org.apache.tez.dag.api.Vertex.VertexExecutionContext in project hive by apache.

the class DagUtils method createVertex.

/*
   * Helper function to create Vertex for given ReduceWork.
   */
private Vertex createVertex(JobConf conf, ReduceWork reduceWork, LocalResource appJarLr, List<LocalResource> additionalLr, FileSystem fs, Path mrScratchDir, Context ctx) throws Exception {
    // set up operator plan
    conf.set(Utilities.INPUT_NAME, reduceWork.getName());
    Utilities.setReduceWork(conf, reduceWork, mrScratchDir, false);
    // create the directories FileSinkOperators need
    Utilities.createTmpDirs(conf, reduceWork);
    VertexExecutionContext vertexExecutionContext = createVertexExecutionContext(reduceWork);
    // create the vertex
    Vertex reducer = Vertex.create(reduceWork.getName(), ProcessorDescriptor.create(ReduceTezProcessor.class.getName()).setUserPayload(TezUtils.createUserPayloadFromConf(conf)), reduceWork.isAutoReduceParallelism() ? reduceWork.getMaxReduceTasks() : reduceWork.getNumReduceTasks(), getContainerResource(conf));
    reducer.setTaskEnvironment(getContainerEnvironment(conf, false));
    reducer.setExecutionContext(vertexExecutionContext);
    reducer.setTaskLaunchCmdOpts(getContainerJavaOpts(conf));
    Map<String, LocalResource> localResources = new HashMap<String, LocalResource>();
    localResources.put(getBaseName(appJarLr), appJarLr);
    for (LocalResource lr : additionalLr) {
        localResources.put(getBaseName(lr), lr);
    }
    reducer.addTaskLocalFiles(localResources);
    return reducer;
}
Also used : Vertex(org.apache.tez.dag.api.Vertex) PreWarmVertex(org.apache.tez.dag.api.PreWarmVertex) VertexExecutionContext(org.apache.tez.dag.api.Vertex.VertexExecutionContext) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource)

Example 2 with VertexExecutionContext

use of org.apache.tez.dag.api.Vertex.VertexExecutionContext in project hive by apache.

the class DagUtils method createVertex.

/*
   * Helper function to create Vertex for given ReduceWork.
   */
private Vertex createVertex(JobConf conf, ReduceWork reduceWork, FileSystem fs, Path mrScratchDir, Context ctx, Map<String, LocalResource> localResources) throws Exception {
    // set up operator plan
    conf.set(Utilities.INPUT_NAME, reduceWork.getName());
    Utilities.setReduceWork(conf, reduceWork, mrScratchDir, false);
    // create the directories FileSinkOperators need
    Utilities.createTmpDirs(conf, reduceWork);
    VertexExecutionContext vertexExecutionContext = createVertexExecutionContext(reduceWork);
    // create the vertex
    Vertex reducer = Vertex.create(reduceWork.getName(), ProcessorDescriptor.create(ReduceTezProcessor.class.getName()).setUserPayload(TezUtils.createUserPayloadFromConf(conf)), reduceWork.isAutoReduceParallelism() ? reduceWork.getMaxReduceTasks() : reduceWork.getNumReduceTasks(), getContainerResource(conf));
    reducer.setTaskEnvironment(getContainerEnvironment(conf, false));
    reducer.setExecutionContext(vertexExecutionContext);
    reducer.setTaskLaunchCmdOpts(getContainerJavaOpts(conf));
    reducer.addTaskLocalFiles(localResources);
    return reducer;
}
Also used : Vertex(org.apache.tez.dag.api.Vertex) PreWarmVertex(org.apache.tez.dag.api.PreWarmVertex) VertexExecutionContext(org.apache.tez.dag.api.Vertex.VertexExecutionContext)

Example 3 with VertexExecutionContext

use of org.apache.tez.dag.api.Vertex.VertexExecutionContext in project tez by apache.

the class TestVertexImpl2 method testVertexExecutionContextOnly.

@Test(timeout = 5000)
public void testVertexExecutionContextOnly() {
    VertexExecutionContext vertexExecutionContext = VertexExecutionContext.create(ExecutionContextTestInfoHolder.append(ExecutionContextTestInfoHolder.TASK_SCHEDULER_NAME_BASE, 1), ExecutionContextTestInfoHolder.append(ExecutionContextTestInfoHolder.CONTAINER_LAUNCHER_NAME_BASE, 1), ExecutionContextTestInfoHolder.append(ExecutionContextTestInfoHolder.TASK_COMM_NAME_BASE, 1));
    ExecutionContextTestInfoHolder info = new ExecutionContextTestInfoHolder(vertexExecutionContext, null, 3);
    VertexWrapper vertexWrapper = createVertexWrapperForExecutionContextTest(info);
    assertEquals(1, vertexWrapper.vertex.taskSchedulerIdentifier);
    assertEquals(1, vertexWrapper.vertex.containerLauncherIdentifier);
    assertEquals(1, vertexWrapper.vertex.taskCommunicatorIdentifier);
}
Also used : VertexExecutionContext(org.apache.tez.dag.api.Vertex.VertexExecutionContext) Test(org.junit.Test)

Example 4 with VertexExecutionContext

use of org.apache.tez.dag.api.Vertex.VertexExecutionContext in project tez by apache.

the class TestDAGPlan method testInvalidExecContext_2.

@Test(timeout = 5000)
public void testInvalidExecContext_2() {
    ServicePluginsDescriptor servicePluginsDescriptor = ServicePluginsDescriptor.create(false, new TaskSchedulerDescriptor[] { TaskSchedulerDescriptor.create("plugin", null) }, new ContainerLauncherDescriptor[] { ContainerLauncherDescriptor.create("plugin", null) }, new TaskCommunicatorDescriptor[] { TaskCommunicatorDescriptor.create("plugin", null) });
    VertexExecutionContext validExecContext = VertexExecutionContext.create("plugin", "plugin", "plugin");
    VertexExecutionContext invalidExecContext1 = VertexExecutionContext.create("invalidplugin", "plugin", "plugin");
    VertexExecutionContext invalidExecContext2 = VertexExecutionContext.create("plugin", "invalidplugin", "plugin");
    VertexExecutionContext invalidExecContext3 = VertexExecutionContext.create("plugin", "plugin", "invalidplugin");
    DAG dag = DAG.create("dag1");
    dag.setExecutionContext(VertexExecutionContext.createExecuteInContainers(true));
    Vertex v1 = Vertex.create("testvertex", ProcessorDescriptor.create("processor1"), 1);
    dag.addVertex(v1);
    // Should succeed. Default context is containers.
    dag.createDag(new TezConfiguration(false), null, null, null, true, servicePluginsDescriptor, null);
    // Set execute in AM should fail
    v1.setExecutionContext(VertexExecutionContext.createExecuteInAm(true));
    try {
        dag.createDag(new TezConfiguration(false), null, null, null, true, servicePluginsDescriptor, null);
        fail("Expecting dag create to fail due to invalid ServicePluginDescriptor");
    } catch (IllegalStateException e) {
        assertTrue(e.getMessage().contains("AM execution"));
    }
    // Valid context
    v1.setExecutionContext(validExecContext);
    dag.createDag(new TezConfiguration(false), null, null, null, true, servicePluginsDescriptor, null);
    // Invalid task scheduler
    v1.setExecutionContext(invalidExecContext1);
    try {
        dag.createDag(new TezConfiguration(false), null, null, null, true, servicePluginsDescriptor, null);
        fail("Expecting dag create to fail due to invalid ServicePluginDescriptor");
    } catch (IllegalStateException e) {
        assertTrue(e.getMessage().contains("testvertex"));
        assertTrue(e.getMessage().contains("task scheduler"));
        assertTrue(e.getMessage().contains("invalidplugin"));
    }
    // Invalid ContainerLauncher
    v1.setExecutionContext(invalidExecContext2);
    try {
        dag.createDag(new TezConfiguration(false), null, null, null, true, servicePluginsDescriptor, null);
        fail("Expecting dag create to fail due to invalid ServicePluginDescriptor");
    } catch (IllegalStateException e) {
        assertTrue(e.getMessage().contains("testvertex"));
        assertTrue(e.getMessage().contains("container launcher"));
        assertTrue(e.getMessage().contains("invalidplugin"));
    }
    // Invalid task comm
    v1.setExecutionContext(invalidExecContext3);
    try {
        dag.createDag(new TezConfiguration(false), null, null, null, true, servicePluginsDescriptor, null);
        fail("Expecting dag create to fail due to invalid ServicePluginDescriptor");
    } catch (IllegalStateException e) {
        assertTrue(e.getMessage().contains("testvertex"));
        assertTrue(e.getMessage().contains("task communicator"));
        assertTrue(e.getMessage().contains("invalidplugin"));
    }
}
Also used : VertexExecutionContext(org.apache.tez.dag.api.Vertex.VertexExecutionContext) ServicePluginsDescriptor(org.apache.tez.serviceplugins.api.ServicePluginsDescriptor) Test(org.junit.Test)

Example 5 with VertexExecutionContext

use of org.apache.tez.dag.api.Vertex.VertexExecutionContext in project tez by apache.

the class TestDagTypeConverters method testVertexExecutionContextTranslation.

@Test(timeout = 5000)
public void testVertexExecutionContextTranslation() {
    VertexExecutionContext originalContext;
    VertexExecutionContextProto contextProto;
    VertexExecutionContext retrievedContext;
    // Uber
    originalContext = VertexExecutionContext.createExecuteInAm(true);
    contextProto = DagTypeConverters.convertToProto(originalContext);
    retrievedContext = DagTypeConverters.convertFromProto(contextProto);
    assertEquals(originalContext, retrievedContext);
    // Regular containers
    originalContext = VertexExecutionContext.createExecuteInContainers(true);
    contextProto = DagTypeConverters.convertToProto(originalContext);
    retrievedContext = DagTypeConverters.convertFromProto(contextProto);
    assertEquals(originalContext, retrievedContext);
    // Custom
    originalContext = VertexExecutionContext.create("plugin", "plugin", "plugin");
    contextProto = DagTypeConverters.convertToProto(originalContext);
    retrievedContext = DagTypeConverters.convertFromProto(contextProto);
    assertEquals(originalContext, retrievedContext);
}
Also used : VertexExecutionContext(org.apache.tez.dag.api.Vertex.VertexExecutionContext) VertexExecutionContextProto(org.apache.tez.dag.api.records.DAGProtos.VertexExecutionContextProto) Test(org.junit.Test)

Aggregations

VertexExecutionContext (org.apache.tez.dag.api.Vertex.VertexExecutionContext)12 Test (org.junit.Test)6 PreWarmVertex (org.apache.tez.dag.api.PreWarmVertex)5 Vertex (org.apache.tez.dag.api.Vertex)5 HashMap (java.util.HashMap)4 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)4 IOException (java.io.IOException)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 FileSystem (org.apache.hadoop.fs.FileSystem)2 Path (org.apache.hadoop.fs.Path)2 MergeFileWork (org.apache.hadoop.hive.ql.io.merge.MergeFileWork)2 DataSourceDescriptor (org.apache.tez.dag.api.DataSourceDescriptor)2 InputInitializerDescriptor (org.apache.tez.dag.api.InputInitializerDescriptor)2 UserPayload (org.apache.tez.dag.api.UserPayload)2 DAGPlan (org.apache.tez.dag.api.records.DAGProtos.DAGPlan)2 VertexExecutionContextProto (org.apache.tez.dag.api.records.DAGProtos.VertexExecutionContextProto)2 VertexPlan (org.apache.tez.dag.api.records.DAGProtos.VertexPlan)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 BidiMap (org.apache.commons.collections4.BidiMap)1