void launchWorkerNode(Container container) throws IOException, YarnException { Map<String, String> env = System.getenv(); ContainerLaunchContext workerContext = Records.newRecord(ContainerLaunchContext.class); LocalResource workerJar = Records.newRecord(LocalResource.class); setupWorkerJar(workerJar); workerContext.setLocalResources(Collections.singletonMap("socialite.jar", workerJar)); System.out.println("[Master] workerJar:" + workerJar); Map<String, String> workerEnv = new HashMap<String, String>(env); setupWorkerEnv(workerEnv); workerContext.setEnvironment(workerEnv); String opts = "-Dsocialite.master=" + NetUtils.getHostname().split("/")[1] + " "; opts += "-Dsocialite.worker.num_threads=" + ClusterConf.get().getNumWorkerThreads() + " "; workerContext.setCommands( Collections.singletonList( "$JAVA_HOME/bin/java -ea " + env.get("JVM_OPTS") + " " + env.get("SOCIALITE_OPTS") + " " + opts + " " + "socialite.dist.worker.WorkerNode" + " 1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/stdout" + " 2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/stderr")); nmClient.startContainer(container, workerContext); L.info("Launched worker node (container:" + container.getId() + ")"); }
// Examines servlet config and servlet context for configuration parameters. // Configuration from the servlet context overrides servlet parameters defined in web.xml Configuration initConfig(ServletConfig pConfig) { Configuration config = new Configuration(ConfigKey.AGENT_ID, NetworkUtil.getAgentId(hashCode(), "servlet")); // From ServletContext .... config.updateGlobalConfiguration(new ServletConfigFacade(pConfig)); // ... and ServletConfig config.updateGlobalConfiguration(new ServletContextFacade(getServletContext())); // Set type last and overwrite anything written config.updateGlobalConfiguration( Collections.singletonMap(ConfigKey.AGENT_TYPE.getKeyValue(), "servlet")); return config; }