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/27 16:48:59 UTC
[08/38] incubator-ignite git commit: # ignite-23
# ignite-23
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/804e0d96
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/804e0d96
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/804e0d96
Branch: refs/heads/ignite-709_2
Commit: 804e0d967bea588e884f5c7d4a5a3da60bca8d27
Parents: c06fade
Author: sboikov <sb...@gridgain.com>
Authored: Wed May 20 11:53:40 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed May 20 11:53:40 2015 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheProcessor.java | 3 +
.../processors/cache/GridCacheUtils.java | 2 +-
.../distributed/dht/GridDhtCacheAdapter.java | 4 +-
.../dht/GridDhtPartitionTopologyImpl.java | 16 +-
.../IgniteCachePartitionMapUpdateTest.java | 226 +++++++++++++++++++
...niteCacheClientNodeChangingTopologyTest.java | 1 -
.../junits/common/GridCommonAbstractTest.java | 2 +-
7 files changed, 243 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/804e0d96/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 fed9504..f94f9d7 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
@@ -798,6 +798,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
ctx.cacheObjects().onCacheProcessorStarted();
+
+ assert caches.containsKey(CU.MARSH_CACHE_NAME) : "Marshaller cache should be started";
+ assert caches.containsKey(CU.UTILITY_CACHE_NAME) : "Utility cache should be started";
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/804e0d96/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index b7bc115..4041f13 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -398,7 +398,7 @@ public class GridCacheUtils {
* @return Partition to state transformer.
*/
@SuppressWarnings({"unchecked"})
- public static <K, V> IgniteClosure<GridDhtLocalPartition, GridDhtPartitionState> part2state() {
+ public static IgniteClosure<GridDhtLocalPartition, GridDhtPartitionState> part2state() {
return PART2STATE;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/804e0d96/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index 23060e6..822c795 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -75,7 +75,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
protected GridDhtCacheAdapter(GridCacheContext<K, V> ctx) {
super(ctx, ctx.config().getStartSize());
- top = new GridDhtPartitionTopologyImpl<>(ctx);
+ top = new GridDhtPartitionTopologyImpl(ctx);
}
/**
@@ -87,7 +87,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
protected GridDhtCacheAdapter(GridCacheContext<K, V> ctx, GridCacheConcurrentMap map) {
super(ctx, map);
- top = new GridDhtPartitionTopologyImpl<>(ctx);
+ top = new GridDhtPartitionTopologyImpl(ctx);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/804e0d96/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index 56f6a62..761dbce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -41,7 +41,7 @@ import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDh
* Partition topology.
*/
@GridToStringExclude
-class GridDhtPartitionTopologyImpl<K, V> implements GridDhtPartitionTopology {
+class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
/** If true, then check consistency. */
private static final boolean CONSISTENCY_CHECK = false;
@@ -49,7 +49,7 @@ class GridDhtPartitionTopologyImpl<K, V> implements GridDhtPartitionTopology {
private static final boolean FULL_MAP_DEBUG = false;
/** Context. */
- private final GridCacheContext<K, V> cctx;
+ private final GridCacheContext<?, ?> cctx;
/** Logger. */
private final IgniteLogger log;
@@ -85,7 +85,7 @@ class GridDhtPartitionTopologyImpl<K, V> implements GridDhtPartitionTopology {
/**
* @param cctx Context.
*/
- GridDhtPartitionTopologyImpl(GridCacheContext<K, V> cctx) {
+ GridDhtPartitionTopologyImpl(GridCacheContext<?, ?> cctx) {
assert cctx != null;
this.cctx = cctx;
@@ -606,7 +606,7 @@ class GridDhtPartitionTopologyImpl<K, V> implements GridDhtPartitionTopology {
try {
return new GridDhtPartitionMap(cctx.nodeId(), updateSeq.get(),
- F.viewReadOnly(locParts, CU.<K, V>part2state()), true);
+ F.viewReadOnly(locParts, CU.part2state()), true);
}
finally {
lock.readLock().unlock();
@@ -1026,7 +1026,9 @@ class GridDhtPartitionTopologyImpl<K, V> implements GridDhtPartitionTopology {
assert nodeId.equals(cctx.nodeId());
// In case if node joins, get topology at the time of joining node.
- ClusterNode oldest = CU.oldest(cctx, topVer);
+ ClusterNode oldest = CU.oldestAliveCacheServerNode(cctx.shared(), topVer);
+
+ assert oldest != null;
// If this node became the oldest node.
if (oldest.id().equals(cctx.nodeId())) {
@@ -1076,7 +1078,9 @@ class GridDhtPartitionTopologyImpl<K, V> implements GridDhtPartitionTopology {
assert nodeId != null;
assert lock.writeLock().isHeldByCurrentThread();
- ClusterNode oldest = CU.oldest(cctx, topVer);
+ ClusterNode oldest = CU.oldestAliveCacheServerNode(cctx.shared(), topVer);
+
+ assert oldest != null;
ClusterNode loc = cctx.localNode();
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/804e0d96/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePartitionMapUpdateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePartitionMapUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePartitionMapUpdateTest.java
new file mode 100644
index 0000000..5b45701
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePartitionMapUpdateTest.java
@@ -0,0 +1,226 @@
+/*
+ * 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.util.typedef.*;
+import org.apache.ignite.lang.*;
+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.junits.common.*;
+
+import java.util.*;
+import java.util.concurrent.*;
+
+import static org.apache.ignite.cache.CacheMode.*;
+
+/**
+ *
+ */
+public class IgniteCachePartitionMapUpdateTest extends GridCommonAbstractTest {
+ /** */
+ protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static final String CACHE1_ATTR = "cache1";
+
+ /** */
+ private static final String CACHE2_ATTR = "cache2";
+
+ /** */
+ private static final String CACHE1 = "cache1";
+
+ /** */
+ private static final String CACHE2 = "cache2";
+
+ /** */
+ private boolean startClientCache;
+
+ /** */
+ private boolean cache1;
+
+ /** */
+ private boolean cache2;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+ CacheConfiguration ccfg1 = new CacheConfiguration();
+
+ ccfg1.setName(CACHE1);
+ ccfg1.setCacheMode(PARTITIONED);
+ ccfg1.setBackups(1);
+ ccfg1.setNodeFilter(new AttributeFilter(CACHE1_ATTR));
+
+ CacheConfiguration ccfg2 = new CacheConfiguration();
+
+ ccfg2.setName(CACHE2);
+ ccfg2.setCacheMode(PARTITIONED);
+ ccfg2.setNodeFilter(new AttributeFilter(CACHE2_ATTR));
+
+ List<CacheConfiguration> ccfgs = new ArrayList<>();
+
+ Map<String, String> attrs = new HashMap<>();
+
+ if (cache1)
+ attrs.put(CACHE1_ATTR, "true");
+
+ if (cache1 || startClientCache)
+ ccfgs.add(ccfg1);
+
+ if (cache2)
+ attrs.put(CACHE2_ATTR, "true");
+
+ if (cache2 || startClientCache)
+ ccfgs.add(ccfg2);
+
+ cfg.setUserAttributes(attrs);
+
+ cfg.setCacheConfiguration(ccfgs.toArray(new CacheConfiguration[ccfgs.size()]));
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPartitionMapUpdate1() throws Exception {
+ cache1 = false;
+ cache2 = false;
+
+ startGrid(0);
+
+ cache1 = true;
+ cache2 = false;
+
+ startGrid(1);
+
+ awaitPartitionMapExchange();
+
+ cache1 = false;
+ cache2 = true;
+
+ startGrid(2);
+
+ cache1 = true;
+ cache2 = true;
+
+ startGrid(3);
+
+ awaitPartitionMapExchange();
+
+ stopGrid(0);
+
+ awaitPartitionMapExchange();
+
+ stopGrid(1);
+
+ awaitPartitionMapExchange();
+
+ stopGrid(2);
+
+ awaitPartitionMapExchange();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPartitionMapUpdate2() throws Exception {
+ startClientCache = true;
+
+ testPartitionMapUpdate1();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testRandom() throws Exception {
+ ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+ final int NODE_CNT = 10;
+
+ for (int iter = 0; iter < 1; iter++) {
+ log.info("Iteration: " + iter);
+
+ for (int i = 0; i < NODE_CNT; i++) {
+ cache1 = rnd.nextBoolean();
+ cache2 = rnd.nextBoolean();
+
+ log.info("Start node [idx=" + i + ", cache1=" + cache1 + ", cache2=" + cache2 + ']');
+
+ startGrid(i);
+
+ awaitPartitionMapExchange();
+ }
+
+ LinkedHashSet<Integer> stopSeq = new LinkedHashSet<>();
+
+ while (stopSeq.size() != NODE_CNT)
+ stopSeq.add(rnd.nextInt(0, NODE_CNT));
+
+ for (Integer idx : stopSeq) {
+ log.info("Stop node: " + idx);
+
+ stopGrid(idx);
+
+ awaitPartitionMapExchange();
+ }
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testRandom2() throws Exception {
+ startClientCache = true;
+
+ testRandom();
+ }
+
+ /**
+ *
+ */
+ static class AttributeFilter implements IgnitePredicate<ClusterNode> {
+ /** */
+ private String attrName;
+
+ /**
+ * @param attrName Attribute name.
+ */
+ public AttributeFilter(String attrName) {
+ this.attrName = attrName;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean apply(ClusterNode node) {
+ return F.eq(node.attribute(attrName), "true");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/804e0d96/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
index c233bb9..bb2e458 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
@@ -38,5 +38,4 @@ public class IgniteCacheClientNodeChangingTopologyTest extends GridCommonAbstrac
return cfg;
}
-
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/804e0d96/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index c8a256f..47be08c 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -388,7 +388,7 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
if (affNodes.size() != owners.size() || !affNodes.containsAll(owners)) {
LT.warn(log(), null, "Waiting for topology map update [grid=" + g.name() +
- ", p=" + p + ", nodes=" + exp + ", owners=" + actual +
+ ", cache=" + cfg.getName() + ", p=" + p + ", nodes=" + exp + ", owners=" + actual +
", affNodes=" + affNodes + ", owners=" + owners +
", locNode=" + g.cluster().localNode().id() + ']');