This is an automated email from the ASF dual-hosted git repository.

stevel pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-3.3 by this push:
     new 0b56be3ca45 MAPREDUCE-7437. MR Fetcher class to use an AtomicInteger 
to generate IDs. (#5579)
0b56be3ca45 is described below

commit 0b56be3ca4512017c52be57fde44dbe7d476b1ce
Author: Steve Loughran <ste...@cloudera.com>
AuthorDate: Tue Apr 25 19:53:40 2023 +0100

    MAPREDUCE-7437. MR Fetcher class to use an AtomicInteger to generate IDs. 
(#5579)
    
    ...as until now it wasn't thread safe
    
    Contributed by Steve Loughran
---
 .../main/java/org/apache/hadoop/mapreduce/task/reduce/Fetcher.java   | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git 
a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/task/reduce/Fetcher.java
 
b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/task/reduce/Fetcher.java
index d8bc68c6c71..4fed3aeac81 100644
--- 
a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/task/reduce/Fetcher.java
+++ 
b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/task/reduce/Fetcher.java
@@ -31,6 +31,7 @@ import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.crypto.SecretKey;
 import javax.net.ssl.HttpsURLConnection;
@@ -88,7 +89,7 @@ class Fetcher<K,V> extends Thread {
   protected final ShuffleClientMetrics metrics;
   protected final ExceptionReporter exceptionReporter;
   protected final int id;
-  private static int nextId = 0;
+  private static final AtomicInteger NEXT_ID = new AtomicInteger(0);
   protected final int reduce;
   
   private final int connectionTimeout;
@@ -115,7 +116,7 @@ class Fetcher<K,V> extends Thread {
                  Reporter reporter, ShuffleClientMetrics metrics,
                  ExceptionReporter exceptionReporter, SecretKey shuffleKey) {
     this(job, reduceId, scheduler, merger, reporter, metrics,
-        exceptionReporter, shuffleKey, ++nextId);
+        exceptionReporter, shuffleKey, NEXT_ID.incrementAndGet());
   }
 
   @VisibleForTesting


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to