From 2586915bb3178d26ad692f93d53aaffbb55d9ed9 Mon Sep 17 00:00:00 2001 From: Xuan Date: Thu, 12 Feb 2015 17:31:45 -0800 Subject: [PATCH] YARN-3179. Update use of Iterator to Iterable in RMAdminCLI and CommonNodeLabelsManager. Contributed by Ray Chiang --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../hadoop/yarn/client/cli/RMAdminCLI.java | 19 ++++++++++--------- .../nodelabels/CommonNodeLabelsManager.java | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 7117fbdd688..fdf13beab4c 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -287,6 +287,9 @@ Release 2.7.0 - UNRELEASED YARN-3158. Correct log messages in ResourceTrackerService. (Varun Saxena via xgong) + YARN-3179. Update use of Iterator to Iterable in RMAdminCLI and + CommonNodeLabelsManager. (Ray Chiang via xgong) + OPTIMIZATIONS YARN-2990. FairScheduler's delay-scheduling always waits for node-local and diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java index af83102c96d..d29f6741317 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/RMAdminCLI.java @@ -128,12 +128,12 @@ public class RMAdminCLI extends HAAdmin { } private static void appendHAUsage(final StringBuilder usageBuilder) { - for (String cmdKey : USAGE.keySet()) { - if (cmdKey.equals("-help")) { + for (Map.Entry cmdEntry : USAGE.entrySet()) { + if (cmdEntry.getKey().equals("-help")) { continue; } - UsageInfo usageInfo = USAGE.get(cmdKey); - usageBuilder.append(" [" + cmdKey + " " + usageInfo.args + "]"); + UsageInfo usageInfo = cmdEntry.getValue(); + usageBuilder.append(" [" + cmdEntry.getKey() + " " + usageInfo.args + "]"); } } @@ -173,14 +173,15 @@ public class RMAdminCLI extends HAAdmin { private static void buildUsageMsg(StringBuilder builder, boolean isHAEnabled) { builder.append("Usage: yarn rmadmin\n"); - for (String cmdKey : ADMIN_USAGE.keySet()) { - UsageInfo usageInfo = ADMIN_USAGE.get(cmdKey); - builder.append(" " + cmdKey + " " + usageInfo.args + "\n"); + for (Map.Entry cmdEntry : ADMIN_USAGE.entrySet()) { + UsageInfo usageInfo = cmdEntry.getValue(); + builder.append(" " + cmdEntry.getKey() + " " + usageInfo.args + "\n"); } if (isHAEnabled) { - for (String cmdKey : USAGE.keySet()) { + for (Map.Entry cmdEntry : USAGE.entrySet()) { + String cmdKey = cmdEntry.getKey(); if (!cmdKey.equals("-help")) { - UsageInfo usageInfo = USAGE.get(cmdKey); + UsageInfo usageInfo = cmdEntry.getValue(); builder.append(" " + cmdKey + " " + usageInfo.args + "\n"); } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java index 25ff4173200..cb6f1f39148 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java @@ -383,8 +383,8 @@ public class CommonNodeLabelsManager extends AbstractService { @SuppressWarnings("unchecked") protected void internalRemoveFromClusterNodeLabels(Collection labelsToRemove) { // remove labels from nodes - for (String nodeName : nodeCollections.keySet()) { - Host host = nodeCollections.get(nodeName); + for (Map.Entry nodeEntry : nodeCollections.entrySet()) { + Host host = nodeEntry.getValue(); if (null != host) { host.labels.removeAll(labelsToRemove); for (Node nm : host.nms.values()) {