You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sk...@apache.org on 2020/05/22 15:37:01 UTC

[ignite] branch master updated: IGNITE-12898 Fixed node joining with configured CacheStore. Fixes #7720

This is an automated email from the ASF dual-hosted git repository.

sk0x50 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 40ff26a  IGNITE-12898 Fixed node joining with configured CacheStore. Fixes #7720
40ff26a is described below

commit 40ff26a905f69f6a438f7507cfed7cf624fd26ee
Author: Ivan Daschinskiy <iv...@gmail.com>
AuthorDate: Fri May 22 18:36:25 2020 +0300

    IGNITE-12898 Fixed node joining with configured CacheStore. Fixes #7720
    
    Signed-off-by: Slava Koptilin <sl...@gmail.com>
---
 .../processors/cache/ClusterCachesInfo.java        |   7 +-
 .../processors/cache/DynamicCacheDescriptor.java   |   6 +-
 ...acheConfigurationSerializationAbstractTest.java | 218 +++++++++++++++++++++
 ...eConfigurationSerializationOnDiscoveryTest.java | 162 ++-------------
 ...heConfigurationSerializationOnExchangeTest.java | 189 ++----------------
 5 files changed, 253 insertions(+), 329 deletions(-)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
index 0062eb4..a21fbc8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
@@ -1259,7 +1259,8 @@ public class ClusterCachesInfo {
                 grpDesc.persistenceEnabled(),
                 grpDesc.walEnabled(),
                 grpDesc.walChangeRequests(),
-                splitCfg.get2());
+                splitCfg.get2() != null ? grpDesc.cacheConfigurationEnrichment() : null
+            );
 
             cacheGrps.put(grpDesc.groupId(), grpData);
         }
@@ -1280,7 +1281,7 @@ public class ClusterCachesInfo {
                 desc.sql(),
                 false,
                 0,
-                splitCfg.get2()
+                splitCfg.get2() != null ? desc.cacheConfigurationEnrichment() : null
             );
 
             caches.put(desc.cacheName(), cacheData);
