diff --git a/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/DistributionStatsNodesDistributedTest.java b/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/DistributionStatsNodesDistributedTest.java index 3828e46c85a4..c11677378bc7 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/DistributionStatsNodesDistributedTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/DistributionStatsNodesDistributedTest.java @@ -46,8 +46,8 @@ public void before() throws Exception { @Test public void testNodesStatistic() { - // Verify DistributionStats nodes is 1 - server.invoke(() -> verifyNodesStatistic(1)); + // Verify DistributionStats nodes is 2 + server.invoke(() -> verifyNodesStatistic(2)); } @Test @@ -56,12 +56,12 @@ public void testDecrement() { DistributionManager distributionManager = internalCache.getDistributionManager(); DistributionStats distributionStats = (DistributionStats) distributionManager.getStats(); - assertThat(distributionStats.getNodes()).isEqualTo(2); + assertThat(distributionStats.getNodes()).isEqualTo(3); server.invoke(() -> ClusterStartupRule.getCache().getDistributionManager().getDistribution() .disconnect(false)); - assertThat(distributionStats.getNodes()).isEqualTo(1); + assertThat(distributionStats.getNodes()).isEqualTo(2); } @Test @@ -71,12 +71,12 @@ public void testDuplicateEntry() { DistributionManager distributionManager = internalCache.getDistributionManager(); DistributionStats distributionStats = (DistributionStats) distributionManager.getStats(); - assertThat(distributionStats.getNodes()).isEqualTo(2); + assertThat(distributionStats.getNodes()).isEqualTo(3); server.stop(); cluster.startServerVM(1, s -> s.withConnectionToLocator(locatorPort)); - assertThat(distributionStats.getNodes()).isEqualTo(2); + assertThat(distributionStats.getNodes()).isEqualTo(3); } @Test @@ -86,14 +86,14 @@ public void testNewServerWillUpdateTheStats() { DistributionManager distributionManager = internalCache.getDistributionManager(); DistributionStats distributionStats = (DistributionStats) distributionManager.getStats(); - assertThat(distributionStats.getNodes()).isEqualTo(2); + assertThat(distributionStats.getNodes()).isEqualTo(3); VM server2VM = VM.getVM(2); server2VM.invoke(() -> { InternalCache internalCache3 = createCache(locatorPort); DistributionManager distributionManager3 = internalCache3.getDistributionManager(); DistributionStats distributionStats3 = (DistributionStats) distributionManager3.getStats(); - assertThat(distributionStats3.getNodes()).isEqualTo(3); + assertThat(distributionStats3.getNodes()).isEqualTo(4); }); // Verify DistributionStats nodes is updated @@ -101,7 +101,7 @@ public void testNewServerWillUpdateTheStats() { InternalCache internalCache2 = ClusterStartupRule.getCache(); DistributionManager distributionManager2 = internalCache2.getDistributionManager(); DistributionStats distributionStats2 = (DistributionStats) distributionManager2.getStats(); - assertThat(distributionStats2.getNodes()).isEqualTo(3); + assertThat(distributionStats2.getNodes()).isEqualTo(4); }); } diff --git a/geode-core/src/distributedTest/java/org/apache/geode/management/CacheManagementDUnitTest.java b/geode-core/src/distributedTest/java/org/apache/geode/management/CacheManagementDUnitTest.java index 9d6b9a6fc71e..2485fe1106cf 100644 --- a/geode-core/src/distributedTest/java/org/apache/geode/management/CacheManagementDUnitTest.java +++ b/geode-core/src/distributedTest/java/org/apache/geode/management/CacheManagementDUnitTest.java @@ -304,6 +304,18 @@ public void testRedundancyZone() { }); } + @Test + public void testVisibleNodes() { + this.managementTestRule.createMember(this.memberVMs[0]); + this.managementTestRule.createMember(this.memberVMs[1]); + + this.memberVMs[1].invoke("visibleNodes", () -> { + ManagementService service = this.managementTestRule.getExistingManagementService(); + MemberMXBean memberMXBean = service.getMemberMXBean(); + assertThat(memberMXBean.getVisibleNodes()).isEqualTo(3); + }); + } + private void verifyQueryMBeans(final VM managerVM) { managerVM.invoke("validateQueryMBeans", () -> { SystemManagementService service = managementTestRule.getSystemManagementService(); diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterDistributionManager.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterDistributionManager.java index 73d17ec575f1..307b4a1cb154 100644 --- a/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterDistributionManager.java +++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterDistributionManager.java @@ -1081,11 +1081,12 @@ private void addNewMember(InternalDistributedMember member) { handleConsoleStartup(member); break; case LOCATOR_DM_TYPE: + stats.setNodes(getDistributionManagerIds().size()); addMemberEvent(new MemberJoinedEvent(member)); break; case NORMAL_DM_TYPE: // Note test is under membersLock - stats.setNodes(getNormalDistributionManagerIds().size()); + stats.setNodes(getDistributionManagerIds().size()); addMemberEvent(new MemberJoinedEvent(member)); break; default: @@ -1916,7 +1917,7 @@ public void handleManagerDeparture(InternalDistributedMember theId, boolean memb } logger.info(msg, new Object[] {theId, prettifyReason(reason)}); executors.handleManagerDeparture(theId); - stats.setNodes(getNormalDistributionManagerIds().size()); + stats.setNodes(getDistributionManagerIds().size()); } private void handleManagerSuspect(InternalDistributedMember suspect,