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 CCA8717BC7 for ; Thu, 23 Apr 2015 16:17:19 +0000 (UTC) Received: (qmail 72149 invoked by uid 500); 23 Apr 2015 16:17:19 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 72119 invoked by uid 500); 23 Apr 2015 16:17:19 -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 72094 invoked by uid 99); 23 Apr 2015 16:17:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Apr 2015 16:17:19 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [54.164.171.186] (HELO mx1-us-east.apache.org) (54.164.171.186) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Apr 2015 16:17:14 +0000 Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id ADA71454BC for ; Thu, 23 Apr 2015 16:12:42 +0000 (UTC) Received: (qmail 43138 invoked by uid 99); 23 Apr 2015 16:12:42 -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, 23 Apr 2015 16:12:42 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1042CE17E2; Thu, 23 Apr 2015 16:12:42 +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, 23 Apr 2015 16:13:01 -0000 Message-Id: <91e978d2fd534d96a5f22ebadaed6985@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [21/50] incubator-ignite git commit: # IGNITE-768 Test for LOCAL cache on isolated nodes. X-Virus-Checked: Checked by ClamAV on apache.org # IGNITE-768 Test for LOCAL cache on isolated 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/c2c9df9c Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/c2c9df9c Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/c2c9df9c Branch: refs/heads/ignite-646 Commit: c2c9df9c125b0334f587001c8a888369752bd7cc Parents: 4e7a691 Author: AKuznetsov Authored: Wed Apr 22 16:31:34 2015 +0700 Committer: AKuznetsov Committed: Wed Apr 22 16:31:34 2015 +0700 ---------------------------------------------------------------------- .../GridCacheLocalIsolatedNodesSelfTest.java | 102 +++++++++++++++++++ .../ignite/testsuites/IgniteCacheTestSuite.java | 1 + 2 files changed, 103 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c2c9df9c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalIsolatedNodesSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalIsolatedNodesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalIsolatedNodesSelfTest.java new file mode 100644 index 0000000..dbfdc86 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalIsolatedNodesSelfTest.java @@ -0,0 +1,102 @@ +/* + * 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.local; + +import org.apache.ignite.*; +import org.apache.ignite.cluster.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.testframework.junits.common.*; + +import java.util.*; + +import static org.apache.ignite.cache.CacheMode.*; + +/** + * Isolated nodes LOCAL cache self test. + */ +public class GridCacheLocalIsolatedNodesSelfTest extends GridCommonAbstractTest { + /** + * + */ + public GridCacheLocalIsolatedNodesSelfTest() { + super(false); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + startGrids(2); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + } + + /** + * + * @throws Exception If test failed. + */ + public void testIsolatedNodes() throws Exception { + Ignite g1 = grid(0); + UUID nid1 = g1.cluster().localNode().id(); + + Ignite g2 = grid(1); + UUID nid2 = g2.cluster().localNode().id(); + + assert !nid1.equals(nid2); + + // Local cache on first node only. + CacheConfiguration ccfg1 = new CacheConfiguration<>("A"); + ccfg1.setCacheMode(LOCAL); + ccfg1.setNodeFilter(new NodeIdFilter(nid1)); + + IgniteCache c1 = g1.createCache(ccfg1); + c1.put("g1", "c1"); + + // Local cache on second node only. + CacheConfiguration ccfg2 = new CacheConfiguration<>("A"); + ccfg2.setCacheMode(LOCAL); + ccfg2.setNodeFilter(new NodeIdFilter(nid2)); + + IgniteCache c2 = g2.createCache(ccfg2); + c2.put("g2", "c2"); + + assertNull(c1.get("g2")); + assertNull(c2.get("g1")); + } + + /** Filter by node ID. */ + private static class NodeIdFilter implements IgnitePredicate { + /** */ + private final UUID nid; + + /** + * @param nid Node ID where cache should be started. + */ + NodeIdFilter(UUID nid) { + this.nid = nid; + } + + /** {@inheritDoc} */ + @Override public boolean apply(ClusterNode n) { + return n.id().equals(nid); + } + } + +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c2c9df9c/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java index 298cd65..421a61e 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java @@ -174,6 +174,7 @@ public class IgniteCacheTestSuite extends TestSuite { suite.addTestSuite(GridCacheVariableTopologySelfTest.class); suite.addTestSuite(GridCacheLocalTxMultiThreadedSelfTest.class); suite.addTestSuite(GridCacheTransformEventSelfTest.class); + suite.addTestSuite(GridCacheLocalIsolatedNodesSelfTest.class); // Partitioned cache. suite.addTestSuite(GridCachePartitionedGetSelfTest.class);