org.apache.hadoop.yarn.client.api.impl.ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData Java Examples
The following examples show how to use
org.apache.hadoop.yarn.client.api.impl.ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NMClientImpl.java From hadoop with Apache License 2.0 | 6 votes |
private void stopContainerInternal(ContainerId containerId, NodeId nodeId) throws IOException, YarnException { ContainerManagementProtocolProxyData proxy = null; List<ContainerId> containerIds = new ArrayList<ContainerId>(); containerIds.add(containerId); try { proxy = cmProxy.getProxy(nodeId.toString(), containerId); StopContainersResponse response = proxy.getContainerManagementProtocol().stopContainers( StopContainersRequest.newInstance(containerIds)); if (response.getFailedRequests() != null && response.getFailedRequests().containsKey(containerId)) { Throwable t = response.getFailedRequests().get(containerId) .deSerialize(); parseAndThrowException(t); } } finally { if (proxy != null) { cmProxy.mayBeCloseProxy(proxy); } } }
Example #2
Source File: NMClientImpl.java From hadoop with Apache License 2.0 | 6 votes |
@Override public ContainerStatus getContainerStatus(ContainerId containerId, NodeId nodeId) throws YarnException, IOException { ContainerManagementProtocolProxyData proxy = null; List<ContainerId> containerIds = new ArrayList<ContainerId>(); containerIds.add(containerId); try { proxy = cmProxy.getProxy(nodeId.toString(), containerId); GetContainerStatusesResponse response = proxy.getContainerManagementProtocol().getContainerStatuses( GetContainerStatusesRequest.newInstance(containerIds)); if (response.getFailedRequests() != null && response.getFailedRequests().containsKey(containerId)) { Throwable t = response.getFailedRequests().get(containerId).deSerialize(); parseAndThrowException(t); } ContainerStatus containerStatus = response.getContainerStatuses().get(0); return containerStatus; } finally { if (proxy != null) { cmProxy.mayBeCloseProxy(proxy); } } }
Example #3
Source File: NMClientImpl.java From big-c with Apache License 2.0 | 6 votes |
@Override public ContainerStatus getContainerStatus(ContainerId containerId, NodeId nodeId) throws YarnException, IOException { ContainerManagementProtocolProxyData proxy = null; List<ContainerId> containerIds = new ArrayList<ContainerId>(); containerIds.add(containerId); try { proxy = cmProxy.getProxy(nodeId.toString(), containerId); GetContainerStatusesResponse response = proxy.getContainerManagementProtocol().getContainerStatuses( GetContainerStatusesRequest.newInstance(containerIds)); if (response.getFailedRequests() != null && response.getFailedRequests().containsKey(containerId)) { Throwable t = response.getFailedRequests().get(containerId).deSerialize(); parseAndThrowException(t); } ContainerStatus containerStatus = response.getContainerStatuses().get(0); return containerStatus; } finally { if (proxy != null) { cmProxy.mayBeCloseProxy(proxy); } } }
Example #4
Source File: NMClientImpl.java From big-c with Apache License 2.0 | 6 votes |
private void stopContainerInternal(ContainerId containerId, NodeId nodeId) throws IOException, YarnException { ContainerManagementProtocolProxyData proxy = null; List<ContainerId> containerIds = new ArrayList<ContainerId>(); containerIds.add(containerId); try { proxy = cmProxy.getProxy(nodeId.toString(), containerId); StopContainersResponse response = proxy.getContainerManagementProtocol().stopContainers( StopContainersRequest.newInstance(containerIds)); if (response.getFailedRequests() != null && response.getFailedRequests().containsKey(containerId)) { Throwable t = response.getFailedRequests().get(containerId) .deSerialize(); parseAndThrowException(t); } } finally { if (proxy != null) { cmProxy.mayBeCloseProxy(proxy); } } }
Example #5
Source File: TestContainerLauncher.java From hadoop with Apache License 2.0 | 5 votes |
@Override protected ContainerLauncher createContainerLauncher(final AppContext context) { return new ContainerLauncherImpl(context) { @Override public ContainerManagementProtocolProxyData getCMProxy( String containerMgrBindAddr, ContainerId containerId) throws IOException { InetSocketAddress addr = NetUtils.getConnectAddress(server); String containerManagerBindAddr = addr.getHostName() + ":" + addr.getPort(); Token token = tokenSecretManager.createNMToken( containerId.getApplicationAttemptId(), NodeId.newInstance(addr.getHostName(), addr.getPort()), "user"); ContainerManagementProtocolProxy cmProxy = new ContainerManagementProtocolProxy(conf); ContainerManagementProtocolProxyData proxy = cmProxy.new ContainerManagementProtocolProxyData( YarnRPC.create(conf), containerManagerBindAddr, containerId, token); return proxy; } }; }
Example #6
Source File: TestContainerLauncherImpl.java From hadoop with Apache License 2.0 | 5 votes |
@Override public ContainerManagementProtocolProxyData getCMProxy( String containerMgrBindAddr, ContainerId containerId) throws IOException { ContainerManagementProtocolProxyData protocolProxy = mock(ContainerManagementProtocolProxyData.class); when(protocolProxy.getContainerManagementProtocol()).thenReturn( containerManager); return protocolProxy; }
Example #7
Source File: TestFail.java From hadoop with Apache License 2.0 | 5 votes |
@Override protected ContainerLauncher createContainerLauncher(AppContext context) { return new ContainerLauncherImpl(context) { @Override public void handle(ContainerLauncherEvent event) { switch (event.getType()) { case CONTAINER_REMOTE_LAUNCH: super.handle(event); // Unused event and container. break; case CONTAINER_REMOTE_CLEANUP: getContext().getEventHandler().handle( new TaskAttemptEvent(event.getTaskAttemptID(), TaskAttemptEventType.TA_CONTAINER_CLEANED)); break; } } @Override public ContainerManagementProtocolProxyData getCMProxy( String containerMgrBindAddr, ContainerId containerId) throws IOException { try { synchronized (this) { wait(); // Just hang the thread simulating a very slow NM. } } catch (InterruptedException e) { e.printStackTrace(); } return null; } }; }
Example #8
Source File: TestContainerLauncher.java From big-c with Apache License 2.0 | 5 votes |
@Override protected ContainerLauncher createContainerLauncher(final AppContext context) { return new ContainerLauncherImpl(context) { @Override public ContainerManagementProtocolProxyData getCMProxy( String containerMgrBindAddr, ContainerId containerId) throws IOException { InetSocketAddress addr = NetUtils.getConnectAddress(server); String containerManagerBindAddr = addr.getHostName() + ":" + addr.getPort(); Token token = tokenSecretManager.createNMToken( containerId.getApplicationAttemptId(), NodeId.newInstance(addr.getHostName(), addr.getPort()), "user"); ContainerManagementProtocolProxy cmProxy = new ContainerManagementProtocolProxy(conf); ContainerManagementProtocolProxyData proxy = cmProxy.new ContainerManagementProtocolProxyData( YarnRPC.create(conf), containerManagerBindAddr, containerId, token); return proxy; } }; }
Example #9
Source File: TestContainerLauncherImpl.java From big-c with Apache License 2.0 | 5 votes |
@Override public ContainerManagementProtocolProxyData getCMProxy( String containerMgrBindAddr, ContainerId containerId) throws IOException { ContainerManagementProtocolProxyData protocolProxy = mock(ContainerManagementProtocolProxyData.class); when(protocolProxy.getContainerManagementProtocol()).thenReturn( containerManager); return protocolProxy; }
Example #10
Source File: TestFail.java From big-c with Apache License 2.0 | 5 votes |
@Override protected ContainerLauncher createContainerLauncher(AppContext context) { return new ContainerLauncherImpl(context) { @Override public void handle(ContainerLauncherEvent event) { switch (event.getType()) { case CONTAINER_REMOTE_LAUNCH: super.handle(event); // Unused event and container. break; case CONTAINER_REMOTE_CLEANUP: getContext().getEventHandler().handle( new TaskAttemptEvent(event.getTaskAttemptID(), TaskAttemptEventType.TA_CONTAINER_CLEANED)); break; } } @Override public ContainerManagementProtocolProxyData getCMProxy( String containerMgrBindAddr, ContainerId containerId) throws IOException { try { synchronized (this) { wait(); // Just hang the thread simulating a very slow NM. } } catch (InterruptedException e) { e.printStackTrace(); } return null; } }; }
Example #11
Source File: TezContainerLauncherImpl.java From tez with Apache License 2.0 | 4 votes |
protected ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData getCMProxy( ContainerId containerID, final String containerManagerBindAddr, Token containerToken) throws IOException { return cmProxy.getProxy(containerManagerBindAddr, containerID); }
Example #12
Source File: TezContainerLauncherImpl.java From tez with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public synchronized void kill() { if(isCompletelyDone()) { return; } if(this.state == ContainerState.PREP) { this.state = ContainerState.KILLED_BEFORE_LAUNCH; } else { LOG.info("Stopping " + containerID); ContainerManagementProtocolProxyData proxy = null; try { proxy = getCMProxy(this.containerID, this.containerMgrAddress, this.containerToken); // kill the remote container if already launched StopContainersRequest stopRequest = Records .newRecord(StopContainersRequest.class); stopRequest.setContainerIds(Collections.singletonList(containerID)); proxy.getContainerManagementProtocol().stopContainers(stopRequest); // If stopContainer returns without an error, assuming the stop made // it over to the NodeManager. getContext().containerStopRequested(containerID); } catch (Throwable t) { // ignore the cleanup failure String message = "cleanup failed for container " + this.containerID + " : " + ExceptionUtils.getStackTrace(t); getContext().containerStopFailed(containerID, message); LOG.warn(message); this.state = ContainerState.DONE; return; } finally { if (proxy != null) { cmProxy.mayBeCloseProxy(proxy); } } this.state = ContainerState.DONE; } }
Example #13
Source File: TezContainerLauncherImpl.java From tez with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public synchronized void launch(ContainerLaunchRequest event) { LOG.info("Launching " + event.getContainerId()); if(this.state == ContainerState.KILLED_BEFORE_LAUNCH) { state = ContainerState.DONE; sendContainerLaunchFailedMsg(event.getContainerId(), "Container was killed before it was launched"); return; } ContainerManagementProtocolProxyData proxy = null; try { proxy = getCMProxy(containerID, containerMgrAddress, containerToken); // Construct the actual Container ContainerLaunchContext containerLaunchContext = event.getContainerLaunchContext(); // Now launch the actual container StartContainerRequest startRequest = Records .newRecord(StartContainerRequest.class); startRequest.setContainerToken(event.getContainerToken()); startRequest.setContainerLaunchContext(containerLaunchContext); StartContainersResponse response = proxy.getContainerManagementProtocol().startContainers( StartContainersRequest.newInstance( Collections.singletonList(startRequest))); if (response.getFailedRequests() != null && !response.getFailedRequests().isEmpty()) { throw response.getFailedRequests().get(containerID).deSerialize(); } // after launching, send launched event to task attempt to move // it from ASSIGNED to RUNNING state getContext().containerLaunched(containerID); this.state = ContainerState.RUNNING; int shufflePort = TezRuntimeUtils.INVALID_PORT; Map<String, java.nio.ByteBuffer> servicesMetaData = response.getAllServicesMetaData(); if (servicesMetaData != null) { String auxiliaryService = conf.get(TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID, TezConfiguration.TEZ_AM_SHUFFLE_AUXILIARY_SERVICE_ID_DEFAULT); ByteBuffer portInfo = servicesMetaData.get(auxiliaryService); if (portInfo != null) { DataInputByteBuffer in = new DataInputByteBuffer(); in.reset(portInfo); shufflePort = in.readInt(); } else { LOG.warn("Shuffle port for {} is not present is the services metadata response", auxiliaryService); } } else { LOG.warn("Shuffle port cannot be found since services metadata response is missing"); } if (deletionTracker != null) { deletionTracker.addNodeShufflePort(event.getNodeId(), shufflePort); } } catch (Throwable t) { String message = "Container launch failed for " + containerID + " : " + ExceptionUtils.getStackTrace(t); this.state = ContainerState.FAILED; sendContainerLaunchFailedMsg(containerID, message); } finally { if (proxy != null) { cmProxy.mayBeCloseProxy(proxy); } } }
Example #14
Source File: ContainerLauncherImpl.java From incubator-tez with Apache License 2.0 | 4 votes |
protected ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData getCMProxy( ContainerId containerID, final String containerManagerBindAddr, Token containerToken) throws IOException { return cmProxy.getProxy(containerManagerBindAddr, containerID); }
Example #15
Source File: ContainerLauncherImpl.java From incubator-tez with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public synchronized void kill() { if(isCompletelyDone()) { return; } if(this.state == ContainerState.PREP) { this.state = ContainerState.KILLED_BEFORE_LAUNCH; } else { LOG.info("Sending a stop request to the NM for ContainerId: " + containerID); ContainerManagementProtocolProxyData proxy = null; try { proxy = getCMProxy(this.containerID, this.containerMgrAddress, this.containerToken); // kill the remote container if already launched StopContainersRequest stopRequest = Records .newRecord(StopContainersRequest.class); stopRequest.setContainerIds(Collections.singletonList(containerID)); proxy.getContainerManagementProtocol().stopContainers(stopRequest); // 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)); } 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) { cmProxy.mayBeCloseProxy(proxy); } } this.state = ContainerState.DONE; } }
Example #16
Source File: ContainerLauncherImpl.java From incubator-tez with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public synchronized void launch(NMCommunicatorLaunchRequestEvent event) { LOG.info("Launching Container with Id: " + event.getContainerId()); if(this.state == ContainerState.KILLED_BEFORE_LAUNCH) { state = ContainerState.DONE; sendContainerLaunchFailedMsg(event.getContainerId(), "Container was killed before it was launched"); return; } ContainerManagementProtocolProxyData proxy = null; try { proxy = getCMProxy(containerID, containerMgrAddress, containerToken); // Construct the actual Container ContainerLaunchContext containerLaunchContext = event.getContainerLaunchContext(); // Now launch the actual container StartContainerRequest startRequest = Records .newRecord(StartContainerRequest.class); startRequest.setContainerToken(event.getContainerToken()); startRequest.setContainerLaunchContext(containerLaunchContext); StartContainersResponse response = proxy.getContainerManagementProtocol().startContainers( StartContainersRequest.newInstance( Collections.singletonList(startRequest))); if (response.getFailedRequests() != null && !response.getFailedRequests().isEmpty()) { throw response.getFailedRequests().get(containerID).deSerialize(); } // after launching, send launched event to task attempt to move // it from ASSIGNED to RUNNING state context.getEventHandler().handle( new AMContainerEventLaunched(containerID)); ContainerLaunchedEvent lEvt = new ContainerLaunchedEvent( containerID, clock.getTime(), context.getApplicationAttemptId()); context.getHistoryHandler().handle(new DAGHistoryEvent( null, lEvt)); this.state = ContainerState.RUNNING; } catch (Throwable t) { String message = "Container launch failed for " + containerID + " : " + StringUtils.stringifyException(t); this.state = ContainerState.FAILED; sendContainerLaunchFailedMsg(containerID, message); } finally { if (proxy != null) { cmProxy.mayBeCloseProxy(proxy); } } }
Example #17
Source File: ContainerLauncherImpl.java From big-c with Apache License 2.0 | 4 votes |
public ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData getCMProxy(String containerMgrBindAddr, ContainerId containerId) throws IOException { return cmProxy.getProxy(containerMgrBindAddr, containerId); }
Example #18
Source File: ContainerLauncherImpl.java From big-c with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public synchronized void kill() { if(this.state == ContainerState.PREP) { this.state = ContainerState.KILLED_BEFORE_LAUNCH; } else if (!isCompletelyDone()) { LOG.info("KILLING " + taskAttemptID); ContainerManagementProtocolProxyData proxy = null; try { proxy = getCMProxy(this.containerMgrAddress, this.containerID); // kill the remote container if already launched List<ContainerId> ids = new ArrayList<ContainerId>(); ids.add(this.containerID); StopContainersRequest request = StopContainersRequest.newInstance(ids); StopContainersResponse response = proxy.getContainerManagementProtocol().stopContainers(request); if (response.getFailedRequests() != null && response.getFailedRequests().containsKey(this.containerID)) { throw response.getFailedRequests().get(this.containerID) .deSerialize(); } } catch (Throwable t) { // ignore the cleanup failure String message = "cleanup failed for container " + this.containerID + " : " + StringUtils.stringifyException(t); context.getEventHandler() .handle( new TaskAttemptDiagnosticsUpdateEvent(this.taskAttemptID, message)); LOG.warn(message); } finally { if (proxy != null) { cmProxy.mayBeCloseProxy(proxy); } } this.state = ContainerState.DONE; } // after killing, send killed event to task attempt context.getEventHandler().handle( new TaskAttemptEvent(this.taskAttemptID, TaskAttemptEventType.TA_CONTAINER_CLEANED)); }
Example #19
Source File: ContainerLauncherImpl.java From big-c with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public synchronized void launch(ContainerRemoteLaunchEvent event) { LOG.info("Launching " + taskAttemptID); if(this.state == ContainerState.KILLED_BEFORE_LAUNCH) { state = ContainerState.DONE; sendContainerLaunchFailedMsg(taskAttemptID, "Container was killed before it was launched"); return; } ContainerManagementProtocolProxyData proxy = null; try { proxy = getCMProxy(containerMgrAddress, containerID); // Construct the actual Container ContainerLaunchContext containerLaunchContext = event.getContainerLaunchContext(); // Now launch the actual container StartContainerRequest startRequest = StartContainerRequest.newInstance(containerLaunchContext, event.getContainerToken()); List<StartContainerRequest> list = new ArrayList<StartContainerRequest>(); list.add(startRequest); StartContainersRequest requestList = StartContainersRequest.newInstance(list); StartContainersResponse response = proxy.getContainerManagementProtocol().startContainers(requestList); if (response.getFailedRequests() != null && response.getFailedRequests().containsKey(containerID)) { throw response.getFailedRequests().get(containerID).deSerialize(); } ByteBuffer portInfo = response.getAllServicesMetaData().get( ShuffleHandler.MAPREDUCE_SHUFFLE_SERVICEID); int port = -1; if(portInfo != null) { port = ShuffleHandler.deserializeMetaData(portInfo); } LOG.info("Shuffle port returned by ContainerManager for " + taskAttemptID + " : " + port); if(port < 0) { this.state = ContainerState.FAILED; throw new IllegalStateException("Invalid shuffle port number " + port + " returned for " + taskAttemptID); } // after launching, send launched event to task attempt to move // it from ASSIGNED to RUNNING state context.getEventHandler().handle( new TaskAttemptContainerLaunchedEvent(taskAttemptID, port)); this.state = ContainerState.RUNNING; } catch (Throwable t) { String message = "Container launch failed for " + containerID + " : " + StringUtils.stringifyException(t); this.state = ContainerState.FAILED; sendContainerLaunchFailedMsg(taskAttemptID, message); } finally { if (proxy != null) { cmProxy.mayBeCloseProxy(proxy); } } }
Example #20
Source File: ContainerLauncherImpl.java From hadoop with Apache License 2.0 | 4 votes |
public ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData getCMProxy(String containerMgrBindAddr, ContainerId containerId) throws IOException { return cmProxy.getProxy(containerMgrBindAddr, containerId); }
Example #21
Source File: ContainerLauncherImpl.java From hadoop with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public synchronized void kill() { if(this.state == ContainerState.PREP) { this.state = ContainerState.KILLED_BEFORE_LAUNCH; } else if (!isCompletelyDone()) { LOG.info("KILLING " + taskAttemptID); ContainerManagementProtocolProxyData proxy = null; try { proxy = getCMProxy(this.containerMgrAddress, this.containerID); // kill the remote container if already launched List<ContainerId> ids = new ArrayList<ContainerId>(); ids.add(this.containerID); StopContainersRequest request = StopContainersRequest.newInstance(ids); StopContainersResponse response = proxy.getContainerManagementProtocol().stopContainers(request); if (response.getFailedRequests() != null && response.getFailedRequests().containsKey(this.containerID)) { throw response.getFailedRequests().get(this.containerID) .deSerialize(); } } catch (Throwable t) { // ignore the cleanup failure String message = "cleanup failed for container " + this.containerID + " : " + StringUtils.stringifyException(t); context.getEventHandler() .handle( new TaskAttemptDiagnosticsUpdateEvent(this.taskAttemptID, message)); LOG.warn(message); } finally { if (proxy != null) { cmProxy.mayBeCloseProxy(proxy); } } this.state = ContainerState.DONE; } // after killing, send killed event to task attempt context.getEventHandler().handle( new TaskAttemptEvent(this.taskAttemptID, TaskAttemptEventType.TA_CONTAINER_CLEANED)); }
Example #22
Source File: ContainerLauncherImpl.java From hadoop with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public synchronized void launch(ContainerRemoteLaunchEvent event) { LOG.info("Launching " + taskAttemptID); if(this.state == ContainerState.KILLED_BEFORE_LAUNCH) { state = ContainerState.DONE; sendContainerLaunchFailedMsg(taskAttemptID, "Container was killed before it was launched"); return; } ContainerManagementProtocolProxyData proxy = null; try { proxy = getCMProxy(containerMgrAddress, containerID); // Construct the actual Container ContainerLaunchContext containerLaunchContext = event.getContainerLaunchContext(); // Now launch the actual container StartContainerRequest startRequest = StartContainerRequest.newInstance(containerLaunchContext, event.getContainerToken()); List<StartContainerRequest> list = new ArrayList<StartContainerRequest>(); list.add(startRequest); StartContainersRequest requestList = StartContainersRequest.newInstance(list); StartContainersResponse response = proxy.getContainerManagementProtocol().startContainers(requestList); if (response.getFailedRequests() != null && response.getFailedRequests().containsKey(containerID)) { throw response.getFailedRequests().get(containerID).deSerialize(); } ByteBuffer portInfo = response.getAllServicesMetaData().get( ShuffleHandler.MAPREDUCE_SHUFFLE_SERVICEID); int port = -1; if(portInfo != null) { port = ShuffleHandler.deserializeMetaData(portInfo); } LOG.info("Shuffle port returned by ContainerManager for " + taskAttemptID + " : " + port); if(port < 0) { this.state = ContainerState.FAILED; throw new IllegalStateException("Invalid shuffle port number " + port + " returned for " + taskAttemptID); } // after launching, send launched event to task attempt to move // it from ASSIGNED to RUNNING state context.getEventHandler().handle( new TaskAttemptContainerLaunchedEvent(taskAttemptID, port)); this.state = ContainerState.RUNNING; } catch (Throwable t) { String message = "Container launch failed for " + containerID + " : " + StringUtils.stringifyException(t); this.state = ContainerState.FAILED; sendContainerLaunchFailedMsg(taskAttemptID, message); } finally { if (proxy != null) { cmProxy.mayBeCloseProxy(proxy); } } }