ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [21/50] incubator-ignite git commit: # IGNITE-768 Test for LOCAL cache on isolated nodes.
Date Thu, 23 Apr 2015 16:13:01 GMT
# 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 <akuznetsov@gridgain.com>
Authored: Wed Apr 22 16:31:34 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
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<String, String> ccfg1 = new CacheConfiguration<>("A");
+        ccfg1.setCacheMode(LOCAL);
+        ccfg1.setNodeFilter(new NodeIdFilter(nid1));
+
+        IgniteCache<String, String> c1 = g1.createCache(ccfg1);
+        c1.put("g1", "c1");
+
+        // Local cache on second node only.
+        CacheConfiguration<String, String> ccfg2 = new CacheConfiguration<>("A");
+        ccfg2.setCacheMode(LOCAL);
+        ccfg2.setNodeFilter(new NodeIdFilter(nid2));
+
+        IgniteCache<String, String> 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<ClusterNode> {
+        /** */
+        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);


Mime
View raw message