use of org.apache.hadoop.yarn.client.api.impl.ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData in project hadoop by apache.
the class NMClientImpl method increaseContainerResource.
@Override
public void increaseContainerResource(Container container) throws YarnException, IOException {
ContainerManagementProtocolProxyData proxy = null;
try {
proxy = cmProxy.getProxy(container.getNodeId().toString(), container.getId());
List<Token> increaseTokens = new ArrayList<>();
increaseTokens.add(container.getContainerToken());
IncreaseContainersResourceRequest increaseRequest = IncreaseContainersResourceRequest.newInstance(increaseTokens);
IncreaseContainersResourceResponse response = proxy.getContainerManagementProtocol().increaseContainersResource(increaseRequest);
if (response.getFailedRequests() != null && response.getFailedRequests().containsKey(container.getId())) {
Throwable t = response.getFailedRequests().get(container.getId()).deSerialize();
parseAndThrowException(t);
}
} finally {
if (proxy != null) {
cmProxy.mayBeCloseProxy(proxy);
}
}
}
use of org.apache.hadoop.yarn.client.api.impl.ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData in project hadoop by apache.
the class NMClientImpl method getContainerStatus.
@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);
}
}
}
use of org.apache.hadoop.yarn.client.api.impl.ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData in project hadoop by apache.
the class NMClientImpl method startContainer.
@Override
public Map<String, ByteBuffer> startContainer(Container container, ContainerLaunchContext containerLaunchContext) throws YarnException, IOException {
// Do synchronization on StartedContainer to prevent race condition
// between startContainer and stopContainer only when startContainer is
// in progress for a given container.
StartedContainer startingContainer = new StartedContainer(container.getId(), container.getNodeId());
synchronized (startingContainer) {
addStartingContainer(startingContainer);
Map<String, ByteBuffer> allServiceResponse;
ContainerManagementProtocolProxyData proxy = null;
try {
proxy = cmProxy.getProxy(container.getNodeId().toString(), container.getId());
StartContainerRequest scRequest = StartContainerRequest.newInstance(containerLaunchContext, container.getContainerToken());
List<StartContainerRequest> list = new ArrayList<StartContainerRequest>();
list.add(scRequest);
StartContainersRequest allRequests = StartContainersRequest.newInstance(list);
StartContainersResponse response = proxy.getContainerManagementProtocol().startContainers(allRequests);
if (response.getFailedRequests() != null && response.getFailedRequests().containsKey(container.getId())) {
Throwable t = response.getFailedRequests().get(container.getId()).deSerialize();
parseAndThrowException(t);
}
allServiceResponse = response.getAllServicesMetaData();
startingContainer.state = ContainerState.RUNNING;
} catch (YarnException | IOException e) {
startingContainer.state = ContainerState.COMPLETE;
// Remove the started container if it failed to start
startedContainers.remove(startingContainer.containerId);
throw e;
} catch (Throwable t) {
startingContainer.state = ContainerState.COMPLETE;
startedContainers.remove(startingContainer.containerId);
throw RPCUtil.getRemoteException(t);
} finally {
if (proxy != null) {
cmProxy.mayBeCloseProxy(proxy);
}
}
return allServiceResponse;
}
}
use of org.apache.hadoop.yarn.client.api.impl.ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData in project hadoop by apache.
the class NMClientImpl method stopContainerInternal.
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);
}
}
}
Aggregations