ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [11/50] ignite git commit: GG-12168 Do not store partitions state for local caches
Date Tue, 04 Jul 2017 10:02:17 GMT
GG-12168 Do not store partitions state for local caches


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

Branch: refs/heads/master
Commit: 8b0f3c104d27a298eb0518f67183c81ef07ed47f
Parents: 6391b3d
Author: Igor Seliverstov <iseliverstov@gridgain.com>
Authored: Mon Jun 26 16:00:58 2017 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Mon Jun 26 16:00:58 2017 +0300

----------------------------------------------------------------------
 .../GridCacheDatabaseSharedManager.java         |  4 +++
 .../persistence/GridCacheOffheapManager.java    | 31 ++++++++++++--------
 .../persistence/IgnitePdsDynamicCacheTest.java  | 11 +++++++
 .../junits/GridTestKernalContext.java           |  1 +
 4 files changed, 34 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0f3c10/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
index 0624774..b9ff7e7 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheDatabaseSharedManager.java
@@ -1573,6 +1573,10 @@ public class GridCacheDatabaseSharedManager extends IgniteCacheDatabaseSharedMan
         Map<T2<Integer, Integer>, T2<Integer, Long>> partStates
     ) throws IgniteCheckedException {
         for (CacheGroupContext grp : cctx.cache().cacheGroups()) {
+            if (grp.isLocal())
+                // Local cache has no partitions and its states.
+                continue;
+
             int grpId = grp.groupId();
 
             PageMemoryEx pageMem = (PageMemoryEx)grp.memoryPolicy().pageMemory();

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0f3c10/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
index 5a35490..4e322b9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
@@ -188,20 +188,22 @@ public class GridCacheOffheapManager extends IgniteCacheOffheapManagerImpl
imple
             if (size > 0 || updCntr > 0) {
                 int state = -1;
 
-                if (beforeDestroy)
-                    state = GridDhtPartitionState.EVICTED.ordinal();
-                else {
-                    // localPartition will not acquire writeLock here because create=false.
-                    GridDhtLocalPartition part = grp.topology().localPartition(store.partId(),
-                        AffinityTopologyVersion.NONE, false);
+                if (!grp.isLocal()) {
+                    if (beforeDestroy)
+                        state = GridDhtPartitionState.EVICTED.ordinal();
+                    else {
+                        // localPartition will not acquire writeLock here because create=false.
+                        GridDhtLocalPartition part = grp.topology().localPartition(store.partId(),
+                            AffinityTopologyVersion.NONE, false);
 
-                    if (part != null && part.state() != GridDhtPartitionState.EVICTED)
-                        state = part.state().ordinal();
-                }
+                        if (part != null && part.state() != GridDhtPartitionState.EVICTED)
+                            state = part.state().ordinal();
+                    }
 
-                // Do not save meta for evicted partitions on next checkpoints.
-                if (state == -1)
-                    return false;
+                    // Do not save meta for evicted partitions on next checkpoints.
+                    if (state == -1)
+                        return false;
+                }
 
                 int grpId = grp.groupId();
                 long partMetaId = pageMem.partitionMetaPageId(grpId, store.partId());
@@ -227,7 +229,10 @@ public class GridCacheOffheapManager extends IgniteCacheOffheapManagerImpl
imple
                         changed |= io.setGlobalRemoveId(pageAddr, rmvId);
                         changed |= io.setSize(pageAddr, size);
 
-                        changed |= io.setPartitionState(pageAddr, (byte)state);
+                        if (state != -1)
+                            changed |= io.setPartitionState(pageAddr, (byte)state);
+                        else
+                            assert grp.isLocal() : grp.cacheOrGroupName();
 
                         long cntrsPageId;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0f3c10/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDynamicCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDynamicCacheTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDynamicCacheTest.java
index ae4b850..189b866 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDynamicCacheTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/IgnitePdsDynamicCacheTest.java
@@ -21,6 +21,7 @@ import java.io.Serializable;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
 import org.apache.ignite.cache.CacheRebalanceMode;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
@@ -118,8 +119,15 @@ public class IgnitePdsDynamicCacheTest extends IgniteDbDynamicCacheSelfTest
{
         ccfg2.setAffinity(new RendezvousAffinityFunction(false, 32));
         ccfg2.setIndexedTypes(Integer.class, Value.class);
 
+        CacheConfiguration ccfg3 = new CacheConfiguration();
+
+        ccfg3.setName("cache3");
+        ccfg3.setAtomicityMode(CacheAtomicityMode.ATOMIC);
+        ccfg3.setCacheMode(CacheMode.LOCAL);
+
         ignite.createCache(ccfg1);
         ignite.createCache(ccfg2);
+        ignite.createCache(ccfg3).put(2, 3);
 
         int iterations = 20;
 
@@ -140,6 +148,9 @@ public class IgnitePdsDynamicCacheTest extends IgniteDbDynamicCacheSelfTest
{
 
             ignite.getOrCreateCache(ccfg2);
 
+            assertEquals(1, ignite.cache(ccfg3.getName()).size());
+            assertEquals(3, ignite.cache(ccfg3.getName()).get(2));
+
             ignite.destroyCache(ccfg2.getName());
 
             ignite.getOrCreateCache(ccfg2);

http://git-wip-us.apache.org/repos/asf/ignite/blob/8b0f3c10/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
index bb92e25..3d3de22 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
@@ -72,6 +72,7 @@ public class GridTestKernalContext extends GridKernalContextImpl {
         );
 
         GridTestUtils.setFieldValue(grid(), "cfg", config());
+        GridTestUtils.setFieldValue(grid(), "ctx", this);
 
         config().setGridLogger(log);
     }


Mime
View raw message