use of org.apache.hadoop.yarn.api.records.SerializedException in project hadoop by apache.
the class TestPBRecordImpl method testSerializedExceptionDeSer.
@Test(timeout = 10000)
public void testSerializedExceptionDeSer() throws Exception {
// without cause
YarnException yarnEx = new YarnException("Yarn_Exception");
SerializedException serEx = SerializedException.newInstance(yarnEx);
Throwable throwable = serEx.deSerialize();
Assert.assertEquals(yarnEx.getClass(), throwable.getClass());
Assert.assertEquals(yarnEx.getMessage(), throwable.getMessage());
// with cause
IOException ioe = new IOException("Test_IOException");
RuntimeException runtimeException = new RuntimeException("Test_RuntimeException", ioe);
YarnException yarnEx2 = new YarnException("Test_YarnException", runtimeException);
SerializedException serEx2 = SerializedException.newInstance(yarnEx2);
Throwable throwable2 = serEx2.deSerialize();
throwable2.printStackTrace();
Assert.assertEquals(yarnEx2.getClass(), throwable2.getClass());
Assert.assertEquals(yarnEx2.getMessage(), throwable2.getMessage());
Assert.assertEquals(runtimeException.getClass(), throwable2.getCause().getClass());
Assert.assertEquals(runtimeException.getMessage(), throwable2.getCause().getMessage());
Assert.assertEquals(ioe.getClass(), throwable2.getCause().getCause().getClass());
Assert.assertEquals(ioe.getMessage(), throwable2.getCause().getCause().getMessage());
}
use of org.apache.hadoop.yarn.api.records.SerializedException in project hadoop by apache.
the class TestContainerManagerSecurity method startContainer.
private void startContainer(final YarnRPC rpc, org.apache.hadoop.yarn.api.records.Token nmToken, org.apache.hadoop.yarn.api.records.Token containerToken, NodeId nodeId, String user) throws Exception {
ContainerLaunchContext context = Records.newRecord(ContainerLaunchContext.class);
StartContainerRequest scRequest = StartContainerRequest.newInstance(context, containerToken);
List<StartContainerRequest> list = new ArrayList<StartContainerRequest>();
list.add(scRequest);
StartContainersRequest allRequests = StartContainersRequest.newInstance(list);
ContainerManagementProtocol proxy = null;
try {
proxy = getContainerManagementProtocolProxy(rpc, nmToken, nodeId, user);
StartContainersResponse response = proxy.startContainers(allRequests);
for (SerializedException ex : response.getFailedRequests().values()) {
parseAndThrowException(ex.deSerialize());
}
} finally {
if (proxy != null) {
rpc.stopProxy(proxy, conf);
}
}
}
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