ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ira...@apache.org
Subject ignite git commit: IGNITE-8491 Add JMX flag: Is the node in baseline or not - Fixes #4010.
Date Fri, 18 May 2018 14:00:22 GMT
Repository: ignite
Updated Branches:
  refs/heads/master 722bb1d24 -> f8ae30d5d


IGNITE-8491 Add JMX flag: Is the node in baseline or not - Fixes #4010.

Signed-off-by: Ivan Rakov <irakov@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f8ae30d5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f8ae30d5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f8ae30d5

Branch: refs/heads/master
Commit: f8ae30d5dd426d995d7bae98674712055895bcb5
Parents: 722bb1d
Author: vd-pyatkov <vpyatkov@gridgain.com>
Authored: Fri May 18 16:59:14 2018 +0300
Committer: Ivan Rakov <irakov@apache.org>
Committed: Fri May 18 16:59:14 2018 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    | 13 +++
 .../org/apache/ignite/mxbean/IgniteMXBean.java  |  8 ++
 .../util/mbeans/GridMBeanBaselineTest.java      | 96 ++++++++++++++++++++
 3 files changed, 117 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f8ae30d5/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 6a40e38..c16af70 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
@@ -106,6 +106,7 @@ import org.apache.ignite.internal.binary.BinaryUtils;
 import org.apache.ignite.internal.cluster.ClusterGroupAdapter;
 import org.apache.ignite.internal.cluster.IgniteClusterEx;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState;
 import org.apache.ignite.internal.processors.failure.FailureProcessor;
 import org.apache.ignite.internal.managers.GridManager;
 import org.apache.ignite.internal.managers.checkpoint.GridCheckpointManager;
@@ -525,6 +526,18 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isNodeInBaseline() {
+        ClusterNode locNode = localNode();
+
+        if (locNode.isClient() || locNode.isDaemon())
+            return false;
+
+        DiscoveryDataClusterState clusterState = ctx.state().clusterState();
+
+        return clusterState.hasBaselineTopology() && CU.baselineNode(locNode, clusterState);
+    }
+
+    /** {@inheritDoc} */
     @Override public String getCommunicationSpiFormatted() {
         assert cfg != null;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/f8ae30d5/modules/core/src/main/java/org/apache/ignite/mxbean/IgniteMXBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/mxbean/IgniteMXBean.java b/modules/core/src/main/java/org/apache/ignite/mxbean/IgniteMXBean.java
index cc4bc5b..e0a5fb5 100644
--- a/modules/core/src/main/java/org/apache/ignite/mxbean/IgniteMXBean.java
+++ b/modules/core/src/main/java/org/apache/ignite/mxbean/IgniteMXBean.java
@@ -439,6 +439,14 @@ public interface IgniteMXBean {
     public String getCurrentCoordinatorFormatted();
 
     /**
+     * Gets a flag whether local node is in baseline. Returns false if baseline topology
is not established.
+     *
+     * @return Return a baseline flag.
+     */
+    @MXBeanDescription("Baseline node flag.")
+    public boolean isNodeInBaseline();
+
+    /**
      * Runs IO latency test against all remote server nodes in cluster.
      *
      * @param warmup Warmup duration in milliseconds.

http://git-wip-us.apache.org/repos/asf/ignite/blob/f8ae30d5/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanBaselineTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanBaselineTest.java
b/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanBaselineTest.java
new file mode 100644
index 0000000..00dce83
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/util/mbeans/GridMBeanBaselineTest.java
@@ -0,0 +1,96 @@
+package org.apache.ignite.util.mbeans;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cluster.BaselineNode;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.mxbean.IgniteMXBean;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ *
+ */
+public class GridMBeanBaselineTest extends GridCommonAbstractTest {
+    /** Client index. */
+    private static final int CLIENT_IDX = 33;
+
+    /** Nodes. */
+    public static final int NODES = 2;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws
Exception {
+        return super.getConfiguration(igniteInstanceName)
+            .setClientMode(igniteInstanceName.equals(getTestIgniteInstanceName(CLIENT_IDX)))
+            .setDataStorageConfiguration(new DataStorageConfiguration()
+                .setCheckpointFrequency(2_000)
+                .setDefaultDataRegionConfiguration(
+                    new DataRegionConfiguration()
+                        .setPersistenceEnabled(true)))
+            .setDataStorageConfiguration(
+                new DataStorageConfiguration()
+                    .setDefaultDataRegionConfiguration(
+                        new DataRegionConfiguration()
+                            .setMaxSize(200L * 1024 * 1024)
+                            .setPersistenceEnabled(true)));
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        cleanPersistenceDir();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        cleanPersistenceDir();
+    }
+
+    /**
+     * Test ignite kernal node in baseline test.
+     *
+     * @throws Exception Thrown if test fails.
+     */
+    public void testIgniteKernalNodeInBaselineTest() throws Exception {
+        try {
+            IgniteEx ignite0 = (IgniteEx)startGrids(NODES);
+
+            startGrid(CLIENT_IDX);
+
+            ignite0.cluster().active(true);
+
+            checkBaselineInFromMBean(ignite0);
+
+            startGrid(NODES);
+
+            checkBaselineInFromMBean(ignite0);
+
+            ignite0.cluster().setBaselineTopology(ignite0.cluster().topologyVersion());
+
+            checkBaselineInFromMBean(ignite0);
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @param ignite Ignite.
+     */
+    private void checkBaselineInFromMBean(IgniteEx ignite) {
+        Set<Object> cIds = ignite.cluster().currentBaselineTopology().stream()
+            .map(BaselineNode::consistentId)
+            .collect(Collectors.toSet());
+
+        for (Ignite ign : Ignition.allGrids()) {
+            IgniteMXBean igniteMXBean = (IgniteMXBean)ign;
+
+            assertEquals(cIds.contains(ign.cluster().localNode().consistentId()),
+                igniteMXBean.isNodeInBaseline());
+        }
+    }
+
+}


Mime
View raw message