ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [19/32] incubator-ignite git commit: # ignite-519
Date Fri, 20 Mar 2015 15:12:33 GMT
# ignite-519


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

Branch: refs/heads/ignite-496
Commit: 46c9d81536e55e9715bd0c359a5619632053a4e7
Parents: 747b4b8
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Mar 20 10:08:30 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Mar 20 10:08:30 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheAdapter.java      |  2 +-
 .../processors/cache/GridCacheMapEntry.java     | 23 ++++++-
 .../IgniteCacheExpiryPolicyAbstractTest.java    | 64 +++++++++++++++-----
 3 files changed, 72 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/46c9d815/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 6710fbc..1418cac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -4213,7 +4213,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K,
V>,
     }
 
     /**
-     *
+     * @return JCache Iterator.
      */
     private Iterator<Cache.Entry<K, V>> localIteratorHonorExpirePolicy() {
         return F.iterator(iterator(),

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/46c9d815/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 4b2cbc3..a610354 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -3944,9 +3944,21 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx
{
      * @return {@code True} if entry is visitable.
      */
     public boolean visitable(CacheEntryPredicate[] filter) {
+        boolean rmv = false;
+
         try {
-            if (obsoleteOrDeleted() || (filter != CU.empty0() &&
-                !cctx.isAll(this, filter)))
+            synchronized (this) {
+                if (obsoleteOrDeleted())
+                    return false;
+
+                if (checkExpired()) {
+                    rmv = markObsolete0(cctx.versions().next(this.ver), true);
+
+                    return false;
+                }
+            }
+
+            if (filter != CU.empty0() && !cctx.isAll(this, filter))
                 return false;
         }
         catch (IgniteCheckedException e) {
@@ -3964,6 +3976,13 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx
{
 
             return false;
         }
+        finally {
+            if (rmv) {
+                onMarkedObsolete();
+
+                cctx.cache().map().removeEntry(this);
+            }
+        }
 
         IgniteInternalTx tx = cctx.tm().localTxx();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/46c9d815/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java
index bdbd7ec..338b09b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyAbstractTest.java
@@ -49,16 +49,19 @@ import static org.apache.ignite.transactions.TransactionIsolation.*;
  */
 public abstract class IgniteCacheExpiryPolicyAbstractTest extends IgniteCacheAbstractTest
{
     /** */
+    private static final long TTL_FOR_EXPIRE = 500L;
+
+    /** */
     private Factory<? extends ExpiryPolicy> factory;
 
     /** */
     private boolean nearCache;
 
     /** */
-    private Integer lastKey = 0;
+    private boolean disableEagerTtl;
 
     /** */
-    private static final long TTL_FOR_EXPIRE = 500L;
+    private Integer lastKey = 0;
 
     /** {@inheritDoc} */
     @Override protected void beforeTestsStarted() throws Exception {
@@ -72,6 +75,22 @@ public abstract class IgniteCacheExpiryPolicyAbstractTest extends IgniteCacheAbs
         storeMap.clear();
     }
 
+
+    /** {@inheritDoc} */
+    @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception
{
+        CacheConfiguration cfg = super.cacheConfiguration(gridName);
+
+        if (nearCache && gridName.equals(getTestGridName(0)))
+            cfg.setDistributionMode(NEAR_PARTITIONED);
+
+        cfg.setExpiryPolicyFactory(factory);
+
+        if (disableEagerTtl)
+            cfg.setEagerTtl(false);
+
+        return cfg;
+    }
+
     /**
      * @throws Exception If failed.
      */
@@ -143,6 +162,33 @@ public abstract class IgniteCacheExpiryPolicyAbstractTest extends IgniteCacheAbs
 
             zeroOnAccess(key);
         }
+
+        IgniteCache<Integer, Object> cache = jcache(0);
+
+        Integer key = primaryKey(cache);
+
+        IgniteCache<Integer, Object> cache0 = cache.withExpiryPolicy(new TestPolicy(60_000L,
60_000L, 60_000L));
+
+        cache0.put(key, 1);
+
+        cache.get(key); // Access using get.
+
+        assertFalse(cache.iterator().hasNext());
+
+        cache0.put(key, 1);
+
+        assertNotNull(cache.iterator().next()); // Access using iterator.
+
+        assertFalse(cache.iterator().hasNext());
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testZeroOnAccessEagerTtlDisabled() throws Exception {
+        disableEagerTtl = true;
+
+        testZeroOnAccess();
     }
 
     /**
@@ -157,6 +203,8 @@ public abstract class IgniteCacheExpiryPolicyAbstractTest extends IgniteCacheAbs
         assertEquals((Integer)1, cache.get(key)); // Access should expire entry.
 
         waitExpired(F.asList(key));
+
+        assertFalse(cache.iterator().hasNext());
     }
 
     /**
@@ -1030,18 +1078,6 @@ public abstract class IgniteCacheExpiryPolicyAbstractTest extends IgniteCacheAbs
         assertTrue(found);
     }
 
-    /** {@inheritDoc} */
-    @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception
{
-        CacheConfiguration cfg = super.cacheConfiguration(gridName);
-
-        if (nearCache && gridName.equals(getTestGridName(0)))
-            cfg.setDistributionMode(NEAR_PARTITIONED);
-
-        cfg.setExpiryPolicyFactory(factory);
-
-        return cfg;
-    }
-
     /**
      *
      */


Mime
View raw message