ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [ignite] branch master updated: IGNITE-13495: fix ZookeeperDiscoveryImpl#getCoordinator() (#8313)
Date Mon, 05 Oct 2020 12:26:15 GMT
This is an automated email from the ASF dual-hosted git repository.

av pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new f9898b2  IGNITE-13495: fix ZookeeperDiscoveryImpl#getCoordinator() (#8313)
f9898b2 is described below

commit f9898b2d7c17d3ab40940dbfd46cdbcae68d5698
Author: Sergei Ryzhov <s.vi.ryzhov@gmail.com>
AuthorDate: Mon Oct 5 15:25:53 2020 +0300

    IGNITE-13495: fix ZookeeperDiscoveryImpl#getCoordinator() (#8313)
---
 .../discovery/zk/internal/ZookeeperDiscoveryImpl.java  |  8 +++++---
 .../zk/internal/ZookeeperDiscoveryMiscTest.java        | 18 ++++++++++++++++++
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java
b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java
index 37ba43c..e9196f2 100644
--- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java
+++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java
@@ -4582,9 +4582,11 @@ public class ZookeeperDiscoveryImpl {
 
     /** */
     public UUID getCoordinator() {
-        Map.Entry<Long, ZookeeperClusterNode> e = rtState.top.nodesByOrder.firstEntry();
-
-        return e != null ? e.getValue().id() : null;
+        return rtState.top.nodesByOrder.values().stream()
+                .filter(n -> !n.isClient() && !n.isDaemon())
+                .map(ZookeeperClusterNode::id)
+                .findFirst()
+                .orElse(null);
     }
 
     /** */
diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryMiscTest.java
b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryMiscTest.java
index 07a1c40..c644a4b 100644
--- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryMiscTest.java
+++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryMiscTest.java
@@ -245,6 +245,24 @@ public class ZookeeperDiscoveryMiscTest extends ZookeeperDiscoverySpiTestBase
{
      * @throws Exception If failed.
      */
     @Test
+    public void testMbeanGetCoordinator() throws Exception {
+        startGrid(0);
+        startClientGrid(1);
+        IgniteEx srv2 = startGrid(2);
+
+        ZookeeperDiscoverySpiMBean mbean = getMxBean(srv2.context().igniteInstanceName(),
"SPIs",
+                ZookeeperDiscoverySpi.class, ZookeeperDiscoverySpiMBean.class);
+
+        stopGrid(0);
+
+        assertEquals(mbean.getCoordinator(), srv2.localNode().id());
+        assertEquals(mbean.getCoordinatorNodeFormatted(), String.valueOf(srv2.localNode()));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    @Test
     public void testClientNodesStatus() throws Exception {
         startGrid(0);
 


Mime
View raw message