From b10ec0aa14bfa0d967ed9998dbedebbc1ce43a47 Mon Sep 17 00:00:00 2001 From: Weiwei Yang Date: Wed, 7 Nov 2018 22:27:57 +0800 Subject: [PATCH] YARN-8977. Remove unnecessary type casting when calling AbstractYarnScheduler#getSchedulerNode. Contributed by Wanqiang Ji. (cherry picked from commit c96cbe8659587cfc114a96aab1be5cc85029fe44) --- .../scheduler/capacity/CapacityScheduler.java | 6 +++--- .../scheduler/fair/TestContinuousScheduling.java | 3 +-- .../resourcemanager/scheduler/fair/TestFairScheduler.java | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java index e89fce0c031..45efd4a8798 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java @@ -2189,8 +2189,8 @@ public class CapacityScheduler extends super.completedContainer(killableContainer, SchedulerUtils .createPreemptedContainerStatus(killableContainer.getContainerId(), SchedulerUtils.PREEMPTED_CONTAINER), RMContainerEventType.KILL); - } else{ - FiCaSchedulerNode node = (FiCaSchedulerNode) getSchedulerNode( + } else { + FiCaSchedulerNode node = getSchedulerNode( killableContainer.getAllocatedNode()); FiCaSchedulerApp application = getCurrentAttemptForContainer( @@ -2222,7 +2222,7 @@ public class CapacityScheduler extends + nonKillableContainer.toString()); } - FiCaSchedulerNode node = (FiCaSchedulerNode) getSchedulerNode( + FiCaSchedulerNode node = getSchedulerNode( nonKillableContainer.getAllocatedNode()); FiCaSchedulerApp application = getCurrentAttemptForContainer( diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestContinuousScheduling.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestContinuousScheduling.java index 251278756b6..e6a841a9c20 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestContinuousScheduling.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestContinuousScheduling.java @@ -376,8 +376,7 @@ public class TestContinuousScheduling extends FairSchedulerTestBase { NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1); scheduler.handle(nodeEvent1); - FSSchedulerNode node = - (FSSchedulerNode) scheduler.getSchedulerNode(node1.getNodeID()); + FSSchedulerNode node = scheduler.getSchedulerNode(node1.getNodeID()); // Tick the time and let the fsApp startTime different from initScheduler // time mockClock.tickSec(delayThresholdTimeMs / 1000); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java index dbf4b2bf91b..0d6caebac68 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java @@ -4557,8 +4557,7 @@ public class TestFairScheduler extends FairSchedulerTestBase { NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1); scheduler.handle(nodeEvent1); - FSSchedulerNode node = (FSSchedulerNode)scheduler.getSchedulerNode( - node1.getNodeID()); + FSSchedulerNode node = scheduler.getSchedulerNode(node1.getNodeID()); NodeRemovedSchedulerEvent removeNode1 = new NodeRemovedSchedulerEvent(node1);