Search in sources :

Example 6 with ContainerContext

use of org.apache.tez.dag.app.ContainerContext in project tez by apache.

the class TestVertexImpl2 method testTaskSpecificLoggingOpts.

@Test(timeout = 5000)
public void testTaskSpecificLoggingOpts() {
    String vertexName = "testvertex";
    String customJavaOpts = "-Xmx128m";
    Configuration conf = new TezConfiguration();
    conf.set(TezConfiguration.TEZ_TASK_LOG_LEVEL, "INFO");
    conf.set(TezConfiguration.TEZ_TASK_SPECIFIC_LAUNCH_CMD_OPTS_LIST, vertexName + "[0,1,2]");
    conf.set(TezConfiguration.TEZ_TASK_SPECIFIC_LOG_LEVEL, "DEBUG;org.apache.tez=INFO");
    conf.set(TezConfiguration.TEZ_TASK_SPECIFIC_LAUNCH_CMD_OPTS, customJavaOpts);
    LogTestInfoHolder testInfo = new LogTestInfoHolder();
    VertexWrapper vertexWrapper = createVertexWrapperForLogTests(testInfo, conf);
    // Expected command opts for regular tasks
    List<String> expectedCommands = new LinkedList<String>();
    expectedCommands.add("-Dlog4j.configuratorClass=org.apache.tez.common.TezLog4jConfigurator");
    expectedCommands.add("-Dlog4j.configuration=" + TezConstants.TEZ_CONTAINER_LOG4J_PROPERTIES_FILE);
    expectedCommands.add("-D" + YarnConfiguration.YARN_APP_CONTAINER_LOG_DIR + "=" + ApplicationConstants.LOG_DIR_EXPANSION_VAR);
    expectedCommands.add("-D" + TezConstants.TEZ_ROOT_LOGGER_NAME + "=" + "INFO" + "," + TezConstants.TEZ_CONTAINER_LOGGER_NAME);
    for (int i = 3; i < testInfo.numTasks; i++) {
        ContainerContext containerContext = vertexWrapper.vertex.getContainerContext(i);
        String javaOpts = containerContext.getJavaOpts();
        assertTrue(javaOpts.contains(testInfo.initialJavaOpts));
        for (String expectedCmd : expectedCommands) {
            assertTrue(javaOpts.contains(expectedCmd));
        }
        Map<String, String> env = containerContext.getEnvironment();
        String val = env.get(testInfo.envKey);
        assertEquals(testInfo.envVal, val);
        String logEnvVal = env.get(TezConstants.TEZ_CONTAINER_LOG_PARAMS);
        assertNull(logEnvVal);
    }
    // Expected command opts for instrumented tasks.
    expectedCommands = new LinkedList<String>();
    expectedCommands.add("-Dlog4j.configuratorClass=org.apache.tez.common.TezLog4jConfigurator");
    expectedCommands.add("-Dlog4j.configuration=" + TezConstants.TEZ_CONTAINER_LOG4J_PROPERTIES_FILE);
    expectedCommands.add("-D" + YarnConfiguration.YARN_APP_CONTAINER_LOG_DIR + "=" + ApplicationConstants.LOG_DIR_EXPANSION_VAR);
    expectedCommands.add("-D" + TezConstants.TEZ_ROOT_LOGGER_NAME + "=" + "DEBUG" + "," + TezConstants.TEZ_CONTAINER_LOGGER_NAME);
    for (int i = 0; i < 3; i++) {
        ContainerContext containerContext = vertexWrapper.vertex.getContainerContext(i);
        String javaOpts = containerContext.getJavaOpts();
        assertTrue(javaOpts.contains(testInfo.initialJavaOpts));
        for (String expectedCmd : expectedCommands) {
            assertTrue(javaOpts.contains(expectedCmd));
        }
        Map<String, String> env = containerContext.getEnvironment();
        String val = env.get(testInfo.envKey);
        assertEquals(testInfo.envVal, val);
        String logEnvVal = env.get(TezConstants.TEZ_CONTAINER_LOG_PARAMS);
        assertEquals("org.apache.tez=INFO", logEnvVal);
    }
}
Also used : ContainerContext(org.apache.tez.dag.app.ContainerContext) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) LinkedList(java.util.LinkedList) TaskLocationHint(org.apache.tez.dag.api.TaskLocationHint) VertexLocationHint(org.apache.tez.dag.api.VertexLocationHint) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) Test(org.junit.Test)

Example 7 with ContainerContext

use of org.apache.tez.dag.app.ContainerContext in project tez by apache.

the class TestVertexImpl2 method testTaskLoggingOptsSimple.

