This is an automated email from the ASF dual-hosted git repository.

mivanac pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 7cc14ee  GEODE-8547: Added impacts to show missing disk-stores (#5567)
7cc14ee is described below

commit 7cc14eef52e06fe1e8c56bd766df56297b9c9ff8
Author: Mario Ivanac <48509724+miva...@users.noreply.github.com>
AuthorDate: Thu Nov 5 11:06:06 2020 +0100

    GEODE-8547: Added impacts to show missing disk-stores (#5567)
    
    * GEODE-8547: Added impacts to show missing disk-stores
    
    * GEODE-8547: Added DUnit test
    
    * GEODE-8547: update after comments
    
    * GEODE-8547: remove unused variables
    
    * GEODE-8547: update test
---
 .../ShowMissingDiskStoreCommandDUnitTest.java      | 57 ++++++++++++++++++++++
 .../cli/commands/ShowMissingDiskStoreCommand.java  | 16 +++---
 2 files changed, 65 insertions(+), 8 deletions(-)

diff --git 
a/geode-gfsh/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoreCommandDUnitTest.java
 
b/geode-gfsh/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoreCommandDUnitTest.java
index 254bd3c..160b92d 100644
--- 
a/geode-gfsh/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoreCommandDUnitTest.java
+++ 
b/geode-gfsh/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoreCommandDUnitTest.java
@@ -28,15 +28,18 @@ import org.junit.rules.TestName;
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.distributed.DistributedSystemDisconnectedException;
 import org.apache.geode.management.internal.cli.result.CommandResult;
 import org.apache.geode.management.internal.cli.result.model.ResultModel;
 import 
org.apache.geode.management.internal.cli.result.model.TabularResultModel;
 import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
 import org.apache.geode.management.internal.i18n.CliStrings;
+import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.dunit.rules.ClusterStartupRule;
 import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.PersistenceTest;
 import org.apache.geode.test.junit.rules.GfshCommandRule;
+import org.apache.geode.test.junit.rules.LocatorStarterRule;
 
 @Category({PersistenceTest.class})
 public class ShowMissingDiskStoreCommandDUnitTest {
@@ -61,6 +64,7 @@ public class ShowMissingDiskStoreCommandDUnitTest {
     // start a server so that we can execute data commands that requires at 
least a server running
   }
 
+
   @Test
   public void showMissingDiskStoresDoesNotDuplicateDiskStores() {
     MemberVM server1 = lsRule.startServerVM(1, locator.getPort());
@@ -156,6 +160,59 @@ public class ShowMissingDiskStoreCommandDUnitTest {
     assertThat(missingDiskStoreIds).isNull();
   }
 
+
+  @Test
+  public void stopAllMembersAndStart2ndLocator() throws Exception {
+    
IgnoredException.addIgnoredException(DistributedSystemDisconnectedException.class);
+
+    MemberVM locator1 = lsRule.startLocatorVM(1, locator.getPort());
+
+    lsRule.startServerVM(2, locator.getPort(), locator1.getPort());
+    lsRule.startServerVM(3, locator.getPort(), locator1.getPort());
+
+    final String testRegionName = "regionA";
+
+    CommandStringBuilder createRegion = new 
CommandStringBuilder(CliStrings.CREATE_REGION)
+        .addOption(CliStrings.CREATE_REGION__REGION, testRegionName)
+        .addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT,
+            RegionShortcut.PARTITION_REDUNDANT.toString());
+    await().untilAsserted(() -> 
gfshConnector.executeAndAssertThat(createRegion.getCommandString())
+        .statusIsSuccess());
+
+    // stop locator1 before locator0
+    lsRule.stop(1, false);
+
+    lsRule.stop(2, false);
+
+    lsRule.stop(0, false);
+
+    lsRule.stop(3, false);
+    final int locatorPort = locator1.getPort();
+
+    // start stale locator
+    locator1.invokeAsync("restart locator in vm1", () -> {
+      LocatorStarterRule locatorStarter = new LocatorStarterRule();
+      locatorStarter.withName("locator-1");
+      locatorStarter.withPort(locatorPort);
+      locatorStarter.withAutoStart();
+      locatorStarter.before();
+    });
+
+    await().untilAsserted(() -> gfshConnector.connectAndVerify(locator1));
+
+    // execute show missing-disk-stores
+    await().untilAsserted(() -> {
+      CommandStringBuilder csb1 = new 
CommandStringBuilder(CliStrings.SHOW_MISSING_DISK_STORE);
+      @SuppressWarnings("deprecation")
+      CommandResult commandResult = 
gfshConnector.executeCommand(csb1.getCommandString());
+      ResultModel result = commandResult.getResultData();
+      TabularResultModel tableSection = 
result.getTableSection("missing-disk-stores");
+      List<String> missingDiskStoreIds = tableSection.getValuesInColumn("Disk 
Store ID");
+      assertThat(missingDiskStoreIds).isNotNull();
+    });
+  }
+
+
   private void addData(MemberVM server1, String testRegionName) {
     server1.invoke(() -> {
       Region<Object, Object> region = 
CacheFactory.getAnyInstance().getRegion(testRegionName);
diff --git 
a/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoreCommand.java
 
b/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoreCommand.java
index 7095799..9c75f29 100644
--- 
a/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoreCommand.java
+++ 
b/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoreCommand.java
@@ -53,10 +53,11 @@ public class ShowMissingDiskStoreCommand extends 
GfshCommand {
     Set<DistributedMember> dataMembers =
         DiskStoreCommandsUtils.getNormalMembers((InternalCache) getCache());
 
-    if (dataMembers.isEmpty()) {
-      return 
ResultModel.createInfo(CliStrings.NO_CACHING_MEMBERS_FOUND_MESSAGE);
+    List<ColocatedRegionDetails> missingRegions = null;
+
+    if (!dataMembers.isEmpty()) {
+      missingRegions = getMissingColocatedRegionList(dataMembers);
     }
-    List<ColocatedRegionDetails> missingRegions = 
getMissingColocatedRegionList(dataMembers);
 
     DistributedSystemMXBean dsMXBean =
         
ManagementService.getManagementService(getCache()).getDistributedSystemMXBean();
@@ -94,12 +95,9 @@ public class ShowMissingDiskStoreCommand extends GfshCommand 
{
       final List<ColocatedRegionDetails> missingColocatedRegions) {
     ResultModel result = new ResultModel();
 
-    boolean hasMissingDiskStores = missingDiskStores.length != 0;
-    boolean hasMissingColocatedRegions = !missingColocatedRegions.isEmpty();
-
     TabularResultModel missingDiskStoreSection = 
result.addTable(MISSING_DISK_STORES_SECTION);
 
-    if (hasMissingDiskStores) {
+    if (missingDiskStores.length != 0) {
       missingDiskStoreSection.setHeader("Missing Disk Stores");
 
       for (PersistentMemberDetails persistentMemberDetails : 
missingDiskStores) {
@@ -113,7 +111,9 @@ public class ShowMissingDiskStoreCommand extends 
GfshCommand {
     }
 
     TabularResultModel missingRegionsSection = 
result.addTable(MISSING_COLOCATED_REGIONS_SECTION);
-    if (hasMissingColocatedRegions) {
+    if (missingColocatedRegions == null) {
+      missingRegionsSection.setHeader("No caching members found.");
+    } else if (!missingColocatedRegions.isEmpty()) {
       missingRegionsSection.setHeader("Missing Colocated Regions");
 
       for (ColocatedRegionDetails colocatedRegionDetails : 
missingColocatedRegions) {

Reply via email to