From 76e309ead01f02b32335330cd920536f907fb71f Mon Sep 17 00:00:00 2001 From: Devaraj K Date: Thu, 12 Feb 2015 13:45:19 +0530 Subject: [PATCH] MAPREDUCE-6253. Update use of Iterator to Iterable. Contributed by Ray Chiang. --- hadoop-mapreduce-project/CHANGES.txt | 2 ++ .../mapreduce/jobhistory/JobHistoryEventHandler.java | 7 +++---- .../main/java/org/apache/hadoop/mapred/QueueManager.java | 4 ++-- .../org/apache/hadoop/mapreduce/v2/hs/CompletedJob.java | 8 ++++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index 246f18dad8..145e99a8d7 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -278,6 +278,8 @@ Release 2.7.0 - UNRELEASED MAPREDUCE-6227. DFSIO for truncate. (shv via yliu) + MAPREDUCE-6253. Update use of Iterator to Iterable. (Ray Chiang via devaraj) + OPTIMIZATIONS MAPREDUCE-6169. MergeQueue should release reference to the current item diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/jobhistory/JobHistoryEventHandler.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/jobhistory/JobHistoryEventHandler.java index 97de8fae2e..aad63d3158 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/jobhistory/JobHistoryEventHandler.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/jobhistory/JobHistoryEventHandler.java @@ -374,11 +374,10 @@ protected void serviceStop() throws Exception { // Process JobUnsuccessfulCompletionEvent for jobIds which still haven't // closed their event writers - Iterator jobIt = fileMap.keySet().iterator(); if(forceJobCompletion) { - while (jobIt.hasNext()) { - JobId toClose = jobIt.next(); - MetaInfo mi = fileMap.get(toClose); + for (Map.Entry jobIt : fileMap.entrySet()) { + JobId toClose = jobIt.getKey(); + MetaInfo mi = jobIt.getValue(); if(mi != null && mi.isWriterActive()) { LOG.warn("Found jobId " + toClose + " to have not been closed. Will close"); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/QueueManager.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/QueueManager.java index 14934b92ef..39fae2a531 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/QueueManager.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/QueueManager.java @@ -441,8 +441,8 @@ synchronized JobQueueInfo getJobQueueInfo(String queue) { synchronized Map getJobQueueInfoMapping() { Map m = new HashMap(); - for (String key : allQueues.keySet()) { - m.put(key, allQueues.get(key).getJobQueueInfo()); + for (Map.Entry entry : allQueues.entrySet()) { + m.put(entry.getKey(), entry.getValue().getJobQueueInfo()); } return m; diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/CompletedJob.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/CompletedJob.java index 66c44c851c..1cf63d4a71 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/CompletedJob.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/CompletedJob.java @@ -227,10 +227,10 @@ private void constructTaskAttemptCompletionEvents() { completionEvents = new LinkedList(); List allTaskAttempts = new LinkedList(); int numMapAttempts = 0; - for (TaskId taskId : tasks.keySet()) { - Task task = tasks.get(taskId); - for (TaskAttemptId taskAttemptId : task.getAttempts().keySet()) { - TaskAttempt taskAttempt = task.getAttempts().get(taskAttemptId); + for (Map.Entry taskEntry : tasks.entrySet()) { + Task task = taskEntry.getValue(); + for (Map.Entry taskAttemptEntry : task.getAttempts().entrySet()) { + TaskAttempt taskAttempt = taskAttemptEntry.getValue(); allTaskAttempts.add(taskAttempt); if (task.getType() == TaskType.MAP) { ++numMapAttempts;