use of org.apache.hadoop.yarn.api.records.ContainerStatus in project hadoop by apache.
the class ContainerManagerImpl method getContainerStatuses.
/**
* Get a list of container statuses running on this NodeManager
*/
@Override
public GetContainerStatusesResponse getContainerStatuses(GetContainerStatusesRequest request) throws YarnException, IOException {
List<ContainerStatus> succeededRequests = new ArrayList<ContainerStatus>();
Map<ContainerId, SerializedException> failedRequests = new HashMap<ContainerId, SerializedException>();
UserGroupInformation remoteUgi = getRemoteUgi();
NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
if (identifier == null) {
throw RPCUtil.getRemoteException(INVALID_NMTOKEN_MSG);
}
for (ContainerId id : request.getContainerIds()) {
try {
ContainerStatus status = getContainerStatusInternal(id, identifier);
succeededRequests.add(status);
} catch (YarnException e) {
failedRequests.put(id, SerializedException.newInstance(e));
}
}
return GetContainerStatusesResponse.newInstance(succeededRequests, failedRequests);
}
use of org.apache.hadoop.yarn.api.records.ContainerStatus in project hadoop by apache.
the class ContainerImpl method sendFinishedEvents.
@SuppressWarnings("unchecked")
private void sendFinishedEvents() {
// Inform the application
@SuppressWarnings("rawtypes") EventHandler eventHandler = dispatcher.getEventHandler();
ContainerStatus containerStatus = cloneAndGetContainerStatus();
eventHandler.handle(new ApplicationContainerFinishedEvent(containerStatus));
// Tell the scheduler the container is Done
eventHandler.handle(new ContainerSchedulerEvent(this, ContainerSchedulerEventType.CONTAINER_COMPLETED));
// Remove the container from the resource-monitor
eventHandler.handle(new ContainerStopMonitoringEvent(containerId));
// Tell the logService too
eventHandler.handle(new LogHandlerContainerFinishedEvent(containerId, exitCode));
}
use of org.apache.hadoop.yarn.api.records.ContainerStatus in project hadoop by apache.
the class NodeManager method getContainerStatuses.
@Override
public synchronized GetContainerStatusesResponse getContainerStatuses(GetContainerStatusesRequest request) throws YarnException {
List<ContainerStatus> statuses = new ArrayList<ContainerStatus>();
for (ContainerId containerId : request.getContainerIds()) {
List<Container> appContainers = containers.get(containerId.getApplicationAttemptId().getApplicationId());
Container container = null;
for (Container c : appContainers) {
if (c.getId().equals(containerId)) {
container = c;
}
}
if (container != null && containerStatusMap.get(container).getState() != null) {
statuses.add(containerStatusMap.get(container));
}
}
return GetContainerStatusesResponse.newInstance(statuses, null);
}
use of org.apache.hadoop.yarn.api.records.ContainerStatus in project hadoop by apache.
the class NodeManager method startContainers.
@Override
public synchronized StartContainersResponse startContainers(StartContainersRequest requests) throws YarnException {
for (StartContainerRequest request : requests.getStartContainerRequests()) {
Token containerToken = request.getContainerToken();
ContainerTokenIdentifier tokenId = null;
try {
tokenId = BuilderUtils.newContainerTokenIdentifier(containerToken);
} catch (IOException e) {
throw RPCUtil.getRemoteException(e);
}
ContainerId containerID = tokenId.getContainerID();
ApplicationId applicationId = containerID.getApplicationAttemptId().getApplicationId();
List<Container> applicationContainers = containers.get(applicationId);
if (applicationContainers == null) {
applicationContainers = new ArrayList<Container>();
containers.put(applicationId, applicationContainers);
}
// Sanity check
for (Container container : applicationContainers) {
if (container.getId().compareTo(containerID) == 0) {
throw new IllegalStateException("Container " + containerID + " already setup on node " + containerManagerAddress);
}
}
Container container = BuilderUtils.newContainer(containerID, this.nodeId, nodeHttpAddress, // DKDC - Doesn't matter
tokenId.getResource(), // DKDC - Doesn't matter
null, // DKDC - Doesn't matter
null);
ContainerStatus containerStatus = BuilderUtils.newContainerStatus(container.getId(), ContainerState.NEW, "", -1000, container.getResource());
applicationContainers.add(container);
containerStatusMap.put(container, containerStatus);
Resources.subtractFrom(available, tokenId.getResource());
Resources.addTo(used, tokenId.getResource());
if (LOG.isDebugEnabled()) {
LOG.debug("startContainer:" + " node=" + containerManagerAddress + " application=" + applicationId + " container=" + container + " available=" + available + " used=" + used);
}
}
StartContainersResponse response = StartContainersResponse.newInstance(null, null, null);
return response;
}
use of org.apache.hadoop.yarn.api.records.ContainerStatus in project hadoop by apache.
the class MockNM method containerIncreaseStatus.
public void containerIncreaseStatus(Container container) throws Exception {
ContainerStatus containerStatus = BuilderUtils.newContainerStatus(container.getId(), ContainerState.RUNNING, "Success", 0, container.getResource());
List<Container> increasedConts = Collections.singletonList(container);
nodeHeartbeat(Collections.singletonList(containerStatus), increasedConts, true, ++responseId);
}
Aggregations