ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [11/50] incubator-ignite git commit: ignite-937 RandomEvictionPolicy calculates cache size incorrectly
Date Fri, 05 Jun 2015 02:34:50 GMT
ignite-937 RandomEvictionPolicy calculates cache size incorrectly


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/4f7f58ef
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/4f7f58ef
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/4f7f58ef

Branch: refs/heads/ignite-389
Commit: 4f7f58ef755da6bf2e26e60ab9d015644350abff
Parents: 82cfb47
Author: agura <agura@gridgain.com>
Authored: Wed May 27 16:28:02 2015 +0300
Committer: agura <agura@gridgain.com>
Committed: Tue Jun 2 17:00:38 2015 +0300

----------------------------------------------------------------------
 .../ignite/cache/eviction/random/RandomEvictionPolicy.java     | 3 ++-
 .../eviction/random/RandomEvictionPolicyCacheSizeSelfTest.java | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4f7f58ef/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicy.java
b/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicy.java
index c88b31d..0ac9197 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicy.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/eviction/random/RandomEvictionPolicy.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.cache.eviction.random;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.eviction.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
@@ -87,7 +88,7 @@ public class RandomEvictionPolicy<K, V> implements EvictionPolicy<K,
V>, RandomE
 
         IgniteCache<K, V> cache = entry.unwrap(IgniteCache.class);
 
-        int size = cache.size();
+        int size = cache.localSize(CachePeekMode.ONHEAP);
 
         for (int i = max; i < size; i++) {
             Cache.Entry<K, V> e = cache.randomEntry();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4f7f58ef/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/random/RandomEvictionPolicyCacheSizeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/random/RandomEvictionPolicyCacheSizeSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/random/RandomEvictionPolicyCacheSizeSelfTest.java
index e9e7228..2a2004e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/random/RandomEvictionPolicyCacheSizeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/random/RandomEvictionPolicyCacheSizeSelfTest.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.cache.eviction.random;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.eviction.random.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.testframework.junits.common.*;
@@ -50,6 +51,7 @@ public class RandomEvictionPolicyCacheSizeSelfTest extends GridCommonAbstractTes
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
         CacheConfiguration ccfg = defaultCacheConfiguration();
+        ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
         ccfg.setNearConfiguration(null);
         ccfg.setEvictionPolicy(new RandomEvictionPolicy(PLC_MAX_SIZE));
 
@@ -67,6 +69,10 @@ public class RandomEvictionPolicyCacheSizeSelfTest extends GridCommonAbstractTes
         for (int i = 0; i < KEYS_CNT; i++)
             cache.put(i, i);
 
+        // Ensure that all entries accessed without data races and cache size will correct
+        for (int i = 0; i < KEYS_CNT; i++)
+            cache.get(i);
+
         assertEquals(PLC_MAX_SIZE * GRID_CNT, cache.size());
     }
 }


Mime
View raw message