Author: cnauroth Date: Thu May 22 04:50:53 2014 New Revision: 1596742 URL: http://svn.apache.org/r1596742 Log: HDFS-6433. Replace BytesMoved class with AtomicLong. Contributed by Benoy Antony.
Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Balancer.java Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1596742&r1=1596741&r2=1596742&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Thu May 22 04:50:53 2014 @@ -575,6 +575,9 @@ Release 2.5.0 - UNRELEASED HDFS-6409. Fix typo in log message about NameNode layout version upgrade. (Chen He via cnauroth) + HDFS-6433. Replace BytesMoved class with AtomicLong. + (Benoy Antony via cnauroth) + Release 2.4.1 - UNRELEASED INCOMPATIBLE CHANGES Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Balancer.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Balancer.java?rev=1596742&r1=1596741&r2=1596742&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Balancer.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Balancer.java Thu May 22 04:50:53 2014 @@ -47,6 +47,7 @@ import java.util.concurrent.ExecutionExc import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.concurrent.atomic.AtomicLong; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -365,7 +366,7 @@ public class Balancer { sendRequest(out); receiveResponse(in); - bytesMoved.inc(block.getNumBytes()); + bytesMoved.addAndGet(block.getNumBytes()); LOG.info("Successfully moved " + this); } catch (IOException e) { LOG.warn("Failed to move " + this + ": " + e.getMessage()); @@ -1111,17 +1112,7 @@ public class Balancer { return null; } - private static class BytesMoved { - private long bytesMoved = 0L;; - private synchronized void inc( long bytes ) { - bytesMoved += bytes; - } - - private synchronized long get() { - return bytesMoved; - } - }; - private final BytesMoved bytesMoved = new BytesMoved(); + private final AtomicLong bytesMoved = new AtomicLong(); /* Start a thread to dispatch block moves for each source. * The thread selects blocks to move & sends request to proxy source to