ignite-1016 Removed validation of affinity function type and exclude neighbors flag
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ae32d866 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ae32d866 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ae32d866 Branch: refs/heads/pull-80-head Commit: ae32d866cbd0cc88f8c63ffa2f9e813c16d41d5e Parents: 1c51bf6 Author: agura <[email protected]> Authored: Thu Sep 10 22:41:09 2015 +0300 Committer: agura <[email protected]> Committed: Thu Sep 10 22:41:09 2015 +0300 ---------------------------------------------------------------------- .../affinity/fair/FairAffinityFunction.java | 15 ++++++-- .../rendezvous/RendezvousAffinityFunction.java | 11 ++++-- .../processors/cache/GridCacheProcessor.java | 12 ------- ...xcludeNeighborsMultiNodeFullApiSelfTest.java | 36 ++++++++++++++++++++ ...tedFairAffinityMultiNodeFullApiSelfTest.java | 35 +++++++++++++++++++ ...xcludeNeighborsMultiNodeFullApiSelfTest.java | 36 ++++++++++++++++++++ ...dezvousAffinityMultiNodeFullApiSelfTest.java | 36 ++++++++++++++++++++ .../IgniteCacheFullApiSelfTestSuite.java | 8 +++++ 8 files changed, 172 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/ae32d866/modules/core/src/main/java/org/apache/ignite/cache/affinity/fair/FairAffinityFunction.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/fair/FairAffinityFunction.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/fair/FairAffinityFunction.java index e008470..648adf0 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/fair/FairAffinityFunction.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/fair/FairAffinityFunction.java @@ -92,6 +92,9 @@ public class FairAffinityFunction implements AffinityFunction { /** Exclude neighbors flag. */ private boolean exclNeighbors; + /** Exclude neighbors warning. */ + private transient boolean exclNeighborsWarn; + /** Logger instance. */ @LoggerResource private transient IgniteLogger log; @@ -260,7 +263,9 @@ public class FairAffinityFunction implements AffinityFunction { List<List<ClusterNode>> assignment = createCopy(ctx, neighborhoodMap); - int tiers = Math.min(ctx.backups() + 1, topSnapshot.size()); + int backups = ctx.backups(); + + int tiers = backups == Integer.MAX_VALUE ? topSnapshot.size() : Math.min(backups + 1, topSnapshot.size()); // Per tier pending partitions. Map<Integer, Queue<Integer>> pendingParts = new HashMap<>(); @@ -292,8 +297,12 @@ public class FairAffinityFunction implements AffinityFunction { balance(tier, pendingParts, fullMap, topSnapshot, true); - LT.warn(log, null, "Affinity function excludeNeighbors property is ignored " + - "because topology has no enough nodes to assign backups."); + if (!exclNeighborsWarn) { + LT.warn(log, null, "Affinity function excludeNeighbors property is ignored " + + "because topology has no enough nodes to assign backups."); + + exclNeighborsWarn = true; + } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/ae32d866/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java index c7ee006..797fd3c 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java @@ -105,6 +105,9 @@ public class RendezvousAffinityFunction implements AffinityFunction, Externaliza /** Exclude neighbors flag. */ private boolean exclNeighbors; + /** Exclude neighbors warning. */ + private transient boolean exclNeighborsWarn; + /** Optional backup filter. First node is primary, second node is a node being tested. */ private IgniteBiPredicate<ClusterNode, ClusterNode> backupFilter; @@ -408,8 +411,12 @@ public class RendezvousAffinityFunction implements AffinityFunction, Externaliza res.add(next.get2()); } - LT.warn(log, null, "Affinity function excludeNeighbors property is ignored " + - "because topology has no enough nodes to assign backups."); + if (!exclNeighborsWarn) { + LT.warn(log, null, "Affinity function excludeNeighbors property is ignored " + + "because topology has no enough nodes to assign backups."); + + exclNeighborsWarn = true; + } } assert res.size() <= primaryAndBackups; http://git-wip-us.apache.org/repos/asf/ignite/blob/ae32d866/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 75d4c43..4c1529d 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 @@ -366,18 +366,6 @@ public class GridCacheProcessor extends GridProcessorAdapter { CacheType cacheType, @Nullable CacheStore cfgStore) throws IgniteCheckedException { if (cc.getCacheMode() == REPLICATED) { - if (cc.getAffinity() instanceof FairAffinityFunction) - throw new IgniteCheckedException("REPLICATED cache can not be started with FairAffinityFunction" + - " [cacheName=" + U.maskName(cc.getName()) + ']'); - - if (cc.getAffinity() instanceof RendezvousAffinityFunction) { - RendezvousAffinityFunction aff = (RendezvousAffinityFunction)cc.getAffinity(); - - if (aff.isExcludeNeighbors()) - throw new IgniteCheckedException("For REPLICATED cache flag 'excludeNeighbors' in " + - "RendezvousAffinityFunction cannot be set [cacheName=" + U.maskName(cc.getName()) + ']'); - } - if (cc.getNearConfiguration() != null && ctx.discovery().cacheAffinityNode(ctx.discovery().localNode(), cc.getName())) { U.warn(log, "Near cache cannot be used with REPLICATED cache, " + http://git-wip-us.apache.org/repos/asf/ignite/blob/ae32d866/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/CacheReplicatedFairAffinityExcludeNeighborsMultiNodeFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/CacheReplicatedFairAffinityExcludeNeighborsMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/CacheReplicatedFairAffinityExcludeNeighborsMultiNodeFullApiSelfTest.java new file mode 100644 index 0000000..8fdbb4a --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/CacheReplicatedFairAffinityExcludeNeighborsMultiNodeFullApiSelfTest.java @@ -0,0 +1,36 @@ +/* + * 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.distributed.replicated; + +import org.apache.ignite.cache.affinity.fair.FairAffinityFunction; +import org.apache.ignite.configuration.CacheConfiguration; + +/** + * Multi-node tests for partitioned cache with {@link FairAffinityFunction}. + */ +public class CacheReplicatedFairAffinityExcludeNeighborsMultiNodeFullApiSelfTest + extends GridCacheReplicatedMultiNodeFullApiSelfTest { + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { + CacheConfiguration cfg = super.cacheConfiguration(gridName); + + cfg.setAffinity(new FairAffinityFunction()); + + return cfg; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ae32d866/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/CacheReplicatedFairAffinityMultiNodeFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/CacheReplicatedFairAffinityMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/CacheReplicatedFairAffinityMultiNodeFullApiSelfTest.java new file mode 100644 index 0000000..ea65913 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/CacheReplicatedFairAffinityMultiNodeFullApiSelfTest.java @@ -0,0 +1,35 @@ +/* + * 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.distributed.replicated; + +import org.apache.ignite.cache.affinity.fair.FairAffinityFunction; +import org.apache.ignite.configuration.CacheConfiguration; + +/** + * Multi-node tests for partitioned cache with {@link FairAffinityFunction}. + */ +public class CacheReplicatedFairAffinityMultiNodeFullApiSelfTest extends GridCacheReplicatedMultiNodeFullApiSelfTest { + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { + CacheConfiguration cfg = super.cacheConfiguration(gridName); + + cfg.setAffinity(new FairAffinityFunction(false)); + + return cfg; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ae32d866/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/CacheReplicatedRendezvousAffinityExcludeNeighborsMultiNodeFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/CacheReplicatedRendezvousAffinityExcludeNeighborsMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/CacheReplicatedRendezvousAffinityExcludeNeighborsMultiNodeFullApiSelfTest.java new file mode 100644 index 0000000..8cd962f --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/CacheReplicatedRendezvousAffinityExcludeNeighborsMultiNodeFullApiSelfTest.java @@ -0,0 +1,36 @@ +/* + * 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.distributed.replicated; + +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; +import org.apache.ignite.configuration.CacheConfiguration; + +/** + * Multi-node tests for partitioned cache with {@link RendezvousAffinityFunction}. + */ +public class CacheReplicatedRendezvousAffinityExcludeNeighborsMultiNodeFullApiSelfTest + extends GridCacheReplicatedMultiNodeFullApiSelfTest { + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { + CacheConfiguration cfg = super.cacheConfiguration(gridName); + + cfg.setAffinity(new RendezvousAffinityFunction()); + + return cfg; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ae32d866/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/CacheReplicatedRendezvousAffinityMultiNodeFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/CacheReplicatedRendezvousAffinityMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/CacheReplicatedRendezvousAffinityMultiNodeFullApiSelfTest.java new file mode 100644 index 0000000..da7fd41 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/CacheReplicatedRendezvousAffinityMultiNodeFullApiSelfTest.java @@ -0,0 +1,36 @@ +/* + * 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.distributed.replicated; + +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; +import org.apache.ignite.configuration.CacheConfiguration; + +/** + * Multi-node tests for partitioned cache with {@link RendezvousAffinityFunction}. + */ +public class CacheReplicatedRendezvousAffinityMultiNodeFullApiSelfTest + extends GridCacheReplicatedMultiNodeFullApiSelfTest { + /** {@inheritDoc} */ + @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { + CacheConfiguration cfg = super.cacheConfiguration(gridName); + + cfg.setAffinity(new RendezvousAffinityFunction(false)); + + return cfg; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/ae32d866/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java index ff53250..78f82ad 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFullApiSelfTestSuite.java @@ -76,6 +76,10 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePar import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedOffHeapMultiNodeFullApiSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedOffHeapTieredFullApiSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedOffHeapTieredMultiNodeFullApiSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.CacheReplicatedFairAffinityExcludeNeighborsMultiNodeFullApiSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.CacheReplicatedFairAffinityMultiNodeFullApiSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.CacheReplicatedRendezvousAffinityExcludeNeighborsMultiNodeFullApiSelfTest; +import org.apache.ignite.internal.processors.cache.distributed.replicated.CacheReplicatedRendezvousAffinityMultiNodeFullApiSelfTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCachePartitionedFairAffinityMultiNodeFullApiSelfTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedAtomicFullApiSelfTest; import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedAtomicMultiNodeFullApiSelfTest; @@ -174,6 +178,10 @@ public class IgniteCacheFullApiSelfTestSuite extends TestSuite { suite.addTestSuite(GridCacheAtomicNearOnlyMultiNodeFullApiSelfTest.class); suite.addTestSuite(GridCacheAtomicNearOnlyMultiNodeP2PDisabledFullApiSelfTest.class); + suite.addTestSuite(CacheReplicatedFairAffinityExcludeNeighborsMultiNodeFullApiSelfTest.class); + suite.addTestSuite(CacheReplicatedFairAffinityMultiNodeFullApiSelfTest.class); + suite.addTestSuite(CacheReplicatedRendezvousAffinityExcludeNeighborsMultiNodeFullApiSelfTest.class); + suite.addTestSuite(CacheReplicatedRendezvousAffinityMultiNodeFullApiSelfTest.class); suite.addTestSuite(GridCachePartitionedFairAffinityMultiNodeFullApiSelfTest.class); suite.addTestSuite(GridCachePartitionedNearDisabledFairAffinityMultiNodeFullApiSelfTest.class); suite.addTestSuite(GridCacheAtomicFairAffinityMultiNodeFullApiSelfTest.class);
