From 6dc8812a95bf369ec1f2e3d8a9473033172736cd Mon Sep 17 00:00:00 2001 From: Akira Ajisaka Date: Tue, 17 Feb 2015 14:47:53 -0800 Subject: [PATCH] HDFS-7780. Update use of Iterator to Iterable in DataXceiverServer and SnapshotDiffInfo. Contributed by Ray Chiang. --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hadoop/hdfs/server/datanode/DataXceiverServer.java | 4 ++-- .../hdfs/server/namenode/snapshot/SnapshotDiffInfo.java | 9 +++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 391005caa1..308b61f91e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -647,6 +647,9 @@ Release 2.7.0 - UNRELEASED HDFS-7795. Show warning if not all favored nodes were chosen by namenode (kihwal) + HDFS-7780. Update use of Iterator to Iterable in DataXceiverServer and + SnapshotDiffInfo. (Ray Chiang via aajisaka) + OPTIMIZATIONS HDFS-7454. Reduce memory footprint for AclEntries in NameNode. diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiverServer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiverServer.java index 9bf95eb825..caf6eaaa92 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiverServer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiverServer.java @@ -252,9 +252,9 @@ public synchronized void sendOOBToPeers() { // be set true before calling this method. synchronized void restartNotifyPeers() { assert (datanode.shouldRun == true && datanode.shutdownForUpgrade); - for (Peer p : peers.keySet()) { + for (Thread t : peers.values()) { // interrupt each and every DataXceiver thread. - peers.get(p).interrupt(); + t.interrupt(); } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotDiffInfo.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotDiffInfo.java index 197b8ae49b..a576c571d0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotDiffInfo.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotDiffInfo.java @@ -187,12 +187,13 @@ boolean isFromEarlier() { */ public SnapshotDiffReport generateReport() { List diffReportList = new ArrayList(); - for (INode node : diffMap.keySet()) { - diffReportList.add(new DiffReportEntry(DiffType.MODIFY, diffMap - .get(node), null)); + for (Map.Entry drEntry : diffMap.entrySet()) { + INode node = drEntry.getKey(); + byte[][] path = drEntry.getValue(); + diffReportList.add(new DiffReportEntry(DiffType.MODIFY, path, null)); if (node.isDirectory()) { List subList = generateReport(dirDiffMap.get(node), - diffMap.get(node), isFromEarlier(), renameMap); + path, isFromEarlier(), renameMap); diffReportList.addAll(subList); } }