myServiceData, null, new HashMap<ApplicationAccessType, String>());
}
public static ContainerLaunchContext createCommonContainerLaunchContext(Configuration config,
String queryId, boolean isMaster) {
TajoConf conf = (TajoConf)config;
ContainerLaunchContext ctx = Records.newRecord(ContainerLaunchContext.class);
try {
ctx.setUser(UserGroupInformation.getCurrentUser().getShortUserName());
} catch (IOException e) {
e.printStackTrace();
}
////////////////////////////////////////////////////////////////////////////
// Set the env variables to be setup
////////////////////////////////////////////////////////////////////////////
LOG.info("Set the environment for the application master");
Map<String, String> environment = new HashMap<String, String>();
//String initialClassPath = getInitialClasspath(conf);
environment.put(ApplicationConstants.Environment.SHELL.name(), "/bin/bash");
if(System.getenv(ApplicationConstants.Environment.JAVA_HOME.name()) != null) {
environment.put(ApplicationConstants.Environment.JAVA_HOME.name(), System.getenv(ApplicationConstants.Environment.JAVA_HOME.name()));
}
// TODO - to be improved with org.apache.tajo.sh shell script
Properties prop = System.getProperties();
if (prop.getProperty("tajo.test", "FALSE").equalsIgnoreCase("TRUE") ||
(System.getenv("tajo.test") != null && System.getenv("tajo.test").equalsIgnoreCase("TRUE"))) {
LOG.info("tajo.test is TRUE");
environment.put(ApplicationConstants.Environment.CLASSPATH.name(), prop.getProperty("java.class.path", null));
environment.put("tajo.test", "TRUE");
} else {
// Add AppMaster.jar location to classpath
// At some point we should not be required to add
// the hadoop specific classpaths to the env.
// It should be provided out of the box.
// For now setting all required classpaths including
// the classpath to "." for the application jar
StringBuilder classPathEnv = new StringBuilder("./");
//for (String c : conf.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH)) {
for (String c : YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH) {
classPathEnv.append(':');
classPathEnv.append(c.trim());
}
classPathEnv.append(":" + System.getenv("TAJO_BASE_CLASSPATH"));
classPathEnv.append(":./log4j.properties:./*");
if(System.getenv("HADOOP_HOME") != null) {
environment.put("HADOOP_HOME", System.getenv("HADOOP_HOME"));
environment.put(
ApplicationConstants.Environment.HADOOP_COMMON_HOME.name(),
System.getenv("HADOOP_HOME"));
environment.put(
ApplicationConstants.Environment.HADOOP_HDFS_HOME.name(),
System.getenv("HADOOP_HOME"));
environment.put(
ApplicationConstants.Environment.HADOOP_YARN_HOME.name(),
System.getenv("HADOOP_HOME"));
}
if(System.getenv("TAJO_BASE_CLASSPATH") != null) {
environment.put("TAJO_BASE_CLASSPATH", System.getenv("TAJO_BASE_CLASSPATH"));
}
environment.put(ApplicationConstants.Environment.CLASSPATH.name(), classPathEnv.toString());
}
ctx.setEnvironment(environment);
if(LOG.isDebugEnabled()) {
LOG.debug("=================================================");
for(Map.Entry<String, String> entry: environment.entrySet()) {
LOG.debug(entry.getKey() + "=" + entry.getValue());
}
LOG.debug("=================================================");
}
////////////////////////////////////////////////////////////////////////////
// Set the local resources
////////////////////////////////////////////////////////////////////////////
Map<String, LocalResource> localResources = new HashMap<String, LocalResource>();
FileSystem fs = null;
FileContext fsCtx = null;
LOG.info("defaultFS: " + conf.get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY));
try {
fs = FileSystem.get(conf);
fsCtx = FileContext.getFileContext(conf);
} catch (IOException e) {
LOG.error(e.getMessage(), e);