You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/08/14 09:40:51 UTC

[2/2] incubator-ignite git commit: # ignite-1175: call 'onDeferredDelete' from innerRemover

# ignite-1175: call 'onDeferredDelete' from innerRemover


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

Branch: refs/heads/ignite-1.3.3-p2
Commit: 51dcd518e51883ca043492a86928cf3488db4bd7
Parents: 834b347
Author: sboikov <sb...@gridgain.com>
Authored: Tue Aug 11 11:30:02 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Aug 11 11:39:54 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheMapEntry.java     |   4 +-
 ...cheDhtLocalPartitionAfterRemoveSelfTest.java | 112 +++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite2.java       |   1 +
 3 files changed, 116 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/51dcd518/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 4680994..a078bed 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
@@ -1232,7 +1232,9 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
         if (writeThrough)
             cctx.store().remove(tx, keyValue(false));
 
-        if (!cctx.deferredDelete()) {
+        if (cctx.deferredDelete() && !detached() && !isInternal())
+            cctx.onDeferredDelete(this, newVer);
+        else {
             boolean marked = false;
 
             synchronized (this) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/51dcd518/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDhtLocalPartitionAfterRemoveSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDhtLocalPartitionAfterRemoveSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDhtLocalPartitionAfterRemoveSelfTest.java
new file mode 100644
index 0000000..a930d35
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheDhtLocalPartitionAfterRemoveSelfTest.java
@@ -0,0 +1,112 @@
+/*
+ * 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;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.processors.cache.distributed.dht.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+
+/**
+ * Test for remove operation.
+ */
+public class CacheDhtLocalPartitionAfterRemoveSelfTest extends GridCommonAbstractTest {
+    /** Grid count. */
+    private static final int GRID_CNT = 3;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        ccfg.setAtomicityMode(TRANSACTIONAL);
+        ccfg.setNearConfiguration(null);
+
+        cfg.setCacheConfiguration(ccfg);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        startGrids(GRID_CNT);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testMemoryUsage() throws Exception {
+        assertEquals(10_000, GridDhtLocalPartition.MAX_DELETE_QUEUE_SIZE);
+
+        IgniteCache<TestKey, Integer> cache = grid(0).cache(null);
+
+        for (int i = 0; i < 20_000; ++i)
+            cache.put(new TestKey(String.valueOf(i)), i);
+
+        for (int i = 0; i < 20_000; ++i)
+            assertEquals((Object)i, cache.getAndRemove(new TestKey(String.valueOf(i))));
+
+        assertEquals(0, cache.size());
+
+        for (int g = 0; g < GRID_CNT; g++) {
+            cache = grid(g).cache(null);
+
+            for (GridDhtLocalPartition p : dht(cache).topology().localPartitions()) {
+                int size = p.size();
+
+                assertTrue("Unexpected size: " + size, size <= 32);
+            }
+        }
+    }
+
+    /**
+     * Test key.
+     */
+    private static class TestKey {
+        /** Key. */
+        private String key;
+
+        /**
+         * @param key Key.
+         */
+        public TestKey(String key) {
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            return key.hashCode();
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object obj) {
+            if (obj == null || !(obj instanceof TestKey))
+                return false;
+
+            return key.equals(((TestKey)obj).key);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/51dcd518/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
index bf760f5..dcbab07 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
@@ -98,6 +98,7 @@ public class IgniteCacheTestSuite2 extends TestSuite {
         suite.addTest(new TestSuite(GridCacheDhtPreloadPutGetSelfTest.class));
         suite.addTest(new TestSuite(GridCacheDhtPreloadDisabledSelfTest.class));
         suite.addTest(new TestSuite(GridCacheDhtPreloadMultiThreadedSelfTest.class));
+        suite.addTest(new TestSuite(CacheDhtLocalPartitionAfterRemoveSelfTest.class));
         suite.addTest(new TestSuite(GridCacheColocatedPreloadRestartSelfTest.class));
         suite.addTest(new TestSuite(GridCacheNearPreloadRestartSelfTest.class));
         suite.addTest(new TestSuite(GridCacheDhtPreloadStartStopSelfTest.class));