diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 1c04b63fe2..6bdbddc533 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -309,6 +309,9 @@ Release 2.1.0-beta - UNRELEASED YARN-686. Flatten NodeReport. (sandyr via tucu) + YARN-737. Throw some specific exceptions directly instead of wrapping them + in YarnException. (Jian He via sseth) + OPTIMIZATIONS YARN-512. Log aggregation root directory check is more expensive than it diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRPC.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRPC.java index c34e64773d..b5a5141cee 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRPC.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRPC.java @@ -184,7 +184,6 @@ public StartContainerResponse startContainer(StartContainerRequest request) try { tokenId = newContainerTokenIdentifier(containerToken); - tokenId = new ContainerTokenIdentifier(); } catch (IOException e) { throw RPCUtil.getRemoteException(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 7cdba1e532..71de5fcafa 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 @@ -394,9 +394,9 @@ public StartContainerResponse startContainer(StartContainerRequest request) throws YarnException, IOException { if (blockNewContainerRequests.get()) { - throw RPCUtil.getRemoteException(new NMNotYetReadyException( + throw new NMNotYetReadyException( "Rejecting new containers as NodeManager has not" + - " yet connected with ResourceManager")); + " yet connected with ResourceManager"); } ContainerLaunchContext launchContext = request.getContainerLaunchContext(); @@ -424,8 +424,7 @@ public StartContainerResponse startContainer(StartContainerRequest request) String msg = "\nContainer "+ containerIDStr + " rejected as it is allocated by a previous RM"; LOG.error(msg); - throw RPCUtil - .getRemoteException(new InvalidContainerException(msg)); + throw new InvalidContainerException(msg); } LOG.info("Start request for " + containerIDStr + " by user " 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/InvalidContainerException.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/InvalidContainerException.java index d761326162..bbed578b4a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/InvalidContainerException.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/InvalidContainerException.java @@ -18,12 +18,13 @@ package org.apache.hadoop.yarn.server.nodemanager.containermanager; -import org.apache.hadoop.yarn.YarnRuntimeException; +import org.apache.hadoop.yarn.exceptions.YarnException; + /** * This Exception happens when NM is rejecting container requests from RM */ -public class InvalidContainerException extends YarnRuntimeException { +public class InvalidContainerException extends YarnException { private static final long serialVersionUID = 1L; 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/NMNotYetReadyException.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/NMNotYetReadyException.java index d63bd2ef6d..df20b6309f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/NMNotYetReadyException.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/NMNotYetReadyException.java @@ -18,13 +18,13 @@ package org.apache.hadoop.yarn.server.nodemanager.containermanager; -import org.apache.hadoop.yarn.YarnRuntimeException; +import org.apache.hadoop.yarn.exceptions.YarnException; /** * This exception happens when NM starts from scratch but has not yet connected * with RM. */ -public class NMNotYetReadyException extends YarnRuntimeException { +public class NMNotYetReadyException extends YarnException { private static final long serialVersionUID = 1L; 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 3765198b0f..51bae7cbe8 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 @@ -293,10 +293,8 @@ public void run() { Assert.assertTrue(e.getMessage().contains( "Rejecting new containers as NodeManager has not" + " yet connected with ResourceManager")); - // TO DO: This should be replaced to explicitly check exception - // class name after YARN-142 - Assert.assertTrue(e.getMessage().contains( - NMNotYetReadyException.class.getName())); + Assert.assertEquals(NMNotYetReadyException.class.getName(), e + .getClass().getName()); } catch (IOException e) { assertionFailedInThread.set(true); } 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/TestContainerManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManager.java index dbda9fb114..5fb8812164 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManager.java @@ -528,10 +528,8 @@ public void testContainerLaunchFromPreviousRM() throws IOException, catchException = true; Assert.assertTrue(e.getMessage().contains( "Container " + cId1 + " rejected as it is allocated by a previous RM")); - // TO DO: This should be replaced to explicitly check exception - // class name after YARN-142 - Assert.assertTrue(e.getMessage().contains( - InvalidContainerException.class.getName())); + Assert.assertEquals(InvalidContainerException.class.getName(), e + .getClass().getName()); } // Verify that startContainer fail because of invalid container request diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java index 28449241bd..e8f68fbbaf 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java @@ -258,7 +258,7 @@ protected void submitApplication( } catch (InvalidResourceRequestException e) { LOG.warn("RM app submission failed in validating AM resource request" + " for application " + applicationId, e); - throw RPCUtil.getRemoteException(e); + throw e; } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java index 7d4bbefbbd..dc1d351949 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/MiniYARNCluster.java @@ -363,10 +363,10 @@ public NodeHeartbeatResponse nodeHeartbeat( NodeHeartbeatResponse.class); try { response = rt.nodeHeartbeat(request); - } catch (YarnException ioe) { + } catch (YarnException e) { LOG.info("Exception in heartbeat from node " + - request.getNodeStatus().getNodeId(), ioe); - throw RPCUtil.getRemoteException(ioe); + request.getNodeStatus().getNodeId(), e); + throw e; } return response; } @@ -379,10 +379,10 @@ public RegisterNodeManagerResponse registerNodeManager( newRecordInstance(RegisterNodeManagerResponse.class); try { response = rt.registerNodeManager(request); - } catch (YarnException ioe) { + } catch (YarnException e) { LOG.info("Exception in node registration from " - + request.getNodeId().toString(), ioe); - throw RPCUtil.getRemoteException(ioe); + + request.getNodeId().toString(), e); + throw e; } return response; }