From 9eb53b9c841233538a51e4e854b261536c0b85d4 Mon Sep 17 00:00:00 2001 From: Vinod Kumar Vavilapalli Date: Tue, 7 May 2013 00:42:48 +0000 Subject: [PATCH] YARN-632. Changed ContainerManager api to throw IOException and YarnRemoteException. Contributed by Xuan Gong. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1479740 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../org/apache/hadoop/yarn/api/ContainerManager.java | 12 +++++++++--- .../distributedshell/ApplicationMaster.java | 4 ++++ .../pb/service/ContainerManagerPBServiceImpl.java | 8 ++++++++ .../containermanager/ContainerManagerImpl.java | 7 ++++--- .../server/nodemanager/TestNodeManagerResync.java | 2 ++ .../containermanager/BaseContainerManagerTest.java | 4 ++-- .../yarn/server/TestContainerManagerSecurity.java | 9 +++++++++ 8 files changed, 41 insertions(+), 8 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 66e5322477..5a2a63363c 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -112,6 +112,9 @@ Release 2.0.5-beta - UNRELEASED YARN-633. Changed RMAdminProtocol api to throw IOException and YarnRemoteException. (Xuan Gong via vinodkv) + YARN-632. Changed ContainerManager api to throw IOException and + YarnRemoteException. (Xuan Gong via vinodkv) + NEW FEATURES YARN-482. FS: Extend SchedulingMode to intermediate queues. diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ContainerManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ContainerManager.java index 0bb559a9fc..0961ac4e4d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ContainerManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/ContainerManager.java @@ -18,6 +18,8 @@ package org.apache.hadoop.yarn.api; +import java.io.IOException; + import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceStability.Stable; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusRequest; @@ -68,11 +70,12 @@ public interface ContainerManager { * @return empty response to indicate acceptance of the request * or an exception * @throws YarnRemoteException + * @throws IOException */ @Public @Stable StartContainerResponse startContainer(StartContainerRequest request) - throws YarnRemoteException; + throws YarnRemoteException, IOException; /** *

The ApplicationMaster requests a NodeManager @@ -94,11 +97,12 @@ StartContainerResponse startContainer(StartContainerRequest request) * @return empty response to indicate acceptance of the request * or an exception * @throws YarnRemoteException + * @throws IOException */ @Public @Stable StopContainerResponse stopContainer(StopContainerRequest request) - throws YarnRemoteException; + throws YarnRemoteException, IOException; /** *

The api used by the ApplicationMaster to request for @@ -118,9 +122,11 @@ StopContainerResponse stopContainer(StopContainerRequest request) * @return response containing the ContainerStatus of the * container * @throws YarnRemoteException + * @throws IOException */ @Public @Stable GetContainerStatusResponse getContainerStatus( - GetContainerStatusRequest request) throws YarnRemoteException; + GetContainerStatusRequest request) throws YarnRemoteException, + IOException; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/ApplicationMaster.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/ApplicationMaster.java index d4abc504d3..26e3d402b7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/ApplicationMaster.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/ApplicationMaster.java @@ -759,6 +759,10 @@ public void run() { + container.getId()); e.printStackTrace(); // TODO do we need to release this container? + } catch (IOException e) { + LOG.info("Start container failed for :" + ", containerId=" + + container.getId()); + e.printStackTrace(); } // Get container status? diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ContainerManagerPBServiceImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ContainerManagerPBServiceImpl.java index 4b0af8156d..19eefff1a9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ContainerManagerPBServiceImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/impl/pb/service/ContainerManagerPBServiceImpl.java @@ -18,6 +18,8 @@ package org.apache.hadoop.yarn.api.impl.pb.service; +import java.io.IOException; + import org.apache.hadoop.yarn.api.ContainerManager; import org.apache.hadoop.yarn.api.ContainerManagerPB; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerStatusResponse; @@ -57,6 +59,8 @@ public GetContainerStatusResponseProto getContainerStatus(RpcController arg0, return ((GetContainerStatusResponsePBImpl)response).getProto(); } catch (YarnRemoteException e) { throw new ServiceException(e); + } catch (IOException e) { + throw new ServiceException(e); } } @@ -69,6 +73,8 @@ public StartContainerResponseProto startContainer(RpcController arg0, return ((StartContainerResponsePBImpl)response).getProto(); } catch (YarnRemoteException e) { throw new ServiceException(e); + } catch (IOException e) { + throw new ServiceException(e); } } @@ -81,6 +87,8 @@ public StopContainerResponseProto stopContainer(RpcController arg0, return ((StopContainerResponsePBImpl)response).getProto(); } catch (YarnRemoteException e) { throw new ServiceException(e); + } catch (IOException e) { + throw new ServiceException(e); } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java index 8e3ef455f9..68891103ed 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java @@ -396,7 +396,7 @@ private void authorizeRequest(String containerIDStr, @SuppressWarnings("unchecked") @Override public StartContainerResponse startContainer(StartContainerRequest request) - throws YarnRemoteException { + throws YarnRemoteException, IOException { if (blockNewContainerRequests.get()) { throw RPCUtil.getRemoteException(new NMNotYetReadyException( @@ -503,7 +503,7 @@ public StartContainerResponse startContainer(StartContainerRequest request) @Override @SuppressWarnings("unchecked") public StopContainerResponse stopContainer(StopContainerRequest request) - throws YarnRemoteException { + throws YarnRemoteException, IOException { ContainerId containerID = request.getContainerId(); String containerIDStr = containerID.toString(); @@ -545,7 +545,8 @@ public StopContainerResponse stopContainer(StopContainerRequest request) @Override public GetContainerStatusResponse getContainerStatus( - GetContainerStatusRequest request) throws YarnRemoteException { + GetContainerStatusRequest request) throws YarnRemoteException, + IOException { ContainerId containerID = request.getContainerId(); String containerIDStr = containerID.toString(); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerResync.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerResync.java index 6f1fafa66f..39f1f01762 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerResync.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerResync.java @@ -301,6 +301,8 @@ public void run() { // class name after YARN-142 Assert.assertTrue(e.getRemoteTrace().contains( NMNotYetReadyException.class.getName())); + } catch (IOException e) { + assertionFailedInThread.set(true); } } // no. of containers to be launched should equal to no. of diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java index bb17a213ed..ea08ff3d28 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/BaseContainerManagerTest.java @@ -185,13 +185,13 @@ public void tearDown() throws IOException, InterruptedException { public static void waitForContainerState(ContainerManager containerManager, ContainerId containerID, ContainerState finalState) - throws InterruptedException, YarnRemoteException { + throws InterruptedException, YarnRemoteException, IOException { waitForContainerState(containerManager, containerID, finalState, 20); } public static void waitForContainerState(ContainerManager containerManager, ContainerId containerID, ContainerState finalState, int timeOutMax) - throws InterruptedException, YarnRemoteException { + throws InterruptedException, YarnRemoteException, IOException { GetContainerStatusRequest request = recordFactory.newRecordInstance(GetContainerStatusRequest.class); request.setContainerId(containerID); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerManagerSecurity.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerManagerSecurity.java index b0f9fa272a..5d65dcf086 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerManagerSecurity.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerManagerSecurity.java @@ -537,6 +537,9 @@ void callWithIllegalContainerID(ContainerManager client, "Unauthorized request to start container. " + "\nExpected containerId: " + tokenId.getContainerID() + " Found: " + newContainerId.toString())); + } catch (IOException e) { + LOG.info("Got IOException: ",e); + fail("IOException is not expected."); } } @@ -563,6 +566,9 @@ void callWithIllegalResource(ContainerManager client, Assert.assertTrue(e.getMessage().contains( "\nExpected resource " + tokenId.getResource().toString() + " but found " + container.getResource().toString())); + } catch (IOException e) { + LOG.info("Got IOException: ",e); + fail("IOException is not expected."); } } @@ -591,6 +597,9 @@ void callWithIllegalUserName(ContainerManager client, Assert.assertTrue(e.getMessage().contains( "Expected user-name " + tokenId.getApplicationSubmitter() + " but found " + context.getUser())); + } catch (IOException e) { + LOG.info("Got IOException: ",e); + fail("IOException is not expected."); } }