accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [07/11] accumulo git commit: ACCUMULO-3867 Switch concurrently-accessed long to AtomicLong
Date Fri, 29 May 2015 01:28:55 GMT
ACCUMULO-3867 Switch concurrently-accessed long to AtomicLong


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

Branch: refs/heads/1.7
Commit: 7c112a06fbd3337f0517f8a0f14fe7eeff7f9512
Parents: f7b0930
Author: Josh Elser <elserj@apache.org>
Authored: Thu May 28 19:49:31 2015 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Thu May 28 21:14:19 2015 -0400

----------------------------------------------------------------------
 .../src/main/java/org/apache/accumulo/monitor/Monitor.java    | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/7c112a06/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
index abdaa4b..6e00863 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
@@ -30,6 +30,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.TimerTask;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.accumulo.core.Constants;
@@ -105,7 +106,7 @@ public class Monitor {
   private static final Logger log = LoggerFactory.getLogger(Monitor.class);
 
   private static final int REFRESH_TIME = 5;
-  private static long lastRecalc = 0L;
+  private static AtomicLong lastRecalc = new AtomicLong(0L);
   private static double totalIngestRate = 0.0;
   private static double totalQueryRate = 0.0;
   private static double totalScanRate = 0.0;
@@ -242,7 +243,7 @@ public class Monitor {
 
     // only recalc every so often
     long currentTime = System.currentTimeMillis();
-    if (currentTime - lastRecalc < REFRESH_TIME * 1000)
+    if (currentTime - lastRecalc.get() < REFRESH_TIME * 1000)
       return;
 
     synchronized (Monitor.class) {
@@ -376,7 +377,7 @@ public class Monitor {
     } finally {
       synchronized (Monitor.class) {
         fetching = false;
-        lastRecalc = currentTime;
+        lastRecalc.set(currentTime);
       }
     }
   }


Mime
View raw message