IGNITE-8904 Add rebalanceThreadPoolSize to nodes configuration consistency check

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/b4909822
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b4909822
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b4909822

Branch: refs/heads/ignite-8446
Commit: b4909822de5885f8556dc2b9759f0a80df6c4aeb
Parents: 7dc7371
Author: Pavel Kovalenko <jokse...@gmail.com>
Authored: Fri Jul 6 23:00:25 2018 +0300
Committer: Ivan Rakov <ira...@apache.org>
Committed: Fri Jul 6 23:00:25 2018 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    |  2 +
 .../ignite/internal/IgniteNodeAttributes.java   |  3 ++
 .../processors/cache/GridCacheProcessor.java    | 24 +++++++++
 .../CacheRebalanceConfigValidationTest.java     | 55 ++++++++++++++++++++
 .../ignite/testsuites/IgniteBasicTestSuite.java |  3 ++
 5 files changed, 87 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b4909822/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 270a014..4687114 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
@@ -258,6 +258,7 @@ import static 
org.apache.ignite.internal.IgniteNodeAttributes.ATTR_OFFHEAP_SIZE;
 import static 
org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PEER_CLASSLOADING;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PHY_RAM;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PREFIX;
+import static 
org.apache.ignite.internal.IgniteNodeAttributes.ATTR_REBALANCE_POOL_SIZE;
 import static 
org.apache.ignite.internal.IgniteNodeAttributes.ATTR_RESTART_ENABLED;
 import static 
org.apache.ignite.internal.IgniteNodeAttributes.ATTR_REST_PORT_RANGE;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_SPI_CLASS;
@@ -1523,6 +1524,7 @@ public class IgniteKernal implements IgniteEx, 
IgniteMXBean, Externalizable {
      */
     @SuppressWarnings({"SuspiciousMethodCalls", "unchecked", 
"TypeMayBeWeakened"})
     private void fillNodeAttributes(boolean notifyEnabled) throws 
IgniteCheckedException {
+        ctx.addNodeAttribute(ATTR_REBALANCE_POOL_SIZE, 
configuration().getRebalanceThreadPoolSize());
         ctx.addNodeAttribute(ATTR_DATA_STREAMER_POOL_SIZE, 
configuration().getDataStreamerThreadPoolSize());
 
         final String[] incProps = cfg.getIncludeProperties();

http://git-wip-us.apache.org/repos/asf/ignite/blob/b4909822/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
index 6a4beeb..663a6f9 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
@@ -199,6 +199,9 @@ public final class IgniteNodeAttributes {
     /** User authentication enabled flag. */
     public static final String ATTR_AUTHENTICATION_ENABLED = ATTR_PREFIX + 
".authentication.enabled";
 
+    /** Rebalance thread pool size. */
+    public static final String ATTR_REBALANCE_POOL_SIZE = ATTR_PREFIX + 
".rebalance.pool.size";
+
     /**
      * Enforces singleton.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/b4909822/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 ad986f6..99bb4cb 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
@@ -925,6 +925,8 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
             if 
(Boolean.TRUE.equals(n.attribute(ATTR_CONSISTENCY_CHECK_SKIPPED)))
                 continue;
 
+            checkRebalanceConfiguration(n);
+
             checkTransactionConfiguration(n);
 
             checkMemoryConfiguration(n);
@@ -3670,6 +3672,28 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
     }
 
     /**
+     * @param rmt Remote node to check.
+     * @throws IgniteCheckedException If check failed.
+     */
+    private void checkRebalanceConfiguration(ClusterNode rmt) throws 
IgniteCheckedException {
+        ClusterNode locNode = ctx.discovery().localNode();
+
+        if (ctx.config().isClientMode() || locNode.isDaemon() || 
rmt.isClient() || rmt.isDaemon())
+            return;
+
+        Integer rebalanceThreadPoolSize = 
rmt.attribute(IgniteNodeAttributes.ATTR_REBALANCE_POOL_SIZE);
+
+        if (rebalanceThreadPoolSize != null && rebalanceThreadPoolSize != 
ctx.config().getRebalanceThreadPoolSize()) {
+            throw new IgniteCheckedException("Rebalance configuration mismatch 
(fix configuration or set -D" +
+                IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK + "=true system 
property)." +
+                " Different values of such parameter may lead to rebalance 
process instability and hanging. " +
+                " [rmtNodeId=" + rmt.id() +
+                ", locRebalanceThreadPoolSize = " + 
ctx.config().getRebalanceThreadPoolSize() +
+                ", rmtRebalanceThreadPoolSize = " + rebalanceThreadPoolSize + 
"]");
+        }
+    }
+
+    /**
      * @param cfg Cache configuration.
      * @return Query manager.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/b4909822/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRebalanceConfigValidationTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRebalanceConfigValidationTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRebalanceConfigValidationTest.java
new file mode 100644
index 0000000..2f31b31
--- /dev/null
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheRebalanceConfigValidationTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.IgniteCheckedException;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class CacheRebalanceConfigValidationTest extends GridCommonAbstractTest 
{
+    /** Rebalance pool size. */
+    private int rebalancePoolSize;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        cfg.setRebalanceThreadPoolSize(rebalancePoolSize);
+
+        return cfg;
+    }
+
+    /**
+     * Checks that node is not allowed to join to cluster if has different 
value of {@link IgniteConfiguration#rebalanceThreadPoolSize}.
+     *
+     * @throws Exception If failed.
+     */
+    public void testParameterConsistency() throws Exception {
+        rebalancePoolSize = 2;
+
+        startGrid(0);
+
+        rebalancePoolSize = 1;
+
+        GridTestUtils.assertThrows(log, () -> startGrid(1), 
IgniteCheckedException.class, "Rebalance configuration mismatch");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/b4909822/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index 08a77d9..a107ac9 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -47,6 +47,7 @@ import org.apache.ignite.internal.TransactionsMXBeanImplTest;
 import org.apache.ignite.internal.managers.IgniteDiagnosticMessagesTest;
 import 
org.apache.ignite.internal.processors.affinity.GridAffinityProcessorMemoryLeakTest;
 import 
org.apache.ignite.internal.processors.affinity.GridAffinityProcessorRendezvousSelfTest;
+import 
org.apache.ignite.internal.processors.cache.CacheRebalanceConfigValidationTest;
 import 
org.apache.ignite.internal.processors.cache.GridLocalIgniteSerializationTest;
 import 
org.apache.ignite.internal.processors.cache.GridProjectionForCachesOnDaemonNodeSelfTest;
 import 
org.apache.ignite.internal.processors.cache.IgniteDaemonNodeMarshallerCacheTest;
@@ -213,6 +214,8 @@ public class IgniteBasicTestSuite extends TestSuite {
 
         suite.addTestSuite(AtomicOperationsInTxTest.class);
 
+        suite.addTestSuite(CacheRebalanceConfigValidationTest.class);
+
         return suite;
     }
 }

Reply via email to