Repository: ignite Updated Branches: refs/heads/ignite-9720 d98bfd955 -> 2a52875fa
IGNITE-9719 Extra rebalanceThreadPoolSize check on client node - Fixes #4911. Signed-off-by: Ivan Rakov <ira...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/962d6a29 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/962d6a29 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/962d6a29 Branch: refs/heads/ignite-9720 Commit: 962d6a29716195c13519ca48b6d79f3b8541653c Parents: d4af213 Author: luchnikovnsk <luchnikov....@gmail.com> Authored: Tue Oct 23 11:16:40 2018 +0300 Committer: Ivan Rakov <ira...@apache.org> Committed: Tue Oct 23 11:16:40 2018 +0300 ---------------------------------------------------------------------- .../apache/ignite/internal/IgniteKernal.java | 32 +++++++++------ .../ignite/client/ClientConfigurationTest.java | 42 ++++++++++++++++++++ 2 files changed, 61 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/962d6a29/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java index 40347d7..1546da3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java @@ -2581,19 +2581,25 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable { * */ private void ackRebalanceConfiguration() throws IgniteCheckedException { - if (cfg.getSystemThreadPoolSize() <= cfg.getRebalanceThreadPoolSize()) - throw new IgniteCheckedException("Rebalance thread pool size exceed or equals System thread pool size. " + - "Change IgniteConfiguration.rebalanceThreadPoolSize property before next start."); - - if (cfg.getRebalanceThreadPoolSize() < 1) - throw new IgniteCheckedException("Rebalance thread pool size minimal allowed value is 1. " + - "Change IgniteConfiguration.rebalanceThreadPoolSize property before next start."); - - for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) { - if (ccfg.getRebalanceBatchesPrefetchCount() < 1) - throw new IgniteCheckedException("Rebalance batches prefetch count minimal allowed value is 1. " + - "Change CacheConfiguration.rebalanceBatchesPrefetchCount property before next start. " + - "[cache=" + ccfg.getName() + "]"); + if (cfg.isClientMode()) { + if (cfg.getRebalanceThreadPoolSize() != IgniteConfiguration.DFLT_REBALANCE_THREAD_POOL_SIZE) + U.warn(log, "Setting the rebalance pool size has no effect on the client mode"); + } + else { + if (cfg.getSystemThreadPoolSize() <= cfg.getRebalanceThreadPoolSize()) + throw new IgniteCheckedException("Rebalance thread pool size exceed or equals System thread pool size. " + + "Change IgniteConfiguration.rebalanceThreadPoolSize property before next start."); + + if (cfg.getRebalanceThreadPoolSize() < 1) + throw new IgniteCheckedException("Rebalance thread pool size minimal allowed value is 1. " + + "Change IgniteConfiguration.rebalanceThreadPoolSize property before next start."); + + for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) { + if (ccfg.getRebalanceBatchesPrefetchCount() < 1) + throw new IgniteCheckedException("Rebalance batches prefetch count minimal allowed value is 1. " + + "Change CacheConfiguration.rebalanceBatchesPrefetchCount property before next start. " + + "[cache=" + ccfg.getName() + "]"); + } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/962d6a29/modules/core/src/test/java/org/apache/ignite/client/ClientConfigurationTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/client/ClientConfigurationTest.java b/modules/core/src/test/java/org/apache/ignite/client/ClientConfigurationTest.java index bcc212a..287c6ec 100644 --- a/modules/core/src/test/java/org/apache/ignite/client/ClientConfigurationTest.java +++ b/modules/core/src/test/java/org/apache/ignite/client/ClientConfigurationTest.java @@ -25,9 +25,19 @@ import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Collections; +import java.util.Set; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import org.apache.ignite.Ignite; +import org.apache.ignite.Ignition; +import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.configuration.BinaryConfiguration; import org.apache.ignite.configuration.ClientConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.GridTestUtils; +import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.Timeout; @@ -73,4 +83,36 @@ public class ClientConfigurationTest { assertTrue(Comparers.equal(target, desTarget)); } + + /** + * Test check the case when {@link IgniteConfiguration#getRebalanceThreadPoolSize()} is equal to {@link + * IgniteConfiguration#getSystemThreadPoolSize()} + */ + @Test + public void testRebalanceThreadPoolSize() { + GridStringLogger gridStrLog = new GridStringLogger(); + gridStrLog.logLength(1024 * 100); + + IgniteConfiguration cci = Config.getServerConfiguration().setClientMode(true); + cci.setRebalanceThreadPoolSize(cci.getSystemThreadPoolSize()); + cci.setGridLogger(gridStrLog); + + try ( + Ignite si = Ignition.start(Config.getServerConfiguration()); + Ignite ci = Ignition.start(cci)) { + Set<ClusterNode> collect = si.cluster().nodes().stream() + .filter(new Predicate<ClusterNode>() { + @Override public boolean test(ClusterNode clusterNode) { + return clusterNode.isClient(); + } + }) + .collect(Collectors.toSet()); + + String log = gridStrLog.toString(); + boolean containsMsg = log.contains("Setting the rebalance pool size has no effect on the client mode"); + + Assert.assertTrue(containsMsg); + Assert.assertEquals(1, collect.size()); + } + } }