use of org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext in project tez by apache.
the class TestTezClientUtils method testSetApplicationTags.
@Test(timeout = 1000)
public void testSetApplicationTags() {
TezConfiguration conf = new TezConfiguration(false);
conf.set(TezConfiguration.TEZ_APPLICATION_TAGS, "foo,bar");
AMConfiguration amconfig = new AMConfiguration(conf, null, null);
ApplicationSubmissionContext appContext = Records.newRecord(ApplicationSubmissionContext.class);
Collection<String> tagsFromConf = amconfig.getTezConfiguration().getTrimmedStringCollection(TezConfiguration.TEZ_APPLICATION_TAGS);
appContext.setApplicationTags(new HashSet<String>(tagsFromConf));
assertTrue(appContext.getApplicationTags().contains("foo"));
assertTrue(appContext.getApplicationTags().contains("bar"));
}
use of org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext in project tez by apache.
the class TestTezClientUtils method testAMLoggingOptsPerLogger.
@Test(timeout = 5000)
public void testAMLoggingOptsPerLogger() throws IOException, YarnException {
TezConfiguration tezConf = new TezConfiguration();
tezConf.set(TezConfiguration.TEZ_AM_LOG_LEVEL, "WARN;org.apache.hadoop.ipc=DEBUG;org.apache.hadoop.security=DEBUG");
ApplicationId appId = ApplicationId.newInstance(1000, 1);
Credentials credentials = new Credentials();
JobTokenSecretManager jobTokenSecretManager = new JobTokenSecretManager();
TezClientUtils.createSessionToken(appId.toString(), jobTokenSecretManager, credentials);
DAG dag = DAG.create("testdag");
dag.addVertex(Vertex.create("testVertex", ProcessorDescriptor.create("processorClassname"), 1).setTaskLaunchCmdOpts("initialLaunchOpts"));
AMConfiguration amConf = new AMConfiguration(tezConf, new HashMap<String, LocalResource>(), credentials);
ApplicationSubmissionContext appSubmissionContext = TezClientUtils.createApplicationSubmissionContext(appId, dag, "amName", amConf, new HashMap<String, LocalResource>(), credentials, false, new TezApiVersionInfo(), null, null);
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 + "=" + "WARN" + "," + TezConstants.TEZ_CONTAINER_LOGGER_NAME);
List<String> commands = appSubmissionContext.getAMContainerSpec().getCommands();
assertEquals(1, commands.size());
for (String expectedCmd : expectedCommands) {
assertTrue(commands.get(0).contains(expectedCmd));
}
Map<String, String> environment = appSubmissionContext.getAMContainerSpec().getEnvironment();
String logEnv = environment.get(TezConstants.TEZ_CONTAINER_LOG_PARAMS);
assertEquals("org.apache.hadoop.ipc=DEBUG;org.apache.hadoop.security=DEBUG", logEnv);
}
use of org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext in project tez by apache.
the class TestTezClientUtils method testAMLoggingOptsSimple.
@Test(timeout = 5000)
public void testAMLoggingOptsSimple() throws IOException, YarnException {
TezConfiguration tezConf = new TezConfiguration();
tezConf.set(TezConfiguration.TEZ_AM_LOG_LEVEL, "WARN");
ApplicationId appId = ApplicationId.newInstance(1000, 1);
Credentials credentials = new Credentials();
JobTokenSecretManager jobTokenSecretManager = new JobTokenSecretManager();
TezClientUtils.createSessionToken(appId.toString(), jobTokenSecretManager, credentials);
DAG dag = DAG.create("testdag");
dag.addVertex(Vertex.create("testVertex", ProcessorDescriptor.create("processorClassname"), 1).setTaskLaunchCmdOpts("initialLaunchOpts"));
AMConfiguration amConf = new AMConfiguration(tezConf, new HashMap<String, LocalResource>(), credentials);
ApplicationSubmissionContext appSubmissionContext = TezClientUtils.createApplicationSubmissionContext(appId, dag, "amName", amConf, new HashMap<String, LocalResource>(), credentials, false, new TezApiVersionInfo(), null, null);
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 + "=" + "WARN" + "," + TezConstants.TEZ_CONTAINER_LOGGER_NAME);
List<String> commands = appSubmissionContext.getAMContainerSpec().getCommands();
assertEquals(1, commands.size());
for (String expectedCmd : expectedCommands) {
assertTrue(commands.get(0).contains(expectedCmd));
}
Map<String, String> environment = appSubmissionContext.getAMContainerSpec().getEnvironment();
String logEnv = environment.get(TezConstants.TEZ_CONTAINER_LOG_PARAMS);
assertNull(logEnv);
}
use of org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext in project tez by apache.
the class TestTezClientUtils method testAppSubmissionContextForPriority.
@Test(timeout = 2000)
public // ApplicationSubmissionContext
void testAppSubmissionContextForPriority() throws Exception {
TezConfiguration tezConf = new TezConfiguration();
int testpriority = 999;
ApplicationId appId = ApplicationId.newInstance(1000, 1);
Credentials credentials = new Credentials();
TezClientUtils.createSessionToken(appId.toString(), new JobTokenSecretManager(), credentials);
tezConf.setBoolean(TezConfiguration.TEZ_IGNORE_LIB_URIS, true);
Map<String, LocalResource> m = new HashMap<String, LocalResource>();
tezConf.setInt(TezConfiguration.TEZ_AM_APPLICATION_PRIORITY, testpriority);
AMConfiguration amConf = new AMConfiguration(tezConf, new HashMap<String, LocalResource>(), credentials);
ApplicationSubmissionContext appcontext;
appcontext = TezClientUtils.createApplicationSubmissionContext(appId, null, "dagname", amConf, m, credentials, false, new TezApiVersionInfo(), null, null);
assertEquals(testpriority, appcontext.getPriority().getPriority());
}
use of org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext in project tez by apache.
the class LocalClient method createApplication.
@Override
public YarnClientApplication createApplication() throws YarnException, IOException {
ApplicationSubmissionContext context = Records.newRecord(ApplicationSubmissionContext.class);
ApplicationId appId = ApplicationId.newInstance(clusterTimeStamp, appIdNumber++);
context.setApplicationId(appId);
GetNewApplicationResponse response = Records.newRecord(GetNewApplicationResponse.class);
response.setApplicationId(appId);
return new YarnClientApplication(response, context);
}
Aggregations