helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject helix git commit: [HELIX-779] do not clean list field in maintenance rebalancer for new resources
Date Thu, 01 Nov 2018 18:44:49 GMT
Repository: helix
Updated Branches:
  refs/heads/master 89f351558 -> bfaa83995


[HELIX-779] do not clean list field in maintenance rebalancer for new resources


Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/bfaa8399
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/bfaa8399
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/bfaa8399

Branch: refs/heads/master
Commit: bfaa8399529b6e63b307c1fbe60903c3ca08fbb1
Parents: 89f3515
Author: Harry Zhang <hrzhang@linkedin.com>
Authored: Thu Oct 4 15:50:16 2018 -0700
Committer: Harry Zhang <hrzhang@linkedin.com>
Committed: Thu Nov 1 10:57:44 2018 -0700

----------------------------------------------------------------------
 .../rebalancer/MaintenanceRebalancer.java       |  7 ++++++-
 .../controller/TestClusterMaintenanceMode.java  | 22 ++++++++++++++++----
 2 files changed, 24 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/bfaa8399/helix-core/src/main/java/org/apache/helix/controller/rebalancer/MaintenanceRebalancer.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/MaintenanceRebalancer.java
b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/MaintenanceRebalancer.java
index 3de3a3d..8bcf999 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/MaintenanceRebalancer.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/MaintenanceRebalancer.java
@@ -24,7 +24,12 @@ public class MaintenanceRebalancer extends SemiAutoRebalancer {
     if (currentStateMap == null || currentStateMap.size() == 0) {
       LOG.warn(String
           .format("No new partition will be assigned for %s in maintenance mode", resourceName));
-      currentIdealState.setPreferenceLists(Collections.EMPTY_MAP);
+
+      // Clear all preference lists, if the resource has not yet been rebalanced,
+      // leave it as is
+      for (List<String> pList : currentIdealState.getPreferenceLists().values()) {
+        pList.clear();
+      }
       return currentIdealState;
     }
 

http://git-wip-us.apache.org/repos/asf/helix/blob/bfaa8399/helix-core/src/test/java/org/apache/helix/integration/controller/TestClusterMaintenanceMode.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/controller/TestClusterMaintenanceMode.java
b/helix-core/src/test/java/org/apache/helix/integration/controller/TestClusterMaintenanceMode.java
index 4e4771b..2eb8034 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/controller/TestClusterMaintenanceMode.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/controller/TestClusterMaintenanceMode.java
@@ -13,6 +13,8 @@ import org.testng.annotations.Test;
 
 public class TestClusterMaintenanceMode extends TaskTestBase {
   MockParticipantManager _newInstance;
+  private String newResourceAddedDuringMaintenanceMode =
+      String.format("%s_%s", WorkflowGenerator.DEFAULT_TGT_DB, 1);
 
   @BeforeClass
   public void beforeClass() throws Exception {
@@ -53,13 +55,13 @@ public class TestClusterMaintenanceMode extends TaskTestBase {
   @Test (dependsOnMethods = "testMaintenanceModeAddNewInstance")
   public void testMaintenanceModeAddNewResource() throws InterruptedException {
     _gSetupTool.getClusterManagementTool()
-        .addResource(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + 1, 7, "MasterSlave",
+        .addResource(CLUSTER_NAME, newResourceAddedDuringMaintenanceMode, 7, "MasterSlave",
             IdealState.RebalanceMode.FULL_AUTO.name());
     _gSetupTool.getClusterManagementTool()
-        .rebalance(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + 1, 3);
+        .rebalance(CLUSTER_NAME, newResourceAddedDuringMaintenanceMode, 3);
     Assert.assertTrue(_clusterVerifier.verifyByPolling());
     ExternalView externalView = _gSetupTool.getClusterManagementTool()
-        .getResourceExternalView(CLUSTER_NAME, WorkflowGenerator.DEFAULT_TGT_DB + 1);
+        .getResourceExternalView(CLUSTER_NAME, newResourceAddedDuringMaintenanceMode);
     Assert.assertNull(externalView);
   }
 
@@ -88,4 +90,16 @@ public class TestClusterMaintenanceMode extends TaskTestBase {
       }
     }
   }
-}
\ No newline at end of file
+
+  @Test (dependsOnMethods = "testMaintenanceModeInstanceBack")
+  public void testExitMaintenanceModeNewResourceRecovery() throws InterruptedException {
+    _gSetupTool.getClusterManagementTool().enableMaintenanceMode(CLUSTER_NAME, false);
+    Assert.assertTrue(_clusterVerifier.verifyByPolling());
+    ExternalView externalView = _gSetupTool.getClusterManagementTool()
+        .getResourceExternalView(CLUSTER_NAME, newResourceAddedDuringMaintenanceMode);
+    Assert.assertEquals(externalView.getRecord().getMapFields().size(), 7);
+    for (Map<String, String> stateMap : externalView.getRecord().getMapFields().values())
{
+      Assert.assertTrue(stateMap.values().contains("MASTER"));
+    }
+  }
+}


Mime
View raw message