nodeManagerClient.startContainer(container, taskManagerLaunchContext);
protected NMClient createAndStartNodeManagerClient(YarnConfiguration yarnConfiguration) { // create the client to communicate with the node managers NMClient nodeManagerClient = NMClient.createNMClient(); nodeManagerClient.init(yarnConfiguration); nodeManagerClient.start(); nodeManagerClient.cleanupRunningContainersOnStop(true); return nodeManagerClient; }
private void releaseYarnContainer(Container container) { LOG.info("Releasing YARN container {}", container.getId()); containersBeingReturned.put(container.getId(), container); // release the container on the node manager try { nodeManagerClient.stopContainer(container.getId(), container.getNodeId()); } catch (Throwable t) { // we only log this error. since the ResourceManager also gets the release // notification, the container should be eventually cleaned up LOG.error("Error while calling YARN Node Manager to release container", t); } // tell the master that the container is no longer needed resourceManagerClient.releaseAssignedContainer(container.getId()); }
/** * @throws IOException */ public void init() throws IOException { if (UserGroupInformation.isSecurityEnabled()) { Credentials cred = UserGroupInformation.getCurrentUser().getCredentials(); allTokens = IgniteYarnUtils.createTokenBuffer(cred); } fs = FileSystem.get(conf); nmClient = NMClient.createNMClient(); nmClient.init(conf); nmClient.start(); // Create async application master. rmClient = AMRMClientAsync.createAMRMClientAsync(300, this); rmClient.init(conf); rmClient.start(); if (props.igniteCfg() == null || props.igniteCfg().isEmpty()) { InputStream input = Thread.currentThread().getContextClassLoader() .getResourceAsStream(IgniteYarnUtils.DEFAULT_IGNITE_CONFIG); cfgPath = new Path(props.igniteWorkDir() + File.separator + IgniteYarnUtils.DEFAULT_IGNITE_CONFIG); // Create file. Override by default. FSDataOutputStream outputStream = fs.create(cfgPath, true); IOUtils.copy(input, outputStream); IOUtils.closeQuietly(input); IOUtils.closeQuietly(outputStream); } else cfgPath = new Path(props.igniteCfg()); }
nodeManagerClient.init(yarnConfig); nodeManagerClient.start(); nodeManagerClient.cleanupRunningContainersOnStop(true);
rmClient.start(); NMClient nmClient = NMClient.createNMClient(); nmClient.init(conf); nmClient.start(); )); System.out.println("Launching container " + container.getId()); nmClient.startContainer(container, ctx);
private void _registerSchedulerAndCreateNMClient(String queue) throws Exception { NMTokenCache nmTokenCache = new NMTokenCache(); nmClient = NMClient.createNMClient(); nmClient.setNMTokenCache(nmTokenCache); nmClient.init(yarnConf); nmClient.start(); LOG.debug("Started NMClient, AM '{}' with scheduler for '{}' queue", appId, queue);
/** {@inheritDoc} */ public void onError(Throwable t) { nmClient.stop(); }
verify(mockNMClient).startContainer(eq(testingContainer), any(ContainerLaunchContext.class)); verify(mockNMClient).stopContainer(any(ContainerId.class), any(NodeId.class)); verify(mockResourceManagerClient).releaseAssignedContainer(any(ContainerId.class)); });
@Override protected void startUp() throws Exception { nmClient.start(); }
public Hadoop21YarnNMClient(Configuration configuration) { this.nmClient = NMClient.createNMClient(); nmClient.init(configuration); }
@Override protected void serviceInit(Configuration conf) throws Exception { this.maxThreadPoolSize = conf.getInt( YarnConfiguration.NM_CLIENT_ASYNC_THREAD_POOL_MAX_SIZE, YarnConfiguration.DEFAULT_NM_CLIENT_ASYNC_THREAD_POOL_MAX_SIZE); LOG.info("Upper bound of the thread pool size is " + maxThreadPoolSize); client.init(conf); super.serviceInit(conf); }
@Override public void cancel() { LOG.info("Request to stop container {}.", container.getId()); try { nmClient.stopContainer(container.getId(), container.getNodeId()); while (true) { ContainerStatus status = nmClient.getContainerStatus(container.getId(), container.getNodeId()); LOG.trace("Container status: {} {}", status, status.getDiagnostics()); if (status.getState() == ContainerState.COMPLETE) { break; } Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS); } LOG.info("Container {} stopped.", container.getId()); } catch (Exception e) { LOG.error("Fail to stop container {}", container.getId(), e); throw Throwables.propagate(e); } } }
callbackHandler, AMRMClientAsync.createAMRMClientAsync(yarnHeartbeatIntervalMillis, callbackHandler), NMClient.createNMClient());
if (event.getType() == ContainerEventType.QUERY_CONTAINER) { try { ContainerStatus containerStatus = client.getContainerStatus( containerId, event.getNodeId()); try {
@Override protected void serviceInit(Configuration conf) throws Exception { super.serviceInit(conf); if (getNMTokenCache() == null) { throw new IllegalStateException("NMTokenCache has not been set"); } cmProxy = new ContainerManagementProtocolProxy(conf, getNMTokenCache()); }
@Override protected void serviceStop() throws Exception { // Usually, started-containers are stopped when this client stops. Unless // the flag cleanupRunningContainers is set to false. if (getCleanupRunningContainers().get()) { cleanupRunningContainers(); } cmProxy.stopAllProxies(); super.serviceStop(); }
public ApplicationMasterAsync(String command, int numContainersToWaitFor) { this.command = command; configuration = new YarnConfiguration(); this.numContainersToWaitFor = numContainersToWaitFor; nmClient = NMClient.createNMClient(); nmClient.init(configuration); nmClient.start(); }
nodeManagerClient.init(yarnConfig); nodeManagerClient.start(); nodeManagerClient.cleanupRunningContainersOnStop(true);
@Override protected void shutdownApplication(ApplicationStatus finalStatus, String optionalDiagnostics) { // first, de-register from YARN FinalApplicationStatus yarnStatus = getYarnStatus(finalStatus); LOG.info("Unregistering application from the YARN Resource Manager"); try { resourceManagerClient.unregisterApplicationMaster(yarnStatus, optionalDiagnostics, ""); } catch (Throwable t) { LOG.error("Could not unregister the application master.", t); } // now shut down all our components try { resourceManagerClient.stop(); } catch (Throwable t) { LOG.error("Could not cleanly shut down the Asynchronous Resource Manager Client", t); } try { nodeManagerClient.stop(); } catch (Throwable t) { LOG.error("Could not cleanly shut down the Node Manager Client", t); } // stop the actor after finishing processing the stop message getContext().system().stop(getSelf()); }