@Test(timeout = 5000)
public void testTaskLoggingOptsSimple() {
    Configuration conf = new TezConfiguration();
    conf.set(TezConfiguration.TEZ_TASK_LOG_LEVEL, "DEBUG");
    LogTestInfoHolder testInfo = new LogTestInfoHolder();
    VertexWrapper vertexWrapper = createVertexWrapperForLogTests(testInfo, conf);
    List<String> expectedCommands = new LinkedList<String>();
    expectedCommands.add("-Dlog4j.configuratorClass=org.apache.tez.common.TezLog4jConfigurator");
    expectedCommands.add("-Dlog4j.configuration=" + TezConstants.TEZ_CONTAINER_LOG4J_PROPERTIES_FILE);
    expectedCommands.add("-D" + YarnConfiguration.YARN_APP_CONTAINER_LOG_DIR + "=" + ApplicationConstants.LOG_DIR_EXPANSION_VAR);
    expectedCommands.add("-D" + TezConstants.TEZ_ROOT_LOGGER_NAME + "=" + "DEBUG" + "," + TezConstants.TEZ_CONTAINER_LOGGER_NAME);
    for (int i = 0; i < testInfo.numTasks; i++) {
        ContainerContext containerContext = vertexWrapper.vertex.getContainerContext(i);
        String javaOpts = containerContext.getJavaOpts();
        assertTrue(javaOpts.contains(testInfo.initialJavaOpts));
        for (String expectedCmd : expectedCommands) {
            assertTrue(javaOpts.contains(expectedCmd));
        }
        Map<String, String> env = containerContext.getEnvironment();
        String val = env.get(testInfo.envKey);
        assertEquals(testInfo.envVal, val);
        String logEnvVal = env.get(TezConstants.TEZ_CONTAINER_LOG_PARAMS);
        assertNull(logEnvVal);
    }
}
Also used : ContainerContext(org.apache.tez.dag.app.ContainerContext) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) Configuration(org.apache.hadoop.conf.Configuration) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) LinkedList(java.util.LinkedList) TaskLocationHint(org.apache.tez.dag.api.TaskLocationHint) VertexLocationHint(org.apache.tez.dag.api.VertexLocationHint) TezConfiguration(org.apache.tez.dag.api.TezConfiguration) Test(org.junit.Test)

Example 8 with ContainerContext

use of org.apache.tez.dag.app.ContainerContext in project tez by apache.

the class ContainerContextMatcher method isExactMatch.

@Override
public boolean isExactMatch(Object cs1, Object cs2) {
    checkArguments(cs1, cs2);
    ContainerContext context1 = (ContainerContext) cs1;
    ContainerContext context2 = (ContainerContext) cs2;
    return context1.isExactMatch(context2);
}
Also used : ContainerContext(org.apache.tez.dag.app.ContainerContext)

Example 9 with ContainerContext

use of org.apache.tez.dag.app.ContainerContext in project tez by apache.

the class VertexImpl method getContainerContext.

@VisibleForTesting
ContainerContext getContainerContext(int taskIdx) {
    if (taskSpecificLaunchCmdOpts.addTaskSpecificLaunchCmdOption(vertexName, taskIdx)) {
        String jvmOpts = javaOptsTaskSpecific != null ? javaOptsTaskSpecific : javaOpts;
        if (taskSpecificLaunchCmdOpts.hasModifiedTaskLaunchOpts()) {
            jvmOpts = taskSpecificLaunchCmdOpts.getTaskSpecificOption(jvmOpts, vertexName, taskIdx);
        }
        ContainerContext context = new ContainerContext(this.localResources, appContext.getCurrentDAG().getCredentials(), this.environmentTaskSpecific != null ? this.environmentTaskSpecific : this.environment, jvmOpts);
        return context;
    } else {
        return this.containerContext;
    }
}
Also used : ContainerContext(org.apache.tez.dag.app.ContainerContext) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

ContainerContext (org.apache.tez.dag.app.ContainerContext)9 Configuration (org.apache.hadoop.conf.Configuration)6 TezConfiguration (org.apache.tez.dag.api.TezConfiguration)6 TaskLocationHint (org.apache.tez.dag.api.TaskLocationHint)5 Test (org.junit.Test)5 LinkedList (java.util.LinkedList)4 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)4 VertexLocationHint (org.apache.tez.dag.api.VertexLocationHint)4 Credentials (org.apache.hadoop.security.Credentials)2 Container (org.apache.hadoop.yarn.api.records.Container)2 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)2 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)2 AMContainer (org.apache.tez.dag.app.rm.container.AMContainer)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 NodeId (org.apache.hadoop.yarn.api.records.NodeId)1 Resource (org.apache.hadoop.yarn.api.records.Resource)1 SystemClock (org.apache.hadoop.yarn.util.SystemClock)1 AppContext (org.apache.tez.dag.app.AppContext)1 TaskCommunicatorManagerInterface (org.apache.tez.dag.app.TaskCommunicatorManagerInterface)1 TaskHeartbeatHandler (org.apache.tez.dag.app.TaskHeartbeatHandler)1