ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [15/36] incubator-ignite git commit: IGNITE-848 - Fixed TTL removal
Date Fri, 08 May 2015 02:58:11 GMT
IGNITE-848 - Fixed TTL removal


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

Branch: refs/heads/ignite-sprint-5
Commit: e4a2130c3d4a6de9519a049f08958aa848335361
Parents: 9008472
Author: Alexey Goncharuk <agoncharuk@gridgain.com>
Authored: Tue May 5 16:20:36 2015 -0700
Committer: Alexey Goncharuk <agoncharuk@gridgain.com>
Committed: Tue May 5 16:20:36 2015 -0700

----------------------------------------------------------------------
 .../processors/cache/GridCacheMapEntry.java     |  4 +-
 .../distributed/dht/GridDhtLocalPartition.java  |  2 +-
 .../IgniteCacheExpiryPolicyAbstractTest.java    |  2 +-
 .../IgniteCacheExpiryPolicyTestSuite.java       |  2 +
 .../expiry/IgniteCacheTtlCleanupSelfTest.java   | 85 ++++++++++++++++++++
 5 files changed, 91 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e4a2130c/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 334f2b3..614da6b 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
@@ -3305,7 +3305,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx
{
                     if (!obsolete()) {
                         if (cctx.deferredDelete() && !detached() && !isInternal())
{
                             if (!deletedUnlocked()) {
-                                update(null, 0L, 0L, obsoleteVer);
+                                update(null, 0L, 0L, ver);
 
                                 deletedUnlocked(true);
 
@@ -3352,7 +3352,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx
{
             }
 
             if (deferred)
-                cctx.onDeferredDelete(this, obsoleteVer);
+                cctx.onDeferredDelete(this, ver);
 
             if ((obsolete || deferred) && cctx.cache().configuration().isStatisticsEnabled())
                 cctx.cache().metrics0().onEvict();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e4a2130c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
index c433698..0749f66 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
@@ -49,7 +49,7 @@ import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDh
  */
 public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition> {
     /** Maximum size for delete queue. */
-    private static final int MAX_DELETE_QUEUE_SIZE = Integer.getInteger(IGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE,
+    public static final int MAX_DELETE_QUEUE_SIZE = Integer.getInteger(IGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE,
         200_000);
 
     /** Static logger to avoid re-creation. */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e4a2130c/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 1e937ea..b74a373 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
@@ -1047,7 +1047,7 @@ public abstract class IgniteCacheExpiryPolicyAbstractTest extends IgniteCacheAbs
             if (e != null && e.deleted()) {
                 assertEquals(0, e.ttl());
 
-                assertTrue(!cache.affinity().isPrimaryOrBackup(grid.localNode(), key));
+                assertFalse(cache.affinity().isPrimaryOrBackup(grid.localNode(), key));
 
                 continue;
             }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e4a2130c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java
index 3a87d6d..c006f69 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyTestSuite.java
@@ -48,6 +48,8 @@ public class IgniteCacheExpiryPolicyTestSuite extends TestSuite {
 
         suite.addTestSuite(IgniteCacheExpiryStoreLoadSelfTest.class);
 
+        suite.addTestSuite(IgniteCacheTtlCleanupSelfTest.class);
+
         return suite;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e4a2130c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTtlCleanupSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTtlCleanupSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTtlCleanupSelfTest.java
new file mode 100644
index 0000000..c0e4189
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTtlCleanupSelfTest.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ignite.internal.processors.cache.expiry;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.affinity.rendezvous.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.processors.cache.distributed.dht.*;
+import org.apache.ignite.internal.processors.cacheobject.*;
+
+import javax.cache.expiry.*;
+import java.util.concurrent.*;
+
+/**
+ *
+ */
+public class IgniteCacheTtlCleanupSelfTest extends GridCacheAbstractSelfTest {
+    /** Number of partitions. */
+    private static final int PART_NUM = 10;
+
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return 1;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception
{
+        CacheConfiguration ccfg = super.cacheConfiguration(gridName);
+
+        ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
+
+        ccfg.setAffinity(new RendezvousAffinityFunction(false, 10));
+
+        ccfg.setNearConfiguration(null);
+
+        return ccfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDeferredDeleteTtl() throws Exception {
+        IgniteCache<Object, Object> cache = grid(0).cache(null)
+            .withExpiryPolicy(new CreatedExpiryPolicy(new Duration(TimeUnit.SECONDS, 5)));
+
+        int cnt = GridDhtLocalPartition.MAX_DELETE_QUEUE_SIZE / PART_NUM + 100;
+
+        for (long i = 0; i < cnt; i++)
+            grid(0).cache(null).put(i * PART_NUM, i);
+
+        for (int i = 0; i < cnt; i++)
+            cache.put(i * PART_NUM, i);
+
+        // Wait 5 seconds.
+        Thread.sleep(6_000);
+
+        assertEquals(cnt, grid(0).cache(null).size());
+
+        GridCacheAdapter<Object, Object> cacheAdapter = ((IgniteKernal)grid(0)).internalCache(null);
+
+        IgniteCacheObjectProcessor cacheObjects = cacheAdapter.context().cacheObjects();
+
+        CacheObjectContext cacheObjCtx = cacheAdapter.context().cacheObjectContext();
+
+        for (int i = 0; i < 100; i++)
+            assertNull(cacheAdapter.map().getEntry(cacheObjects.toCacheKeyObject(cacheObjCtx,
i, true)));
+    }
+}


Mime
View raw message