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/05/14 13:58:51 UTC

[3/5] incubator-ignite git commit: # ignite-709_3 do not create system caches on client nodes

# ignite-709_3 do not create system caches on client nodes


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

Branch: refs/heads/ignite-709_3
Commit: 22ec4aae19ee53fb05c14187d0fd62e66490bffa
Parents: 63261f5
Author: sboikov <sb...@gridgain.com>
Authored: Thu May 14 14:32:52 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu May 14 14:32:52 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheProcessor.java    | 18 +++-
 .../cache/IgniteSystemCacheOnClientTest.java    | 97 ++++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite4.java       |  1 +
 3 files changed, 115 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/22ec4aae/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 86d80c1..e63dd8b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -736,7 +736,13 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         if (marshallerCache() == null) {
             assert ctx.config().isClientMode() : "Marshaller cache is missed on server node.";
 
-            IgniteInternalFuture<?> fut = startCacheAsync(CU.MARSH_CACHE_NAME, true);
+            DynamicCacheDescriptor desc = registeredCaches.get(CU.MARSH_CACHE_NAME);
+
+            assert desc != null && desc.cacheConfiguration() != null && desc.cacheType().equals(CacheType.MARSHALLER);
+
+            // On client node user near-only marshaller cache.
+            IgniteInternalFuture<?> fut = dynamicStartCache(desc.cacheConfiguration(),
+                CU.MARSH_CACHE_NAME, new NearCacheConfiguration(), desc.cacheType(), false);
 
             assert fut != null;
 
@@ -2542,6 +2548,16 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     }
 
     /**
+     * @return Utility cache start future.
+     */
+    public IgniteInternalFuture<?> utilityCacheAsync() {
+        if (internalCache(CU.UTILITY_CACHE_NAME) != null)
+            return new GridFinishedFuture<>();
+
+        return startCacheAsync(CU.UTILITY_CACHE_NAME, true);
+    }
+
+    /**
      * @param name Cache name.
      * @param <K> type of keys.
      * @param <V> type of values.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/22ec4aae/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteSystemCacheOnClientTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteSystemCacheOnClientTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteSystemCacheOnClientTest.java
new file mode 100644
index 0000000..52ef7e2
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteSystemCacheOnClientTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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.cluster.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.util.lang.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.util.*;
+
+/**
+ *
+ */
+public class IgniteSystemCacheOnClientTest extends GridCommonAbstractTest {
+    /** */
+    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+        if (gridName.equals(getTestGridName(1)))
+            cfg.setClientMode(true);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        super.afterTestsStopped();
+
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testSystemCacheOnClientNode() throws Exception {
+        startGrids(2);
+
+        final IgniteKernal ignite = (IgniteKernal)ignite(1);
+
+        assertTrue(ignite.configuration().isClientMode());
+
+        GridTestUtils.waitForCondition(new GridAbsPredicate() {
+            @Override public boolean apply() {
+                return ignite.internalCache(CU.MARSH_CACHE_NAME) != null;
+            }
+        }, 5000);
+
+        GridCacheAdapter marshCache = ignite.internalCache(CU.MARSH_CACHE_NAME);
+
+        assertNotNull(marshCache);
+
+        assertTrue("Marshaller cache on client should have near cache", marshCache.context().isNear());
+
+        marshCache = ((IgniteKernal)ignite(0)).internalCache(CU.MARSH_CACHE_NAME);
+
+        assertFalse(marshCache.context().isNear());
+
+        Collection<ClusterNode> affNodes = marshCache.affinity().mapKeyToPrimaryAndBackups(1);
+
+        assertEquals(1, affNodes.size());
+        assertTrue(affNodes.contains(ignite(0).cluster().localNode()));
+
+        GridCacheAdapter utilityCache = ((IgniteKernal)ignite(0)).internalCache(CU.UTILITY_CACHE_NAME);
+
+        affNodes = utilityCache.affinity().mapKeyToPrimaryAndBackups(1);
+
+        assertEquals(1, affNodes.size());
+        assertTrue(affNodes.contains(ignite(0).cluster().localNode()));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/22ec4aae/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
index f7272d4..39f331c 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
@@ -125,6 +125,7 @@ public class IgniteCacheTestSuite4 extends TestSuite {
         suite.addTestSuite(IgniteExchangeFutureHistoryTest.class);
 
         suite.addTestSuite(CacheNoValueClassOnServerNodeTest.class);
+        suite.addTestSuite(IgniteSystemCacheOnClientTest.class);
 
         return suite;
     }