@@ -1303,7 +1304,7 @@ public class ClusterCachesInfo {
                 false,
                 true,
                 0,
-                splitCfg.get2()
+                splitCfg.get2() != null ? desc.cacheConfigurationEnrichment() : null
             );
 
             templates.put(desc.cacheName(), cacheData);
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
index b9b494b..ae0ba34 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
@@ -405,10 +405,12 @@ public class DynamicCacheDescriptor {
         res.sql(sql());
 
         if (isConfigurationEnriched()) {
-            T2<CacheConfiguration, CacheConfigurationEnrichment> splitCfg = splitter.split(this);
+            T2<CacheConfiguration, CacheConfigurationEnrichment> splitCfg = splitter.split(cacheCfg);
 
             res.config(splitCfg.get1());
-            res.cacheConfigurationEnrichment(splitCfg.get2());
+
+            // If original enrichment is present, it should be written instead of result of split.
+            res.cacheConfigurationEnrichment(cacheCfgEnrichment == null ? splitCfg.get2() : cacheCfgEnrichment);
         }
         else
             res.cacheConfigurationEnrichment(cacheCfgEnrichment);
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationSerializationAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationSerializationAbstractTest.java
new file mode 100644
index 0000000..5cd16ee
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationSerializationAbstractTest.java
@@ -0,0 +1,218 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import javax.cache.configuration.FactoryBuilder;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.CU;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.marshaller.MarshallerUtils;
+import org.apache.ignite.marshaller.jdk.JdkMarshaller;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.runners.Parameterized;
+
+/**
+ * A base class to check that user-defined parameters (marked as {@link org.apache.ignite.configuration.SerializeSeparately})
+ * for cache configurations are not explicitly deserialized on non-affinity nodes.
+ */
+public class CacheConfigurationSerializationAbstractTest extends GridCommonAbstractTest {
+    /** */
+    @Parameterized.Parameters(name = "Persistence enabled = {0}")
+    public static List<Object[]> parameters() {
+        ArrayList<Object[]> params = new ArrayList<>();
+
+        params.add(new Object[]{false});
+        params.add(new Object[]{true});
+
+        return params;
+    }
+
+    /** Persistence enabled. */
+    @Parameterized.Parameter
+    public boolean persistenceEnabled;
+
+    /** Jdk marshaller */
+    private final JdkMarshaller marsh = MarshallerUtils.jdkMarshaller(null);
+
+    /**
+     *
+     */
+    @Before
+    public void before() throws Exception {
+        stopAllGrids();
+
+        cleanPersistenceDir();
+    }
+
+    /**
+     *
+     */
+    @After
+    public void after() throws Exception {
+        stopAllGrids();
+
+        cleanPersistenceDir();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        cfg.setConsistentId(igniteInstanceName);
+
+        if (persistenceEnabled)
+            cfg.setDataStorageConfiguration(new DataStorageConfiguration()
+                    .setDefaultDataRegionConfiguration(
+                            new DataRegionConfiguration().setPersistenceEnabled(true).setMaxSize(256 * 1024 * 1024))
+            );
+
+        return cfg;
+    }
+
+    /**
+     * Creates configuration for cache which affinity belongs only to given node index.
+     *
+     * @param nodeIdx Node index.
+     * @return Cache configuration.
+     */
+    protected CacheConfiguration onlyOnNode(int nodeIdx) {
+        return new CacheConfiguration("cache-" + getTestIgniteInstanceName(nodeIdx))
+                .setNodeFilter(new OnlyOneNodeFilter(getTestIgniteInstanceName(nodeIdx)))
+                .setWriteBehindEnabled(true)
+                .setWriteThrough(true)
+                .setReadThrough(true)
+                .setCacheStoreFactory(FactoryBuilder.factoryOf(GridCacheTestStore.class));
+    }
+
+    /**
+     * @param stopCrd If {@code true}, coordinator will be stopped.
+     * @throws Exception If failed.
+     */
+    protected void restartNodesAndCheck(boolean stopCrd) throws Exception {
+        if (!stopCrd) {
+            Collection<Ignite> srvs = new ArrayList<>();
+
+            for (Ignite g : G.allGrids()) {
+                if (!g.configuration().getDiscoverySpi().isClientMode()
+                        && !g.name().equals(getTestIgniteInstanceName(0)))
+                    srvs.add(g);
+            }
+
+            for (Ignite g : srvs)
+                stopGrid(g.name(), true, false);
+        }
+        else
+            stopAllGrids();
+
+        if (stopCrd) {
+            startGridsMultiThreaded(3);
+
+            startClientGrid(3);
+        }
+        else {
+            for (int i = 1; i < 3; i++)
+                startGrid(i);
+        }
+
+        awaitPartitionMapExchange();
+
+        for (Ignite node : G.allGrids())
+            checkCaches((IgniteEx) node);
+    }
+
+    /**
+     * @param node Node.
+     */
+    protected void checkCaches(IgniteEx node) throws Exception {
+        ClusterNode clusterNode = node.localNode();
+        GridCacheProcessor cacheProc = node.context().cache();
+
+        for (DynamicCacheDescriptor cacheDesc : cacheProc.cacheDescriptors().values()) {
+            if (CU.isUtilityCache(cacheDesc.cacheName()))
+                continue;
+
+            boolean affNode = CU.affinityNode(clusterNode, cacheDesc.cacheConfiguration().getNodeFilter());
+
+            IgniteInternalCache cache = cacheProc.cache(cacheDesc.cacheName());
+
+            if (affNode) {
+                Assert.assertNotNull("Cache is not started " + cacheDesc.cacheName() + ", node " + node.name(), cache);
+
+                CacheConfiguration ccfg = cache.configuration();
+
+                Assert.assertNotNull("Cache store factory is null " + cacheDesc.cacheName() + ", node " + node.name(),
+                        ccfg.getCacheStoreFactory());
+            }
+            else {
+                Assert.assertTrue("Cache is started " + cacheDesc.cacheName() + ", node " + node.name(),
+                        cache == null || !cache.context().affinityNode());
+
+                if (cache == null) {
+                    Assert.assertFalse("Cache configuration is enriched " + cacheDesc.cacheName() + ", node " + node.name(),
+                            cacheDesc.isConfigurationEnriched());
+                    Assert.assertNull("Cache store factory is not null " + cacheDesc.cacheName() + ", node " + node.name(),
+                            cacheDesc.cacheConfiguration().getCacheStoreFactory());
+                }
+            }
+
+            // Checks that in enrichment stay an actual serialized class instead of null.
+            if (cacheDesc.cacheConfigurationEnrichment() != null) {
+                CacheConfigurationEnrichment enrichment = cacheDesc.cacheConfigurationEnrichment();
+
+                byte[] data = enrichment.getFieldSerializedValue("storeFactory");
+
+                Assert.assertNotNull("storeFactory is null for cache: " + cacheDesc.cacheName(),
+                        marsh.unmarshal(data, getClass().getClassLoader()));
+            }
+        }
+    }
+
+    /**
+     *
+     */
+    static class OnlyOneNodeFilter implements IgnitePredicate<ClusterNode> {
+        /** Consistent id. */
+        private final String consistentId;
+
+        /**
+         * @param consistentId Consistent id.
+         */
+        OnlyOneNodeFilter(String consistentId) {
+            this.consistentId = consistentId;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean apply(ClusterNode node) {
+            return node.consistentId().equals(consistentId);
+        }
+    }
+}
+
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationSerializationOnDiscoveryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationSerializationOnDiscoveryTest.java
index a968eea..2ad1379 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationSerializationOnDiscoveryTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationSerializationOnDiscoveryTest.java
@@ -17,23 +17,12 @@
 
 package org.apache.ignite.internal.processors.cache;
 
-import java.util.ArrayList;
-import java.util.List;
-import javax.cache.configuration.FactoryBuilder;
 import org.apache.ignite.Ignite;
-import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.cluster.ClusterState;
 import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.DataRegionConfiguration;
-import org.apache.ignite.configuration.DataStorageConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.internal.util.typedef.internal.CU;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -43,78 +32,23 @@ import org.junit.runners.Parameterized;
  * for static cache configurations are not explicitly deserialized on non-affinity nodes.
  */
 @RunWith(Parameterized.class)
-public class CacheConfigurationSerializationOnDiscoveryTest extends GridCommonAbstractTest {
-    /** */
-    @Parameterized.Parameters(name = "Persistence enabled = {0}")
-    public static List<Object[]> parameters() {
-        ArrayList<Object[]> params = new ArrayList<>();
-
-        params.add(new Object[]{false});
-        params.add(new Object[]{true});
-
-        return params;
-    }
-
+public class CacheConfigurationSerializationOnDiscoveryTest extends CacheConfigurationSerializationAbstractTest {
     /** Caches. */
     private CacheConfiguration[] caches;
 
-    /** Persistence enabled. */
-    @Parameterized.Parameter
-    public boolean persistenceEnabled;
-
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
 
-        cfg.setConsistentId(igniteInstanceName);
-
         if (caches != null)
             cfg.setCacheConfiguration(caches);
 
-        if (persistenceEnabled)
-            cfg.setDataStorageConfiguration(new DataStorageConfiguration()
-                .setDefaultDataRegionConfiguration(
-                    new DataRegionConfiguration().setPersistenceEnabled(true).setMaxSize(256 * 1024 * 1024))
-            );
-
         return cfg;
     }
 
     /**
      *
      */
-    @Before
-    public void before() throws Exception {
-        stopAllGrids();
-
-        cleanPersistenceDir();
-    }
-
-    /**
-     *
-     */
-    @After
-    public void after() throws Exception {
-        stopAllGrids();
-
-        cleanPersistenceDir();
-    }
-
-    /**
-     * Creates configuration for cache which affinity belongs only to given node index.
-     *
-     * @param nodeIdx Node index.
-     * @return Cache configuration.
-     */
-    private CacheConfiguration onlyOnNode(int nodeIdx) {
-        return new CacheConfiguration("cache-" + getTestIgniteInstanceName(nodeIdx))
-            .setNodeFilter(new OnlyOneNodeFilter(getTestIgniteInstanceName(nodeIdx)))
-            .setCacheStoreFactory(FactoryBuilder.factoryOf(GridCacheTestStore.class));
-    }
-
-    /**
-     *
-     */
     @Test
     public void testSerializationForCachesConfiguredOnCoordinator() throws Exception {
         caches = new CacheConfiguration[] {onlyOnNode(0), onlyOnNode(1), onlyOnNode(2)};
@@ -126,15 +60,14 @@ public class CacheConfigurationSerializationOnDiscoveryTest extends GridCommonAb
         startGridsMultiThreaded(1, 2);
 
         if (persistenceEnabled)
-            crd.cluster().active(true);
+            crd.cluster().state(ClusterState.ACTIVE);
 
         awaitPartitionMapExchange();
 
         for (Ignite node : G.allGrids())
             checkCaches((IgniteEx) node);
 
-        if (persistenceEnabled)
-            restartNodesAndCheck();
+        restartNodesAndCheck(persistenceEnabled);
     }
 
     /**
@@ -155,15 +88,14 @@ public class CacheConfigurationSerializationOnDiscoveryTest extends GridCommonAb
         caches = null;
 
         if (persistenceEnabled)
-            crd.cluster().active(true);
+            crd.cluster().state(ClusterState.ACTIVE);
 
         awaitPartitionMapExchange();
 
         for (Ignite node : G.allGrids())
             checkCaches((IgniteEx) node);
 
-        if (persistenceEnabled)
-            restartNodesAndCheck();
+        restartNodesAndCheck(persistenceEnabled);
     }
 
     /**
@@ -186,15 +118,14 @@ public class CacheConfigurationSerializationOnDiscoveryTest extends GridCommonAb
         caches = null;
 
         if (persistenceEnabled)
-            crd.cluster().active(true);
+            crd.cluster().state(ClusterState.ACTIVE);
 
         awaitPartitionMapExchange();
 
         for (Ignite node : G.allGrids())
             checkCaches((IgniteEx) node);
 
-        if (persistenceEnabled)
-            restartNodesAndCheck();
+        restartNodesAndCheck(persistenceEnabled);
     }
 
     /**
@@ -217,15 +148,14 @@ public class CacheConfigurationSerializationOnDiscoveryTest extends GridCommonAb
         caches = null;
 
         if (persistenceEnabled)
-            crd.cluster().active(true);
+            crd.cluster().state(ClusterState.ACTIVE);
 
         awaitPartitionMapExchange();
 
         for (Ignite node : G.allGrids())
             checkCaches((IgniteEx) node);
 
-        if (persistenceEnabled)
-            restartNodesAndCheck();
+        restartNodesAndCheck(persistenceEnabled);
     }
 
     /**
@@ -248,81 +178,13 @@ public class CacheConfigurationSerializationOnDiscoveryTest extends GridCommonAb
         IgniteEx clnt = startClientGrid(3);
 
         if (persistenceEnabled)
-            clnt.cluster().active(true);
-
-        awaitPartitionMapExchange();
-
-        for (Ignite node : G.allGrids())
-            checkCaches((IgniteEx) node);
-
-        if (persistenceEnabled)
-            restartNodesAndCheck();
-    }
-
-    /**
-     * Restart nodes and check caches.
-     */
-    private void restartNodesAndCheck() throws Exception {
-        stopAllGrids();
-
-        startGridsMultiThreaded(3);
+            clnt.cluster().state(ClusterState.ACTIVE);
 
         awaitPartitionMapExchange();
 
         for (Ignite node : G.allGrids())
             checkCaches((IgniteEx) node);
-    }
 
-    /**
-     * @param node Node.
-     */
-    private void checkCaches(IgniteEx node) {
-        ClusterNode clusterNode = node.localNode();
-        GridCacheProcessor cacheProcessor = node.context().cache();
-
-        for (DynamicCacheDescriptor cacheDesc : cacheProcessor.cacheDescriptors().values()) {
-            if (CU.isUtilityCache(cacheDesc.cacheName()))
-                continue;
-
-            boolean affinityNode = CU.affinityNode(clusterNode, cacheDesc.cacheConfiguration().getNodeFilter());
-
-            IgniteInternalCache cache = cacheProcessor.cache(cacheDesc.cacheName());
-
-            if (affinityNode) {
-                Assert.assertTrue("Cache is not started " + cacheDesc.cacheName() + ", node " + node.name(), cache != null);
-
-                CacheConfiguration ccfg = cache.configuration();
-
-                Assert.assertTrue("Cache store factory is null " + cacheDesc.cacheName() + ", node " + node.name(), ccfg.getCacheStoreFactory() != null);
-            }
-            else {
-                Assert.assertTrue("Cache is started " + cacheDesc.cacheName() + ", node " + node.name(), cache == null || !cache.context().affinityNode());
-
-                if (cache == null) {
-                    Assert.assertTrue("Cache configuration is enriched " + cacheDesc.cacheName() + ", node " + node.name(), !cacheDesc.isConfigurationEnriched());
-                    Assert.assertTrue("Cache store factory is not null " + cacheDesc.cacheName() + ", node " + node.name(), cacheDesc.cacheConfiguration().getCacheStoreFactory() == null);
-                }
-            }
-        }
-    }
-
-    /**
-     *
-     */
-    private static class OnlyOneNodeFilter implements IgnitePredicate<ClusterNode> {
-        /** Consistent id. */
-        private final String consistentId;
-
-        /**
-         * @param consistentId Consistent id.
-         */
-        private OnlyOneNodeFilter(String consistentId) {
-            this.consistentId = consistentId;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean apply(ClusterNode node) {
-            return node.consistentId().equals(consistentId);
-        }
+        restartNodesAndCheck(persistenceEnabled);
     }
 }
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationSerializationOnExchangeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationSerializationOnExchangeTest.java
index af6d89f..5480bd6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationSerializationOnExchangeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheConfigurationSerializationOnExchangeTest.java
@@ -17,24 +17,11 @@
 
 package org.apache.ignite.internal.processors.cache;
 
-import java.util.ArrayList;
-import java.util.List;
-import javax.cache.configuration.FactoryBuilder;
-import com.google.common.collect.Lists;
+import java.util.Arrays;
 import org.apache.ignite.Ignite;
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.DataRegionConfiguration;
-import org.apache.ignite.configuration.DataStorageConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.cluster.ClusterState;
 import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.internal.util.typedef.internal.CU;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -44,94 +31,27 @@ import org.junit.runners.Parameterized;
  * for dynamic cache configurations are not explicitly deserialized on non-affinity nodes.
  */
 @RunWith(Parameterized.class)
-public class CacheConfigurationSerializationOnExchangeTest extends GridCommonAbstractTest {
-    /** */
-    @Parameterized.Parameters(name = "Persistence enabled = {0}")
-    public static List<Object[]> parameters() {
-        ArrayList<Object[]> params = new ArrayList<>();
-
-        params.add(new Object[]{false});
-        params.add(new Object[]{true});
-
-        return params;
-    }
-
-    /** Persistence enabled. */
-    @Parameterized.Parameter
-    public boolean persistenceEnabled;
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
-        cfg.setConsistentId(igniteInstanceName);
-
-        if (persistenceEnabled)
-            cfg.setDataStorageConfiguration(new DataStorageConfiguration()
-                .setDefaultDataRegionConfiguration(
-                    new DataRegionConfiguration().setPersistenceEnabled(true).setMaxSize(256 * 1024 * 1024))
-            );
-
-        return cfg;
-    }
-
-    /**
-     *
-     */
-    @Before
-    public void before() throws Exception {
-        stopAllGrids();
-
-        cleanPersistenceDir();
-    }
-
-    /**
-     *
-     */
-    @After
-    public void after() throws Exception {
-        stopAllGrids();
-
-        cleanPersistenceDir();
-    }
-
-    /**
-     * Creates configuration for cache which affinity belongs only to given node index.
-     *
-     * @param nodeIdx Node index.
-     * @return Cache configuration.
-     */
-    private CacheConfiguration<?, ?> onlyOnNode(int nodeIdx) {
-        return new CacheConfiguration("cache-" + getTestIgniteInstanceName(nodeIdx))
-            .setNodeFilter(new OnlyOneNodeFilter(getTestIgniteInstanceName(nodeIdx)))
-            .setCacheStoreFactory(FactoryBuilder.factoryOf(GridCacheTestStore.class));
-    }
-
+public class CacheConfigurationSerializationOnExchangeTest extends CacheConfigurationSerializationAbstractTest {
     /**
      *
      */
     @Test
     public void testSerializationForDynamicCacheStartedOnCoordinator() throws Exception {
-        IgniteEx crd = (IgniteEx) startGridsMultiThreaded(3);
+        IgniteEx crd = (IgniteEx)startGridsMultiThreaded(3);
 
         if (persistenceEnabled)
-            crd.cluster().active(true);
+            crd.cluster().state(ClusterState.ACTIVE);
 
         startClientGrid(3);
 
-        crd.getOrCreateCaches(Lists.newArrayList(
-            onlyOnNode(0),
-            onlyOnNode(1),
-            onlyOnNode(2)
-        ));
+        crd.getOrCreateCaches(Arrays.asList(onlyOnNode(0), onlyOnNode(1), onlyOnNode(2)));
 
         awaitPartitionMapExchange();
 
         for (Ignite node : G.allGrids())
             checkCaches((IgniteEx) node);
 
-        if (persistenceEnabled)
-            restartNodesAndCheck();
+        restartNodesAndCheck(persistenceEnabled);
     }
 
     /**
@@ -144,23 +64,18 @@ public class CacheConfigurationSerializationOnExchangeTest extends GridCommonAbs
         IgniteEx otherNode = startGrid(2);
 
         if (persistenceEnabled)
-            otherNode.cluster().active(true);
+            otherNode.cluster().state(ClusterState.ACTIVE);
 
         startClientGrid(3);
 
-        otherNode.getOrCreateCaches(Lists.newArrayList(
-            onlyOnNode(0),
-            onlyOnNode(1),
-            onlyOnNode(2)
-        ));
+        otherNode.getOrCreateCaches(Arrays.asList(onlyOnNode(0), onlyOnNode(1), onlyOnNode(2)));
 
         awaitPartitionMapExchange();
 
         for (Ignite node : G.allGrids())
             checkCaches((IgniteEx) node);
 
-        if (persistenceEnabled)
-            restartNodesAndCheck();
+        restartNodesAndCheck(persistenceEnabled);
     }
 
     /**
@@ -168,94 +83,20 @@ public class CacheConfigurationSerializationOnExchangeTest extends GridCommonAbs
      */
     @Test
     public void testSerializationForDynamicCacheStartedOnClientNode() throws Exception {
-        IgniteEx crd = (IgniteEx) startGridsMultiThreaded(3);
+        IgniteEx crd = (IgniteEx)startGridsMultiThreaded(3);
 
         if (persistenceEnabled)
-            crd.cluster().active(true);
+            crd.cluster().state(ClusterState.ACTIVE);
 
         IgniteEx clientNode = startClientGrid(3);
 
-        clientNode.getOrCreateCaches(Lists.newArrayList(
-            onlyOnNode(0),
-            onlyOnNode(1),
-            onlyOnNode(2)
-        ));
-
-        awaitPartitionMapExchange();
-
-        for (Ignite node : G.allGrids())
-            checkCaches((IgniteEx) node);
-
-        if (persistenceEnabled)
-            restartNodesAndCheck();
-    }
-
-    /**
-     * Restart nodes and check caches.
-     */
-    private void restartNodesAndCheck() throws Exception {
-        stopAllGrids();
-
-        startGridsMultiThreaded(3);
-
-        startClientGrid(3);
+        clientNode.getOrCreateCaches(Arrays.asList(onlyOnNode(0), onlyOnNode(1), onlyOnNode(2)));
 
         awaitPartitionMapExchange();
 
         for (Ignite node : G.allGrids())
-            checkCaches((IgniteEx) node);
-    }
-
-    /**
-     * @param node Node.
-     */
-    private void checkCaches(IgniteEx node) {
-        ClusterNode clusterNode = node.localNode();
-        GridCacheProcessor cacheProcessor = node.context().cache();
-
-        for (DynamicCacheDescriptor cacheDesc : cacheProcessor.cacheDescriptors().values()) {
-            if (CU.isUtilityCache(cacheDesc.cacheName()))
-                continue;
-
-            boolean affinityNode = CU.affinityNode(clusterNode, cacheDesc.cacheConfiguration().getNodeFilter());
-
-            IgniteInternalCache cache = cacheProcessor.cache(cacheDesc.cacheName());
-
-            if (affinityNode) {
-                Assert.assertTrue("Cache is not started " + cacheDesc.cacheName() + ", node " + node.name(), cache != null);
-
-                CacheConfiguration ccfg = cache.configuration();
-
-                Assert.assertTrue("Cache store factory is null " + cacheDesc.cacheName() + ", node " + node.name(), ccfg.getCacheStoreFactory() != null);
-            }
-            else {
-                Assert.assertTrue("Cache is started " + cacheDesc.cacheName() + ", node " + node.name(), cache == null || !cache.context().affinityNode());
-
-                if (cache == null) {
-                    Assert.assertTrue("Cache configuration is enriched " + cacheDesc.cacheName() + ", node " + node.name(), !cacheDesc.isConfigurationEnriched());
-                    Assert.assertTrue("Cache store factory is not null " + cacheDesc.cacheName() + ", node " + node.name(), cacheDesc.cacheConfiguration().getCacheStoreFactory() == null);
-                }
-            }
-        }
-    }
-
-    /**
-     *
-     */
-    private static class OnlyOneNodeFilter implements IgnitePredicate<ClusterNode> {
-        /** Consistent id. */
-        private final String consistentId;
-
-        /**
-         * @param consistentId Consistent id.
-         */
-        private OnlyOneNodeFilter(String consistentId) {
-            this.consistentId = consistentId;
-        }
+            checkCaches((IgniteEx)node);
 
-        /** {@inheritDoc} */
-        @Override public boolean apply(ClusterNode node) {
-            return node.consistentId().equals(consistentId);
-        }
+        restartNodesAndCheck(persistenceEnabled);
     }
 }