accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlmar...@apache.org
Subject accumulo git commit: ACCUMULO-1755: Applied Keiths suggestion
Date Wed, 02 Mar 2016 16:38:55 GMT
Repository: accumulo
Updated Branches:
  refs/heads/ACCUMULO-1755 7e93105d1 -> 27b69bedc


ACCUMULO-1755: Applied Keiths suggestion


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/27b69bed
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/27b69bed
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/27b69bed

Branch: refs/heads/ACCUMULO-1755
Commit: 27b69bedcb1e1ffcde1e47f9fbd9765027644f65
Parents: 7e93105
Author: Dave Marion <dlmarion@apache.org>
Authored: Wed Mar 2 11:38:08 2016 -0500
Committer: Dave Marion <dlmarion@apache.org>
Committed: Wed Mar 2 11:38:08 2016 -0500

----------------------------------------------------------------------
 .../client/impl/TabletServerBatchWriter.java    | 30 ++++++++++++--------
 1 file changed, 18 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/27b69bed/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java
b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java
index 6a8e2dd..35281d6 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java
@@ -439,15 +439,25 @@ public class TabletServerBatchWriter {
     }
   }
 
+  private static void computeMin(AtomicInteger stat, int update) {
+    int old = stat.get();
+    while (!stat.compareAndSet(old, Math.min(old, update))) {
+      old = stat.get();
+    }
+  }
+
+  private static void computeMax(AtomicInteger stat, int update) {
+    int old = stat.get();
+    while (!stat.compareAndSet(old, Math.max(old, update))) {
+      old = stat.get();
+    }
+  }
+
   private void updateBatchStats(Map<String,TabletServerMutations<Mutation>> binnedMutations)
{
     tabletServersBatchSum.addAndGet(binnedMutations.size());
 
-    synchronized (minTabletServersBatch) {
-      minTabletServersBatch.set(Math.min(minTabletServersBatch.get(), binnedMutations.size()));
-    }
-    synchronized (maxTabletServersBatch) {
-      maxTabletServersBatch.set(Math.max(maxTabletServersBatch.get(), binnedMutations.size()));
-    }
+    computeMin(minTabletServersBatch, binnedMutations.size());
+    computeMax(maxTabletServersBatch, binnedMutations.size());
 
     int numTablets = 0;
 
@@ -458,12 +468,8 @@ public class TabletServerBatchWriter {
 
     tabletBatchSum.addAndGet(numTablets);
 
-    synchronized (minTabletBatch) {
-      minTabletBatch.set(Math.min(minTabletBatch.get(), numTablets));
-    }
-    synchronized (maxTabletBatch) {
-      maxTabletBatch.set(Math.max(maxTabletBatch.get(), numTablets));
-    }
+    computeMin(minTabletBatch, numTablets);
+    computeMax(maxTabletBatch, numTablets);
 
     numBatches.incrementAndGet();
   }


Mime
View raw message