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

boglesby pushed a commit to branch support/1.12
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/support/1.12 by this push:
     new 2ff0343  GEODE-10103: Retrieve full region path names (#7419)
2ff0343 is described below

commit 2ff0343454216171811275939032e92ae2ce63fd
Author: Barry Oglesby <bogle...@users.noreply.github.com>
AuthorDate: Wed Mar 9 07:11:30 2022 -1000

    GEODE-10103: Retrieve full region path names (#7419)
    
    * GEODE-10103: Retrieve full region path names
    
    This commit modifies RebalanceOperationPerformer getMemberRegionList
    to invoke listAllRegionPaths instead of listNames.
    
    (cherry picked from commit 8610ee70d470a8b30ab067db912bd0ac345d9df0)
    (cherry picked from commit d8f5afcecab615113c4326a32e9f56e0dfaa44f6)
    (cherry picked from commit 3b4ecd09a685b41e5b5d4df3927dd0e93ad87162)
    (cherry picked from commit ef29acb596039472a0f9a1c9b455942fe557d5b9)
---
 .../rest/RebalanceManagementDunitTest.java         |  10 +-
 .../operation/RebalanceOperationPerformer.java     |   8 +-
 .../RebalanceSubregionDistributedTest.java         | 111 +++++++++++++++++++++
 .../internal/cli/commands/RebalanceCommand.java    |   4 +-
 4 files changed, 123 insertions(+), 10 deletions(-)

diff --git 
a/geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/RebalanceManagementDunitTest.java
 
b/geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/RebalanceManagementDunitTest.java
index ae6e034..cc5c4b6 100644
--- 
a/geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/RebalanceManagementDunitTest.java
+++ 
b/geode-assembly/src/distributedTest/java/org/apache/geode/management/internal/rest/RebalanceManagementDunitTest.java
@@ -15,6 +15,7 @@
 
 package org.apache.geode.management.internal.rest;
 
+import static org.apache.geode.cache.Region.SEPARATOR;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.ArrayList;
@@ -94,7 +95,8 @@ public class RebalanceManagementDunitTest {
         .isGreaterThanOrEqualTo(cmr.getOperationStart().getTime());
     assertThat(result.getRebalanceRegionResults().size()).isEqualTo(2);
     RebalanceRegionResult firstRegionSummary = 
result.getRebalanceRegionResults().get(0);
-    assertThat(firstRegionSummary.getRegionName()).isIn("customers1", 
"customers2");
+    assertThat(firstRegionSummary.getRegionName()).isIn(SEPARATOR + 
"customers1",
+        SEPARATOR + "customers2");
   }
 
   @Test
@@ -109,7 +111,7 @@ public class RebalanceManagementDunitTest {
     RebalanceResult result = cmr.getFutureResult().get();
     assertThat(result.getRebalanceRegionResults().size()).isEqualTo(1);
     RebalanceRegionResult firstRegionSummary = 
result.getRebalanceRegionResults().get(0);
-    assertThat(firstRegionSummary.getRegionName()).isEqualTo("customers2");
+    assertThat(firstRegionSummary.getRegionName()).isEqualTo(SEPARATOR + 
"customers2");
     assertThat(firstRegionSummary.getBucketCreateBytes()).isEqualTo(0);
     
assertThat(firstRegionSummary.getTimeInMilliseconds()).isGreaterThanOrEqualTo(0);
   }
@@ -124,7 +126,7 @@ public class RebalanceManagementDunitTest {
     RebalanceResult result = cmr.getFutureResult().get();
     assertThat(result.getRebalanceRegionResults().size()).isEqualTo(1);
     RebalanceRegionResult firstRegionSummary = 
result.getRebalanceRegionResults().get(0);
-    assertThat(firstRegionSummary.getRegionName()).isEqualTo("customers2");
+    assertThat(firstRegionSummary.getRegionName()).isEqualTo(SEPARATOR + 
"customers2");
     assertThat(firstRegionSummary.getBucketCreateBytes()).isEqualTo(0);
     
assertThat(firstRegionSummary.getTimeInMilliseconds()).isGreaterThanOrEqualTo(0);
   }
@@ -161,7 +163,7 @@ public class RebalanceManagementDunitTest {
     RebalanceResult result = cmr.getFutureResult().get();
     assertThat(result.getRebalanceRegionResults().size()).isEqualTo(1);
     RebalanceRegionResult firstRegionSummary = 
result.getRebalanceRegionResults().get(0);
-    assertThat(firstRegionSummary.getRegionName()).isEqualTo("customers1");
+    assertThat(firstRegionSummary.getRegionName()).isEqualTo(SEPARATOR + 
"customers1");
     assertThat(firstRegionSummary.getBucketCreateBytes()).isEqualTo(0);
     
assertThat(firstRegionSummary.getTimeInMilliseconds()).isGreaterThanOrEqualTo(0);
   }
diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/operation/RebalanceOperationPerformer.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/operation/RebalanceOperationPerformer.java
index e59b46d..d9b1956 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/operation/RebalanceOperationPerformer.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/operation/RebalanceOperationPerformer.java
@@ -157,7 +157,7 @@ public class RebalanceOperationPerformer {
 
       // translate to the return type we want
       RebalanceRegionResultImpl result = new RebalanceRegionResultImpl();
-      result.setRegionName(regionName.replace("/", ""));
+      result.setRegionName(regionName);
       result.setBucketCreateBytes(results.getTotalBucketCreateBytes());
       
result.setBucketCreateTimeInMilliseconds(results.getTotalBucketCreateTime());
       
result.setBucketCreatesCompleted(results.getTotalBucketCreatesCompleted());
@@ -206,8 +206,8 @@ public class RebalanceOperationPerformer {
   private static List<MemberPRInfo> getMemberRegionList(InternalCache cache,
       List<String> listExcludedRegion) {
     List<MemberPRInfo> listMemberPRInfo = new ArrayList<>();
-    String[] listDSRegions =
-        
ManagementService.getManagementService(cache).getDistributedSystemMXBean().listRegions();
+    String[] listDSRegions = ManagementService.getManagementService(cache)
+        .getDistributedSystemMXBean().listAllRegionPaths();
     final Set<DistributedMember> dsMembers = 
ManagementUtils.getAllMembers(cache);
 
     for (String regionName : listDSRegions) {
@@ -451,7 +451,7 @@ public class RebalanceOperationPerformer {
     
result.setPrimaryTransferTimeInMilliseconds(Long.parseLong(rstList.get(6)));
     result.setPrimaryTransfersCompleted(Integer.parseInt(rstList.get(7)));
     result.setTimeInMilliseconds(Long.parseLong(rstList.get(8)));
-    result.setRegionName(rstList.get(9).replace("/", ""));
+    result.setRegionName(rstList.get(9));
 
     return result;
   }
diff --git 
a/geode-gfsh/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RebalanceSubregionDistributedTest.java
 
b/geode-gfsh/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RebalanceSubregionDistributedTest.java
new file mode 100644
index 0000000..e1e294c
--- /dev/null
+++ 
b/geode-gfsh/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/RebalanceSubregionDistributedTest.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+package org.apache.geode.management.internal.cli.commands;
+
+import static org.apache.geode.cache.Region.SEPARATOR;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.IntStream;
+
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.geode.cache.PartitionAttributesFactory;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionFactory;
+import org.apache.geode.cache.RegionShortcut;
+import org.apache.geode.management.internal.cli.result.model.ResultModel;
+import 
org.apache.geode.management.internal.cli.result.model.TabularResultModel;
+import org.apache.geode.test.dunit.rules.ClusterStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.rules.GfshCommandRule;
+import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
+
+public class RebalanceSubregionDistributedTest implements Serializable {
+
+  @Rule
+  public ClusterStartupRule cluster = new ClusterStartupRule();
+
+  @ClassRule
+  public static GfshCommandRule gfsh = new GfshCommandRule();
+
+  @Rule
+  public SerializableTestName testName = new SerializableTestName();
+
+  private static final String ROOT_REGION_NAME = "root";
+
+  @Test
+  public void testRebalanceSubregion() throws Exception {
+    // Start locator
+    MemberVM locator = cluster.startLocatorVM(0);
+
+    // Start 2 servers
+    MemberVM server1 = cluster.startServerVM(1, locator.getPort());
+    MemberVM server2 = cluster.startServerVM(2, locator.getPort());
+
+    // Create region in server1
+    String regionName = testName.getMethodName();
+    server1.invoke(() -> createSubregion(regionName));
+
+    // Do puts in server1
+    server1.invoke(() -> doPuts(regionName));
+
+    // Create region in server2
+    server2.invoke(() -> createSubregion(regionName));
+
+    // Make sure the locator has the MBean
+    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(
+        SEPARATOR + ROOT_REGION_NAME + SEPARATOR + regionName, 2);
+
+    // Connect gfsh to locator
+    gfsh.connectAndVerify(locator);
+
+    // Execute rebalance and verify it is successful
+    gfsh.executeAndAssertThat("rebalance").statusIsSuccess();
+
+    // Verify the results
+    ResultModel result = gfsh.getCommandResult().getResultData();
+    List<TabularResultModel> tableSections = result.getTableSections();
+    assertThat(tableSections.size()).isEqualTo(1);
+    assertThat(tableSections.get(0).getHeader()
+        .contains(SEPARATOR + ROOT_REGION_NAME + SEPARATOR + 
regionName)).isTrue();
+  }
+
+  private void createSubregion(String regionName) {
+    // Create the root region
+    RegionFactory<Object, Object> rootRegionFactory =
+        Objects.requireNonNull(ClusterStartupRule.getCache())
+            .createRegionFactory(RegionShortcut.REPLICATE);
+    Region<Object, Object> rootRegion = 
rootRegionFactory.create(ROOT_REGION_NAME);
+
+    // Create the subregion
+    RegionFactory<Integer, Integer> partitionedRegionFactory =
+        Objects.requireNonNull(ClusterStartupRule.getCache())
+            .createRegionFactory(RegionShortcut.PARTITION);
+    partitionedRegionFactory
+        .setPartitionAttributes(new PartitionAttributesFactory<Integer, 
Integer>().create());
+    partitionedRegionFactory.createSubregion(rootRegion, regionName);
+  }
+
+  private void doPuts(String regionName) {
+    Region<Integer, Integer> subregion = 
Objects.requireNonNull(ClusterStartupRule.getCache())
+        .getRegion(SEPARATOR + ROOT_REGION_NAME + SEPARATOR + regionName);
+    IntStream.range(0, 112).forEach(i -> subregion.put(i, i));
+  }
+}
diff --git 
a/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/RebalanceCommand.java
 
b/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/RebalanceCommand.java
index 51a3dd7..781a7b2 100644
--- 
a/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/RebalanceCommand.java
+++ 
b/geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/commands/RebalanceCommand.java
@@ -172,9 +172,9 @@ public class RebalanceCommand extends GfshCommand {
 
     String headerText;
     if (simulate) {
-      headerText = "Simulated partition regions";
+      headerText = "Simulated rebalance of partitioned region";
     } else {
-      headerText = "Rebalanced partition regions";
+      headerText = "Rebalanced partitioned region";
     }
     for (int i = resultItemCount; i < rstlist.size(); i++) {
       headerText = headerText + " " + rstlist.get(i);

Reply via email to