List of usage examples for org.apache.hadoop.yarn.api.protocolrecords StopContainersRequest setContainerIds
@Public @Stable public abstract void setContainerIds(List<ContainerId> containerIds);
ContainerIds of the containers to be stopped. From source file:org.apache.hama.bsp.BSPTaskLauncher.java
License:Apache License
public void stopAndCleanup() throws YarnException, IOException { StopContainersRequest stopRequest = Records.newRecord(StopContainersRequest.class); List<ContainerId> containerIds = new ArrayList<ContainerId>(); containerIds.add(allocatedContainer.getId()); LOG.info("getId : " + allocatedContainer.getId()); stopRequest.setContainerIds(containerIds); LOG.info("StopContainer : " + stopRequest.getContainerIds()); cm.stopContainers(stopRequest);//from w w w . j a v a 2 s . c o m }
From source file:org.apache.tajo.master.YarnContainerProxy.java
License:Apache License
@Override public synchronized void stopContainer() { if (isCompletelyDone()) { return;//www.jav a 2 s.co m } if (this.state == ContainerState.PREP) { this.state = ContainerState.KILLED_BEFORE_LAUNCH; } else { LOG.info("KILLING " + containerID); ContainerManagementProtocol proxy = null; try { proxy = getCMProxy(this.containerID, this.containerMgrAddress, this.containerToken); // kill the remote container if already launched List<ContainerId> willBeStopedIds = new ArrayList<ContainerId>(); willBeStopedIds.add(this.containerID); StopContainersRequest stopRequests = Records.newRecord(StopContainersRequest.class); stopRequests.setContainerIds(willBeStopedIds); proxy.stopContainers(stopRequests); // If stopContainer returns without an error, assuming the stop made // it over to the NodeManager. // context.getEventHandler().handle( // new AMContainerEvent(containerID, AMContainerEventType.C_NM_STOP_SENT)); context.getResourceAllocator().removeContainer(containerID); } catch (Throwable t) { // ignore the cleanup failure String message = "cleanup failed for container " + this.containerID + " : " + StringUtils.stringifyException(t); // context.getEventHandler().handle( // new AMContainerEventStopFailed(containerID, message)); LOG.warn(message); this.state = ContainerState.DONE; return; } finally { if (proxy != null) { yarnRPC.stopProxy(proxy, conf); } } this.state = ContainerState.DONE; } }
From source file:org.springframework.yarn.am.AppmasterCmTemplate.java
License:Apache License
@Override public StopContainersResponse stopContainers() { return execute(new YarnRpcCallback<StopContainersResponse, ContainerManagementProtocol>() { @Override//from w w w .j a va2s . c o m public StopContainersResponse doInYarn(ContainerManagementProtocol proxy) throws YarnException, IOException { StopContainersRequest request = Records.newRecord(StopContainersRequest.class); ArrayList<ContainerId> ids = new ArrayList<ContainerId>(); ids.add(container.getId()); request.setContainerIds(ids); return proxy.stopContainers(request); } }); }