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);
}
}
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);
}
}
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);
}
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;
}
}
Aggregations