accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlmar...@apache.org
Subject accumulo git commit: Fix synchronization issues in stats updating, only update status if trace logging is enabled.
Date Wed, 02 Mar 2016 13:56:24 GMT
Repository: accumulo
Updated Branches:
  refs/heads/ACCUMULO-1755 03c256fd4 -> 7e93105d1


Fix synchronization issues in stats updating, only update status if trace logging is enabled.


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

Branch: refs/heads/ACCUMULO-1755
Commit: 7e93105d1149d221960a214ef8638f82243caa5f
Parents: 03c256f
Author: Dave Marion <dlmarion@apache.org>
Authored: Wed Mar 2 08:55:22 2016 -0500
Committer: Dave Marion <dlmarion@apache.org>
Committed: Wed Mar 2 08:55:22 2016 -0500

----------------------------------------------------------------------
 .../client/impl/TabletServerBatchWriter.java    | 56 ++++++++++++--------
 1 file changed, 33 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/7e93105d/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 89561da..6a8e2dd 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
@@ -376,26 +376,26 @@ public class TabletServerBatchWriter {
   }
 
   private void logStats() {
-    long finishTime = System.currentTimeMillis();
+    if (log.isTraceEnabled()) {
+      long finishTime = System.currentTimeMillis();
 
-    long finalGCTimes = 0;
-    List<GarbageCollectorMXBean> gcmBeans = ManagementFactory.getGarbageCollectorMXBeans();
-    for (GarbageCollectorMXBean garbageCollectorMXBean : gcmBeans) {
-      finalGCTimes += garbageCollectorMXBean.getCollectionTime();
-    }
+      long finalGCTimes = 0;
+      List<GarbageCollectorMXBean> gcmBeans = ManagementFactory.getGarbageCollectorMXBeans();
+      for (GarbageCollectorMXBean garbageCollectorMXBean : gcmBeans) {
+        finalGCTimes += garbageCollectorMXBean.getCollectionTime();
+      }
 
-    CompilationMXBean compMxBean = ManagementFactory.getCompilationMXBean();
-    long finalCompileTimes = 0;
-    if (compMxBean.isCompilationTimeMonitoringSupported()) {
-      finalCompileTimes = compMxBean.getTotalCompilationTime();
-    }
+      CompilationMXBean compMxBean = ManagementFactory.getCompilationMXBean();
+      long finalCompileTimes = 0;
+      if (compMxBean.isCompilationTimeMonitoringSupported()) {
+        finalCompileTimes = compMxBean.getTotalCompilationTime();
+      }
 
-    double averageRate = totalSent.get() / (totalSendTime.get() / 1000.0);
-    double overallRate = totalAdded / ((finishTime - startTime) / 1000.0);
+      double averageRate = totalSent.get() / (totalSendTime.get() / 1000.0);
+      double overallRate = totalAdded / ((finishTime - startTime) / 1000.0);
 
-    double finalSystemLoad = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage();
+      double finalSystemLoad = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage();
 
-    if (log.isTraceEnabled()) {
       log.trace("");
       log.trace("TABLET SERVER BATCH WRITER STATISTICS");
       log.trace(String.format("Added                : %,10d mutations", totalAdded));
@@ -432,16 +432,22 @@ public class TabletServerBatchWriter {
   }
 
   public void updateBinningStats(int count, long time, Map<String,TabletServerMutations<Mutation>>
binnedMutations) {
-    totalBinTime.addAndGet(time);
-    totalBinned.addAndGet(count);
-    updateBatchStats(binnedMutations);
+    if (log.isTraceEnabled()) {
+      totalBinTime.addAndGet(time);
+      totalBinned.addAndGet(count);
+      updateBatchStats(binnedMutations);
+    }
   }
 
   private void updateBatchStats(Map<String,TabletServerMutations<Mutation>> binnedMutations)
{
     tabletServersBatchSum.addAndGet(binnedMutations.size());
 
-    minTabletServersBatch.set(Math.min(minTabletServersBatch.get(), binnedMutations.size()));
-    maxTabletServersBatch.set(Math.max(maxTabletServersBatch.get(), binnedMutations.size()));
+    synchronized (minTabletServersBatch) {
+      minTabletServersBatch.set(Math.min(minTabletServersBatch.get(), binnedMutations.size()));
+    }
+    synchronized (maxTabletServersBatch) {
+      maxTabletServersBatch.set(Math.max(maxTabletServersBatch.get(), binnedMutations.size()));
+    }
 
     int numTablets = 0;
 
@@ -452,8 +458,12 @@ public class TabletServerBatchWriter {
 
     tabletBatchSum.addAndGet(numTablets);
 
-    minTabletBatch.set(Math.min(minTabletBatch.get(), numTablets));
-    maxTabletBatch.set(Math.max(maxTabletBatch.get(), numTablets));
+    synchronized (minTabletBatch) {
+      minTabletBatch.set(Math.min(minTabletBatch.get(), numTablets));
+    }
+    synchronized (maxTabletBatch) {
+      maxTabletBatch.set(Math.max(maxTabletBatch.get(), numTablets));
+    }
 
     numBatches.incrementAndGet();
   }
@@ -653,7 +663,7 @@ public class TabletServerBatchWriter {
       binningThreadPool.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
     }
 
-    private TabletLocator getLocator(String tableId) {
+    private synchronized TabletLocator getLocator(String tableId) {
       TabletLocator ret = locators.get(tableId);
       if (ret == null) {
         ret = TabletLocator.getLocator(context, tableId);


Mime
View raw message