Search in sources :

Example 6 with SerializedException

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());
}
Also used : SerializedException(org.apache.hadoop.yarn.api.records.SerializedException) IOException(java.io.IOException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) Test(org.junit.Test)

Example 7 with SerializedException

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);
        }
    }
}
Also used : StartContainersRequest(org.apache.hadoop.yarn.api.protocolrecords.StartContainersRequest) ContainerManagementProtocol(org.apache.hadoop.yarn.api.ContainerManagementProtocol) StartContainersResponse(org.apache.hadoop.yarn.api.protocolrecords.StartContainersResponse) SerializedException(org.apache.hadoop.yarn.api.records.SerializedException) ArrayList(java.util.ArrayList) ContainerLaunchContext(org.apache.hadoop.yarn.api.records.ContainerLaunchContext) StartContainerRequest(org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest)

Example 8 with SerializedException

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()));
    }
}
Also used : ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) GetContainerStatusesResponseProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnServiceProtos.GetContainerStatusesResponseProtoOrBuilder) ContainerExceptionMapProto(org.apache.hadoop.yarn.proto.YarnServiceProtos.ContainerExceptionMapProto) SerializedException(org.apache.hadoop.yarn.api.records.SerializedException)

Example 9 with SerializedException

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()));
    }
}
Also used : ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) StartContainersResponseProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnServiceProtos.StartContainersResponseProtoOrBuilder) ContainerExceptionMapProto(org.apache.hadoop.yarn.proto.YarnServiceProtos.ContainerExceptionMapProto) SerializedException(org.apache.hadoop.yarn.api.records.SerializedException)

Example 10 with SerializedException

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()));
    }
}
Also used : ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) IncreaseContainersResourceResponseProtoOrBuilder(org.apache.hadoop.yarn.proto.YarnServiceProtos.IncreaseContainersResourceResponseProtoOrBuilder) ContainerExceptionMapProto(org.apache.hadoop.yarn.proto.YarnServiceProtos.ContainerExceptionMapProto) SerializedException(org.apache.hadoop.yarn.api.records.SerializedException)

Aggregations

SerializedException (org.apache.hadoop.yarn.api.records.SerializedException)15 ContainerId (org.apache.hadoop.yarn.api.records.ContainerId)12 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)8 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)7 StartContainerRequest (org.apache.hadoop.yarn.api.protocolrecords.StartContainerRequest)6 StartContainersRequest (org.apache.hadoop.yarn.api.protocolrecords.StartContainersRequest)5 ContainerLaunchContext (org.apache.hadoop.yarn.api.records.ContainerLaunchContext)5 Test (org.junit.Test)5 IOException (java.io.IOException)4 Map (java.util.Map)4 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)4 Token (org.apache.hadoop.yarn.api.records.Token)4 ContainerExceptionMapProto (org.apache.hadoop.yarn.proto.YarnServiceProtos.ContainerExceptionMapProto)4 NMTokenIdentifier (org.apache.hadoop.yarn.security.NMTokenIdentifier)4 StartContainersResponse (org.apache.hadoop.yarn.api.protocolrecords.StartContainersResponse)3 InvalidToken (org.apache.hadoop.security.token.SecretManager.InvalidToken)2 IncreaseContainersResourceRequest (org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceRequest)2 IncreaseContainersResourceResponse (org.apache.hadoop.yarn.api.protocolrecords.IncreaseContainersResourceResponse)2 ContainerStatus (org.apache.hadoop.yarn.api.records.ContainerStatus)2