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()); }
@Override public boolean stopWorker(final YarnWorkerNode workerNode) { final Container container = workerNode.getContainer(); log.info("Stopping container {}.", container.getId()); try { nodeManagerClient.stopContainer(container.getId(), container.getNodeId()); } catch (final Exception e) { log.warn("Error while calling YARN Node Manager to stop container", e); } resourceManagerClient.releaseAssignedContainer(container.getId()); workerNodeMap.remove(workerNode.getResourceID()); return true; }
verify(mockNMClient).stopContainer(any(ContainerId.class), any(NodeId.class)); verify(mockResourceManagerClient).releaseAssignedContainer(any(ContainerId.class)); });
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()); }
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()); }
@Override public boolean stopWorker(final YarnWorkerNode workerNode) { final Container container = workerNode.getContainer(); log.info("Stopping container {}.", container.getId()); try { nodeManagerClient.stopContainer(container.getId(), container.getNodeId()); } catch (final Exception e) { log.warn("Error while calling YARN Node Manager to stop container", e); } resourceManagerClient.releaseAssignedContainer(container.getId()); workerNodeMap.remove(workerNode.getResourceID()); return true; }
@Override public boolean stopWorker(final YarnWorkerNode workerNode) { final Container container = workerNode.getContainer(); log.info("Stopping container {}.", container.getId()); try { nodeManagerClient.stopContainer(container.getId(), container.getNodeId()); } catch (final Exception e) { log.warn("Error while calling YARN Node Manager to stop container", e); } resourceManagerClient.releaseAssignedContainer(container.getId()); workerNodeMap.remove(workerNode.getResourceID()); return true; }
@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); } } }
@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); } } }
@Override public Void run() throws Exception { if (action == Action.START) { LOG.debug("Starting container '{}' process for resource '{}' " + "at node '{}'", container.getId(), clientResourceId, container.getNodeId()); ContainerLaunchContext ctx = Records.newRecord(ContainerLaunchContext.class); ctx.setEnvironment(Collections.EMPTY_MAP); ctx.setLocalResources(Collections.EMPTY_MAP); ctx.setCommands(Arrays.asList("sleep", Integer.toString( SLEEP_TIME_SEC))); nmClient.startContainer(container, ctx); } else { nmClient.stopContainer(container.getId(), container.getNodeId()); } return null; } });
@Override public ContainerState transition( StatefulContainer container, ContainerEvent event) { ContainerId containerId = event.getContainerId(); try { container.nmClientAsync.getClient().stopContainer( containerId, event.getNodeId()); try { container.nmClientAsync.getCallbackHandler().onContainerStopped( event.getContainerId()); } catch (Throwable thr) { // Don't process user created unchecked exception LOG.info("Unchecked exception is thrown from onContainerStopped for " + "Container " + event.getContainerId(), thr); } return ContainerState.DONE; } catch (YarnException e) { return onExceptionRaised(container, event, e); } catch (IOException e) { return onExceptionRaised(container, event, e); } catch (Throwable t) { return onExceptionRaised(container, event, t); } }
@Override public ContainerState transition( StatefulContainer container, ContainerEvent event) { ContainerId containerId = event.getContainerId(); try { container.nmClientAsync.getClient().stopContainer( containerId, event.getNodeId()); try { container.nmClientAsync.getCallbackHandler().onContainerStopped( event.getContainerId()); } catch (Throwable thr) { // Don't process user created unchecked exception LOG.info("Unchecked exception is thrown from onContainerStopped for " + "Container " + event.getContainerId(), thr); } return ContainerState.DONE; } catch (YarnException e) { return onExceptionRaised(container, event, e); } catch (IOException e) { return onExceptionRaised(container, event, e); } catch (Throwable t) { return onExceptionRaised(container, event, t); } }
@Override public ContainerState transition( StatefulContainer container, ContainerEvent event) { ContainerId containerId = event.getContainerId(); try { container.nmClientAsync.getClient().stopContainer( containerId, event.getNodeId()); try { container.nmClientAsync.getCallbackHandler().onContainerStopped( event.getContainerId()); } catch (Throwable thr) { // Don't process user created unchecked exception LOG.info("Unchecked exception is thrown from onContainerStopped for " + "Container " + event.getContainerId(), thr); } return ContainerState.DONE; } catch (YarnException e) { return onExceptionRaised(container, event, e); } catch (IOException e) { return onExceptionRaised(container, event, e); } catch (Throwable t) { return onExceptionRaised(container, event, t); } }
@Override public ContainerState transition( StatefulContainer container, ContainerEvent event) { ContainerId containerId = event.getContainerId(); try { container.nmClientAsync.getClient().stopContainer( containerId, event.getNodeId()); try { container.nmClientAsync.getCallbackHandler().onContainerStopped( event.getContainerId()); } catch (Throwable thr) { // Don't process user created unchecked exception LOG.info("Unchecked exception is thrown from onContainerStopped for " + "Container " + event.getContainerId(), thr); } return ContainerState.DONE; } catch (YarnException e) { return onExceptionRaised(container, event, e); } catch (IOException e) { return onExceptionRaised(container, event, e); } catch (Throwable t) { return onExceptionRaised(container, event, t); } }