use of org.apache.hadoop.yarn.api.records.SerializedException in project hadoop by apache.
the class TestContainerManager method testMultipleContainersLaunch.
@Test
public void testMultipleContainersLaunch() throws Exception {
containerManager.start();
List<StartContainerRequest> list = new ArrayList<>();
ContainerLaunchContext containerLaunchContext = recordFactory.newRecordInstance(ContainerLaunchContext.class);
for (int i = 0; i < 10; i++) {
ContainerId cId = createContainerId(i);
long identifier = 0;
if ((i & 1) == 0)
// container with even id fail
identifier = ResourceManagerConstants.RM_INVALID_IDENTIFIER;
else
identifier = DUMMY_RM_IDENTIFIER;
Token containerToken = createContainerToken(cId, identifier, context.getNodeId(), user, context.getContainerTokenSecretManager());
StartContainerRequest request = StartContainerRequest.newInstance(containerLaunchContext, containerToken);
list.add(request);
}
StartContainersRequest requestList = StartContainersRequest.newInstance(list);
StartContainersResponse response = containerManager.startContainers(requestList);
Thread.sleep(5000);
Assert.assertEquals(5, response.getSuccessfullyStartedContainers().size());
for (ContainerId id : response.getSuccessfullyStartedContainers()) {
// Containers with odd id should succeed.
Assert.assertEquals(1, id.getContainerId() & 1);
}
Assert.assertEquals(5, response.getFailedRequests().size());
for (Map.Entry<ContainerId, SerializedException> entry : response.getFailedRequests().entrySet()) {
// Containers with even id should fail.
Assert.assertEquals(0, entry.getKey().getContainerId() & 1);
Assert.assertTrue(entry.getValue().getMessage().contains("Container " + entry.getKey() + " rejected as it is allocated by a previous RM"));
}
}
use of org.apache.hadoop.yarn.api.records.SerializedException in project hadoop by apache.
the class TestContainerManager method testMultipleContainersStopAndGetStatus.
@Test
public void testMultipleContainersStopAndGetStatus() throws Exception {
containerManager.start();
List<StartContainerRequest> startRequest = new ArrayList<>();
ContainerLaunchContext containerLaunchContext = recordFactory.newRecordInstance(ContainerLaunchContext.class);
List<ContainerId> containerIds = new ArrayList<>();
for (int i = 0; i < 10; i++) {
ContainerId cId;
if ((i & 1) == 0) {
// Containers with even id belong to an unauthorized app
cId = createContainerId(i, 1);
} else {
cId = createContainerId(i, 0);
}
Token containerToken = createContainerToken(cId, DUMMY_RM_IDENTIFIER, context.getNodeId(), user, context.getContainerTokenSecretManager());
StartContainerRequest request = StartContainerRequest.newInstance(containerLaunchContext, containerToken);
startRequest.add(request);
containerIds.add(cId);
}
// start containers
StartContainersRequest requestList = StartContainersRequest.newInstance(startRequest);
containerManager.startContainers(requestList);
Thread.sleep(5000);
// Get container statuses
GetContainerStatusesRequest statusRequest = GetContainerStatusesRequest.newInstance(containerIds);
GetContainerStatusesResponse statusResponse = containerManager.getContainerStatuses(statusRequest);
Assert.assertEquals(5, statusResponse.getContainerStatuses().size());
for (ContainerStatus status : statusResponse.getContainerStatuses()) {
// Containers with odd id should succeed
Assert.assertEquals(1, status.getContainerId().getContainerId() & 1);
}
Assert.assertEquals(5, statusResponse.getFailedRequests().size());
for (Map.Entry<ContainerId, SerializedException> entry : statusResponse.getFailedRequests().entrySet()) {
// Containers with even id should fail.
Assert.assertEquals(0, entry.getKey().getContainerId() & 1);
Assert.assertTrue(entry.getValue().getMessage().contains("attempted to get status for non-application container"));
}
// stop containers
StopContainersRequest stopRequest = StopContainersRequest.newInstance(containerIds);
StopContainersResponse stopResponse = containerManager.stopContainers(stopRequest);
Assert.assertEquals(5, stopResponse.getSuccessfullyStoppedContainers().size());
for (ContainerId id : stopResponse.getSuccessfullyStoppedContainers()) {
// Containers with odd id should succeed.
Assert.assertEquals(1, id.getContainerId() & 1);
}
Assert.assertEquals(5, stopResponse.getFailedRequests().size());
for (Map.Entry<ContainerId, SerializedException> entry : stopResponse.getFailedRequests().entrySet()) {
// Containers with even id should fail.
Assert.assertEquals(0, entry.getKey().getContainerId() & 1);
Assert.assertTrue(entry.getValue().getMessage().contains("attempted to stop non-application container"));
}
}
use of org.apache.hadoop.yarn.api.records.SerializedException in project hadoop by apache.
the class GetContainerStatusesResponsePBImpl method initFailedRequests.
private void initFailedRequests() {
if (this.failedRequests != null) {
return;
}
GetContainerStatusesResponseProtoOrBuilder p = viaProto ? proto : builder;
List<ContainerExceptionMapProto> protoList = p.getFailedRequestsList();
this.failedRequests = new HashMap<ContainerId, SerializedException>();
for (ContainerExceptionMapProto ce : protoList) {
this.failedRequests.put(convertFromProtoFormat(ce.getContainerId()), convertFromProtoFormat(ce.getException()));
}
}
use of org.apache.hadoop.yarn.api.records.SerializedException in project hadoop by apache.
the class StartContainersResponsePBImpl method initFailedContainers.
private void initFailedContainers() {
if (this.failedContainers != null) {
return;
}
StartContainersResponseProtoOrBuilder p = viaProto ? proto : builder;
List<ContainerExceptionMapProto> protoList = p.getFailedRequestsList();
this.failedContainers = new HashMap<ContainerId, SerializedException>();
for (ContainerExceptionMapProto ce : protoList) {
this.failedContainers.put(convertFromProtoFormat(ce.getContainerId()), convertFromProtoFormat(ce.getException()));
}
}
use of org.apache.hadoop.yarn.api.records.SerializedException in project hadoop by apache.
the class IncreaseContainersResourceResponsePBImpl method initFailedRequests.
private void initFailedRequests() {
if (this.failedRequests != null) {
return;
}
IncreaseContainersResourceResponseProtoOrBuilder p = viaProto ? proto : builder;
List<ContainerExceptionMapProto> protoList = p.getFailedRequestsList();
this.failedRequests = new HashMap<ContainerId, SerializedException>();
for (ContainerExceptionMapProto ce : protoList) {
this.failedRequests.put(convertFromProtoFormat(ce.getContainerId()), convertFromProtoFormat(ce.getException()));
}
}
Aggregations