From 6b0f813e898cbd14b2ae52ecfed6d30bce8cb6b7 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Fri, 26 Feb 2016 20:24:50 +0000 Subject: [PATCH] YARN-4723. NodesListManager$UnknownNodeId ClassCastException. Contributed by Kuhu Shukla --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../server/resourcemanager/NodesListManager.java | 13 ++----------- .../server/resourcemanager/rmnode/RMNodeImpl.java | 4 ++++ .../resourcemanager/TestRMNodeTransitions.java | 14 ++++++++++++++ 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 4ec6e2a3e4a..c27d191219e 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -1559,6 +1559,9 @@ Release 2.7.3 - UNRELEASED YARN-2046. Out of band heartbeats are sent only on container kill and possibly too early (Ming Ma via jlowe) + YARN-4723. NodesListManager$UnknownNodeId ClassCastException (Kuhu Shukla + via jlowe) + Release 2.7.2 - 2016-01-25 INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/NodesListManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/NodesListManager.java index 4cdf67ac6aa..ec2708ebb3c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/NodesListManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/NodesListManager.java @@ -166,17 +166,8 @@ public class NodesListManager extends CompositeService implements UnknownNodeId nodeId = new UnknownNodeId(host); RMNodeImpl rmNode = new RMNodeImpl(nodeId, rmContext, host, -1, -1, new UnknownNode(host), null, null); - - RMNode prevRMNode = - rmContext.getRMNodes().putIfAbsent(nodeId, rmNode); - if (prevRMNode != null) { - this.rmContext.getDispatcher().getEventHandler().handle( - new RMNodeEvent(prevRMNode.getNodeID(), - RMNodeEventType.DECOMMISSION)); - } else { - this.rmContext.getDispatcher().getEventHandler().handle( - new RMNodeEvent(nodeId, RMNodeEventType.DECOMMISSION)); - } + rmContext.getInactiveRMNodes().put(nodeId, rmNode); + rmNode.handle(new RMNodeEvent(nodeId, RMNodeEventType.DECOMMISSION)); } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java index ca9df38cb33..5f8317e890a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmnode/RMNodeImpl.java @@ -1017,6 +1017,10 @@ public class RMNodeImpl implements RMNode, EventHandler { */ public static void deactivateNode(RMNodeImpl rmNode, NodeState finalState) { + if (rmNode.getNodeID().getPort() == -1) { + rmNode.updateMetricsForDeactivatedNode(rmNode.getState(), finalState); + return; + } reportNodeUnusable(rmNode, finalState); // Deactivate the node diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMNodeTransitions.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMNodeTransitions.java index 701e51252ac..6ba360bda4f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMNodeTransitions.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMNodeTransitions.java @@ -688,6 +688,20 @@ public class TestRMNodeTransitions { Assert.assertEquals(0, node.getRunningApps().size()); } + @Test + public void testUnknownNodeId() { + NodesListManager.UnknownNodeId nodeId = + new NodesListManager.UnknownNodeId("host1"); + RMNodeImpl node = + new RMNodeImpl(nodeId, rmContext, null, 0, 0, null, null, null); + rmContext.getInactiveRMNodes().putIfAbsent(nodeId,node); + node.handle( + new RMNodeEvent(node.getNodeID(), RMNodeEventType.DECOMMISSION)); + Assert.assertNull( + "Must be null as there is no NODE_UNUSABLE update", + nodesListManagerEvent); + } + private RMNodeImpl getRunningNode() { return getRunningNode(null, 0); }