Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EF0D2103E6 for ; Thu, 14 May 2015 11:58:59 +0000 (UTC) Received: (qmail 77028 invoked by uid 500); 14 May 2015 11:58:59 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 76998 invoked by uid 500); 14 May 2015 11:58:59 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 76989 invoked by uid 99); 14 May 2015 11:58:59 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 May 2015 11:58:59 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 6FA07C4CEC for ; Thu, 14 May 2015 11:58:59 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.791 X-Spam-Level: * X-Spam-Status: No, score=1.791 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id WH33DG8BtvVv for ; Thu, 14 May 2015 11:58:51 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with SMTP id D52362316E for ; Thu, 14 May 2015 11:58:50 +0000 (UTC) Received: (qmail 76733 invoked by uid 99); 14 May 2015 11:58:49 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 May 2015 11:58:49 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AE5EDE1081; Thu, 14 May 2015 11:58:49 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.incubator.apache.org Date: Thu, 14 May 2015 11:58:51 -0000 Message-Id: <4ddbd8e4995c44b3b61fcdcf92813cd8@git.apache.org> In-Reply-To: <9dc2de7519ca4bd5b1213d5bfd72a35c@git.apache.org> References: <9dc2de7519ca4bd5b1213d5bfd72a35c@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [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 Authored: Thu May 14 14:32:52 2015 +0300 Committer: sboikov 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 type of keys. * @param 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 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; }