this.yarnClient.init(conf);
this.yarnClient.start();
}
private ApplicationAttemptId allocateAndLaunchQueryMaster(QueryInProgress queryInProgress) throws IOException, YarnException {
QueryId queryId = queryInProgress.getQueryId();
ApplicationId appId = ApplicationIdUtils.queryIdToAppId(queryId);
LOG.info("Allocate and launch ApplicationMaster for QueryMaster: queryId=" +
queryId + ", appId=" + appId);
ApplicationSubmissionContext appContext = Records.newRecord(ApplicationSubmissionContext.class);
// set the application id
appContext.setApplicationId(appId);
// set the application name
appContext.setApplicationName("Tajo");
Priority pri = Records.newRecord(Priority.class);
pri.setPriority(5);
appContext.setPriority(pri);
// Set the queue to which this application is to be submitted in the RM
appContext.setQueue("default");
ContainerLaunchContext commonContainerLaunchContext =
YarnContainerProxy.createCommonContainerLaunchContext(masterContext.getConf(), queryId.toString(), true);
// Setup environment by cloning from common env.
Map<String, String> env = commonContainerLaunchContext.getEnvironment();
Map<String, String> myEnv = new HashMap<String, String>(env.size());
myEnv.putAll(env);
////////////////////////////////////////////////////////////////////////////
// Set the local resources
////////////////////////////////////////////////////////////////////////////
// Set the necessary command to execute the application master
Vector<CharSequence> vargs = new Vector<CharSequence>(30);
// Set java executable command
//LOG.info("Setting up app master command");
vargs.add("${JAVA_HOME}" + "/bin/java");
// Set Xmx based on am memory size
String jvmOptions = masterContext.getConf().get("tajo.rm.yarn.querymaster.jvm.option", "-Xmx2000m");
for(String eachToken: jvmOptions.split((" "))) {
vargs.add(eachToken);
}
// Set Remote Debugging
//if (!context.getQuery().getSubQuery(event.getExecutionBlockId()).isLeafQuery()) {
//vargs.add("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005");
//}
// Set class name
vargs.add(TajoWorker.class.getCanonicalName());
vargs.add("qm");
vargs.add(queryId.toString()); // queryId
vargs.add(masterContext.getTajoMasterService().getBindAddress().getHostName() + ":" +
masterContext.getTajoMasterService().getBindAddress().getPort());
vargs.add("1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/stdout");
vargs.add("2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/stderr");