Skip to content

Commit

Permalink
GEODE-9101: fix VisibleNode attribute (#7829)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkevo authored Jul 28, 2022
1 parent 649015b commit e2f7fe0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -86,22 +86,22 @@ 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
server.invoke(() -> {
InternalCache internalCache2 = ClusterStartupRule.getCache();
DistributionManager distributionManager2 = internalCache2.getDistributionManager();
DistributionStats distributionStats2 = (DistributionStats) distributionManager2.getStats();
assertThat(distributionStats2.getNodes()).isEqualTo(3);
assertThat(distributionStats2.getNodes()).isEqualTo(4);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e2f7fe0

Please sign in to comment.