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 2016/12/01 09:49:31 UTC
ignite git commit: ignite-4344 Do not create offheap map on client
nodes.
Repository: ignite
Updated Branches:
refs/heads/ignite-4344 [created] cc7f20611
ignite-4344 Do not create offheap map on client nodes.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/cc7f2061
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/cc7f2061
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/cc7f2061
Branch: refs/heads/ignite-4344
Commit: cc7f20611783c42bd6fe2afba2f1825769e9e264
Parents: c06e401
Author: sboikov <sb...@gridgain.com>
Authored: Thu Dec 1 12:49:19 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Dec 1 12:49:19 2016 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheProcessor.java | 10 +-
.../cache/OffheapCacheOnClientsTest.java | 143 +++++++++++++++++++
.../testsuites/IgniteCacheTestSuite2.java | 2 +
3 files changed, 150 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc7f2061/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 0e0d769..0be2072 100755
--- 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
@@ -1286,10 +1286,12 @@ public class GridCacheProcessor extends GridProcessorAdapter {
U.startLifecycleAware(lifecycleAwares(cfg, cfgStore));
+ boolean affNode = CU.affinityNode(ctx.discovery().localNode(), cfg.getNodeFilter());
+
GridCacheAffinityManager affMgr = new GridCacheAffinityManager();
GridCacheEventManager evtMgr = new GridCacheEventManager();
- GridCacheSwapManager swapMgr = new GridCacheSwapManager(cfg.getCacheMode() == LOCAL ||
- !GridCacheUtils.isNearEnabled(cfg));
+ GridCacheSwapManager swapMgr = new GridCacheSwapManager(
+ affNode && (cfg.getCacheMode() == LOCAL || !GridCacheUtils.isNearEnabled(cfg)));
GridCacheEvictionManager evictMgr = new GridCacheEvictionManager();
GridCacheQueryManager qryMgr = queryManager(cfg);
CacheContinuousQueryManager contQryMgr = new CacheContinuousQueryManager();
@@ -1302,8 +1304,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
storeMgr.initialize(cfgStore, sesHolders);
- boolean affNode = CU.affinityNode(ctx.discovery().localNode(), cfg.getNodeFilter());
-
GridCacheContext<?, ?> cacheCtx = new GridCacheContext(
ctx,
sharedCtx,
@@ -1427,7 +1427,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
* 7. GridCacheTtlManager.
* ===============================================
*/
- swapMgr = new GridCacheSwapManager(true);
+ swapMgr = new GridCacheSwapManager(affNode);
evictMgr = new GridCacheEvictionManager();
evtMgr = new GridCacheEventManager();
pluginMgr = new CachePluginManager(ctx, cfg);
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc7f2061/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/OffheapCacheOnClientsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/OffheapCacheOnClientsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/OffheapCacheOnClientsTest.java
new file mode 100644
index 0000000..90985b6
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/OffheapCacheOnClientsTest.java
@@ -0,0 +1,143 @@
+/*
+ * 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.concurrent.ConcurrentMap;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheMemoryMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+
+/**
+ *
+ */
+public class OffheapCacheOnClientsTest extends GridCommonAbstractTest {
+ /** */
+ private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static final String CACHE_NAME = "CACHE_NAME";
+
+ /** */
+ private boolean client;
+
+ /** */
+ private boolean forceSrvMode;
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGrid(0);
+
+ client = true;
+
+ startGrid(1);
+
+ forceSrvMode = true;
+
+ startGrid(2);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+ if (client) {
+ cfg.setClientMode(true);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(forceSrvMode);
+ }
+
+ return cfg;
+ }
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOffheapCacheOnClient() throws Exception {
+ try {
+ Ignite client = grid(1);
+
+ testStartCacheOnClient(client, OFFHEAP_TIERED);
+ testStartCacheOnClient(client, OFFHEAP_VALUES);
+ testStartCacheOnClient(client, ONHEAP_TIERED);
+
+ client = grid(2);
+
+ testStartCacheOnClient(client, OFFHEAP_TIERED);
+ testStartCacheOnClient(client, OFFHEAP_VALUES);
+ testStartCacheOnClient(client, ONHEAP_TIERED);
+ }
+ finally {
+ grid(0).destroyCache(CACHE_NAME);
+ }
+ }
+
+ /**
+ * @param client Node.
+ * @param memMode Memory mode.
+ * @throws Exception If failed.
+ */
+ private void testStartCacheOnClient(Ignite client, CacheMemoryMode memMode) throws Exception {
+ assertTrue(client.configuration().isClientMode());
+
+ try {
+ client.createCache(new CacheConfiguration(CACHE_NAME)
+ .setCacheMode(REPLICATED)
+ .setOffHeapMaxMemory(1024 * 1024)
+ .setMemoryMode(memMode));
+
+ IgniteCache<Integer, Integer> cache = client.cache(CACHE_NAME);
+
+ assertNotNull(cache);
+
+ cache.put(1, 1);
+ assertEquals((Integer)1, cache.get(1));
+
+ GridOffHeapProcessor offheap = ((IgniteKernal)client).cachex(CACHE_NAME).context().offheap();
+
+ assertNotNull(offheap);
+
+ ConcurrentMap offheapMaps = GridTestUtils.getFieldValue(offheap, "offheap");
+ assertNotNull(offheapMaps);
+
+ assertEquals(0,offheapMaps.size());
+ }
+ finally {
+ client.destroyCache(CACHE_NAME);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc7f2061/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 6edfd09..f632f67 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
@@ -39,6 +39,7 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheEntryProcessorNode
import org.apache.ignite.internal.processors.cache.IgniteCacheIncrementTxTest;
import org.apache.ignite.internal.processors.cache.IgniteCachePartitionMapUpdateTest;
import org.apache.ignite.internal.processors.cache.IgniteDynamicCacheAndNodeStop;
+import org.apache.ignite.internal.processors.cache.OffheapCacheOnClientsTest;
import org.apache.ignite.internal.processors.cache.distributed.CacheLoadingConcurrentGridStartSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.CacheLoadingConcurrentGridStartSelfTestAllowOverwrite;
import org.apache.ignite.internal.processors.cache.distributed.CacheLockReleaseNodeLeaveTest;
@@ -266,6 +267,7 @@ public class IgniteCacheTestSuite2 extends TestSuite {
suite.addTest(new TestSuite(IgniteNoCustomEventsOnNodeStart.class));
suite.addTest(new TestSuite(CacheExchangeMessageDuplicatedStateTest.class));
+ suite.addTest(new TestSuite(OffheapCacheOnClientsTest.class));
return suite;
}