You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ab...@apache.org on 2016/12/19 08:42:09 UTC

geode git commit: GEODE-1541 : Made statsListUniqueId to be an AtomicLong. This closes #319

Repository: geode
Updated Branches:
  refs/heads/develop fc89d7410 -> c02feccf7


GEODE-1541 : Made statsListUniqueId to be an AtomicLong.
This closes #319


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

Branch: refs/heads/develop
Commit: c02feccf7f73931e751b541c74a6729141ae02fd
Parents: fc89d74
Author: Amey Barve <ab...@apache.org>
Authored: Thu Dec 15 13:00:25 2016 +0530
Committer: Amey Barve <ab...@apache.org>
Committed: Mon Dec 19 14:10:36 2016 +0530

----------------------------------------------------------------------
 .../internal/InternalDistributedSystem.java           | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/c02feccf/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
index 800512d..95aa7df 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
@@ -36,6 +36,7 @@ import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.logging.log4j.Logger;
@@ -1726,8 +1727,7 @@ public class InternalDistributedSystem extends DistributedSystem
 
   private final CopyOnWriteArrayList<Statistics> statsList = new CopyOnWriteArrayList<Statistics>();
   private int statsListModCount = 0;
-  private long statsListUniqueId = 1;
-  private final Object statsListUniqueIdLock = new Object();
+  private AtomicLong statsListUniqueId = new AtomicLong(1);
 
   // As the function execution stats can be lot in number, its better to put
   // them in a map so that it will be accessible immediately
@@ -1800,10 +1800,7 @@ public class InternalDistributedSystem extends DistributedSystem
     if (this.statsDisabled) {
       return new DummyStatisticsImpl(type, textId, numericId);
     }
-    long myUniqueId;
-    synchronized (statsListUniqueIdLock) {
-      myUniqueId = statsListUniqueId++; // fix for bug 30597
-    }
+    long myUniqueId = statsListUniqueId.getAndIncrement();
     Statistics result =
         new LocalStatisticsImpl(type, textId, numericId, myUniqueId, false, osStatFlags, this);
     synchronized (statsList) {
@@ -1935,10 +1932,7 @@ public class InternalDistributedSystem extends DistributedSystem
       return new DummyStatisticsImpl(type, textId, numericId);
     }
 
-    long myUniqueId;
-    synchronized (statsListUniqueIdLock) {
-      myUniqueId = statsListUniqueId++; // fix for bug 30597
-    }
+    long myUniqueId = statsListUniqueId.getAndIncrement();
     Statistics result = StatisticsImpl.createAtomicNoOS(type, textId, numericId, myUniqueId, this);
     synchronized (statsList) {
       statsList.add(result);