HADOOP-11586. Update use of Iterator to Iterable in AbstractMetricsContext.java. Contributed by Ray Chiang.

This commit is contained in:
Akira Ajisaka 2015-02-12 14:41:03 -08:00
parent 3157d992b0
commit 11d8934463
2 changed files with 9 additions and 6 deletions

View File

@ -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.

View File

@ -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<String,RecordMap> recordEntry : bufferedData.entrySet()) {
RecordMap recordMap = recordEntry.getValue();
synchronized (recordMap) {
Set<Entry<TagMap, MetricMap>> entrySet = recordMap.entrySet ();
for (Entry<TagMap, MetricMap> 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<String, Collection<OutputRecord>> getAllRecords() {
Map<String, Collection<OutputRecord>> out = new TreeMap<String, Collection<OutputRecord>>();
for (String recordName : bufferedData.keySet()) {
RecordMap recordMap = bufferedData.get(recordName);
for (Map.Entry<String,RecordMap> recordEntry : bufferedData.entrySet()) {
RecordMap recordMap = recordEntry.getValue();
synchronized (recordMap) {
List<OutputRecord> records = new ArrayList<OutputRecord>();
Set<Entry<TagMap, MetricMap>> entrySet = recordMap.entrySet();
@ -348,7 +348,7 @@ public synchronized Map<String, Collection<OutputRecord>> getAllRecords() {
OutputRecord outRec = new OutputRecord(entry.getKey(), entry.getValue());
records.add(outRec);
}
out.put(recordName, records);
out.put(recordEntry.getKey(), records);
}
}
return out;