From 11d8934463fca00db225a1c7660e0815832352d8 Mon Sep 17 00:00:00 2001 From: Akira Ajisaka Date: Thu, 12 Feb 2015 14:41:03 -0800 Subject: [PATCH] HADOOP-11586. Update use of Iterator to Iterable in AbstractMetricsContext.java. Contributed by Ray Chiang. --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../hadoop/metrics/spi/AbstractMetricsContext.java | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 0a274d32a6..7078d42ed3 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -594,6 +594,9 @@ Release 2.7.0 - UNRELEASED HADOOP-11543. Improve help message for hadoop/yarn command. (Brahma Reddy Battula via ozawa). + HADOOP-11586. Update use of Iterator to Iterable in + AbstractMetricsContext.java. (Ray Chiang via aajisaka) + OPTIMIZATIONS HADOOP-11323. WritableComparator#compare keeps reference to byte array. diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java index ae45585102..067dc358d6 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java @@ -318,13 +318,13 @@ private void timerEvent() throws IOException { * Emits the records. */ private synchronized void emitRecords() throws IOException { - for (String recordName : bufferedData.keySet()) { - RecordMap recordMap = bufferedData.get(recordName); + for (Map.Entry recordEntry : bufferedData.entrySet()) { + RecordMap recordMap = recordEntry.getValue(); synchronized (recordMap) { Set> entrySet = recordMap.entrySet (); for (Entry entry : entrySet) { OutputRecord outRec = new OutputRecord(entry.getKey(), entry.getValue()); - emitRecord(contextName, recordName, outRec); + emitRecord(contextName, recordEntry.getKey(), outRec); } } } @@ -339,8 +339,8 @@ private synchronized void emitRecords() throws IOException { @Override public synchronized Map> getAllRecords() { Map> out = new TreeMap>(); - for (String recordName : bufferedData.keySet()) { - RecordMap recordMap = bufferedData.get(recordName); + for (Map.Entry recordEntry : bufferedData.entrySet()) { + RecordMap recordMap = recordEntry.getValue(); synchronized (recordMap) { List records = new ArrayList(); Set> entrySet = recordMap.entrySet(); @@ -348,7 +348,7 @@ public synchronized Map> getAllRecords() { OutputRecord outRec = new OutputRecord(entry.getKey(), entry.getValue()); records.add(outRec); } - out.put(recordName, records); + out.put(recordEntry.getKey(), records); } } return out;