helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [helix] 11/13: Refactor freeze mode naming and getStatus default value (#1818)
Date Fri, 16 Jul 2021 21:03:18 GMT
This is an automated email from the ASF dual-hosted git repository.

hzlu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git

commit d2f5637f9d1a7cce54b024ac714d4552809ff2f9
Author: Huizhi Lu <5187721+huizhilu@users.noreply.github.com>
AuthorDate: Wed Jul 14 19:32:27 2021 -0700

    Refactor freeze mode naming and getStatus default value (#1818)
    
    Rename CLUSTER_PAUSE with CLUSTER_FREEZE mode.
    Change default return value for LiveInstance#getStatus(): null -> NORMAL. And fix tests
accordingly.
---
 .../helix/api/status/ClusterManagementMode.java       |  6 +++---
 .../stages/ManagementMessageGenerationPhase.java      |  4 +---
 .../helix/controller/stages/ManagementModeStage.java  |  8 +++-----
 .../org/apache/helix/manager/zk/ZKHelixAdmin.java     |  2 +-
 .../helix/messaging/handling/HelixTaskExecutor.java   |  3 ++-
 .../java/org/apache/helix/model/LiveInstance.java     |  6 ++++--
 .../stages/TestManagementMessageGeneration.java       |  2 +-
 .../controller/stages/TestManagementModeStage.java    |  4 ++--
 .../integration/controller/TestClusterFreezeMode.java | 10 +++++-----
 .../integration/paticipant/TestParticipantFreeze.java | 15 +++++++++------
 .../org/apache/helix/manager/zk/TestZkHelixAdmin.java |  4 ++--
 .../helix/model/TestControllerHistoryModel.java       |  2 +-
 .../java/org/apache/helix/model/TestLiveInstance.java |  4 +++-
 .../rest/server/resources/helix/ClusterAccessor.java  |  4 ++--
 .../apache/helix/rest/server/TestClusterAccessor.java | 19 ++++++++++---------
 15 files changed, 49 insertions(+), 44 deletions(-)

diff --git a/helix-core/src/main/java/org/apache/helix/api/status/ClusterManagementMode.java
b/helix-core/src/main/java/org/apache/helix/api/status/ClusterManagementMode.java
index 86817d1..a342a8c 100644
--- a/helix-core/src/main/java/org/apache/helix/api/status/ClusterManagementMode.java
+++ b/helix-core/src/main/java/org/apache/helix/api/status/ClusterManagementMode.java
@@ -33,10 +33,10 @@ public class ClusterManagementMode {
         NORMAL,
 
         /**
-         * Puts a cluster into pause mode, which will pause controller and participants.
+         * Puts a cluster into freeze mode, which will freeze controller and participants.
          * This can be used to retain the cluster state.
          */
-        CLUSTER_PAUSE,
+        CLUSTER_FREEZE,
 
         /** Pause controller only, but not participants. */
         CONTROLLER_PAUSE,
@@ -88,7 +88,7 @@ public class ClusterManagementMode {
      */
     public LiveInstance.LiveInstanceStatus getDesiredParticipantStatus() {
         switch (mode) {
-            case CLUSTER_PAUSE:
+            case CLUSTER_FREEZE:
                 return LiveInstance.LiveInstanceStatus.PAUSED;
             case NORMAL:
                 return LiveInstance.LiveInstanceStatus.NORMAL;
diff --git a/helix-core/src/main/java/org/apache/helix/controller/stages/ManagementMessageGenerationPhase.java
b/helix-core/src/main/java/org/apache/helix/controller/stages/ManagementMessageGenerationPhase.java
index c795deb..4479d50 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/stages/ManagementMessageGenerationPhase.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/stages/ManagementMessageGenerationPhase.java
@@ -96,9 +96,7 @@ public class ManagementMessageGenerationPhase extends MessageGenerationPhase
{
       LiveInstance liveInstance = liveInstanceMap.get(instanceName);
       Collection<Message> pendingMessages = allInstanceMessages.get(instanceName);
       String sessionId = liveInstance.getEphemeralOwner();
-      LiveInstanceStatus liveInstanceStatus = liveInstance.getStatus();
-      LiveInstanceStatus currentStatus = (liveInstanceStatus == null
-          ? LiveInstanceStatus.NORMAL : liveInstanceStatus);
+      LiveInstanceStatus currentStatus = liveInstance.getStatus();
 
       if (needStatusChangeMessage(pendingMessages, currentStatus, desiredStatus)) {
         Message statusChangeMessage = MessageUtil.createStatusChangeMessage(currentStatus,
diff --git a/helix-core/src/main/java/org/apache/helix/controller/stages/ManagementModeStage.java
b/helix-core/src/main/java/org/apache/helix/controller/stages/ManagementModeStage.java
index b639685..55a320a 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/stages/ManagementModeStage.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/stages/ManagementModeStage.java
@@ -30,7 +30,6 @@ import org.apache.helix.HelixManager;
 import org.apache.helix.PropertyKey;
 import org.apache.helix.PropertyType;
 import org.apache.helix.api.status.ClusterManagementMode;
-import org.apache.helix.controller.LogUtil;
 import org.apache.helix.controller.dataproviders.ManagementControllerDataProvider;
 import org.apache.helix.controller.pipeline.AbstractBaseStage;
 import org.apache.helix.controller.pipeline.StageException;
@@ -40,7 +39,6 @@ import org.apache.helix.model.LiveInstance;
 import org.apache.helix.model.LiveInstance.LiveInstanceStatus;
 import org.apache.helix.model.Message;
 import org.apache.helix.model.Message.MessageType;
-import org.apache.helix.model.Partition;
 import org.apache.helix.model.PauseSignal;
 import org.apache.helix.model.Resource;
 import org.apache.helix.util.HelixUtil;
@@ -104,7 +102,7 @@ public class ManagementModeStage extends AbstractBaseStage {
         status = ClusterManagementMode.Status.IN_PROGRESS;
       }
     } else if (pauseSignal.isClusterPause()) {
-      type = ClusterManagementMode.Type.CLUSTER_PAUSE;
+      type = ClusterManagementMode.Type.CLUSTER_FREEZE;
       if (!instancesFullyFrozen(enabledLiveInstances, liveInstanceMap, allInstanceMessages))
{
         status = ClusterManagementMode.Status.IN_PROGRESS;
       }
@@ -144,9 +142,9 @@ public class ManagementModeStage extends AbstractBaseStage {
 
     // If there is any pending message sent by users, status could be computed as in progress.
     // Skip recording status change to avoid confusion after cluster is already fully frozen.
-    if (ClusterManagementMode.Type.CLUSTER_PAUSE.equals(recordedType)
+    if (ClusterManagementMode.Type.CLUSTER_FREEZE.equals(recordedType)
         && ClusterManagementMode.Status.COMPLETED.equals(recordedStatus)
-        && ClusterManagementMode.Type.CLUSTER_PAUSE.equals(mode.getMode())
+        && ClusterManagementMode.Type.CLUSTER_FREEZE.equals(mode.getMode())
         && ClusterManagementMode.Status.IN_PROGRESS.equals(mode.getStatus())) {
       LOG.info("Skip recording status mode={}, status={}, because cluster is fully frozen",
           mode.getMode(), mode.getStatus());
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
index 73c699e..05bef08 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
@@ -509,7 +509,7 @@ public class ZKHelixAdmin implements HelixAdmin {
 
     // TODO: support other modes
     switch (mode) {
-      case CLUSTER_PAUSE:
+      case CLUSTER_FREEZE:
         enableClusterPauseMode(clusterName, request.isCancelPendingST(), reason);
         break;
       case NORMAL:
diff --git a/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java
b/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java
index ff970c2..11badac 100644
--- a/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java
+++ b/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java
@@ -187,6 +187,7 @@ public class HelixTaskExecutor implements MessageListener, TaskExecutor
{
     _timer = new Timer("HelixTaskExecutor_Timer", true);
 
     _isShuttingDown = false;
+    _liveInstanceStatus = LiveInstanceStatus.NORMAL;
 
     startMonitorThread();
   }
@@ -1370,7 +1371,7 @@ public class HelixTaskExecutor implements MessageListener, TaskExecutor
{
               manager.getStateMachineEngine(), false);
         }
         _freezeSessionId = null;
-        _liveInstanceStatus = null;
+        _liveInstanceStatus = toStatus;
         success = accessor.getBaseDataAccessor().update(path, record -> {
           // Remove the status field for backwards compatibility
           record.getSimpleFields().remove(LiveInstance.LiveInstanceProperty.STATUS.name());
diff --git a/helix-core/src/main/java/org/apache/helix/model/LiveInstance.java b/helix-core/src/main/java/org/apache/helix/model/LiveInstance.java
index fed2940..e711fea 100644
--- a/helix-core/src/main/java/org/apache/helix/model/LiveInstance.java
+++ b/helix-core/src/main/java/org/apache/helix/model/LiveInstance.java
@@ -142,10 +142,12 @@ public class LiveInstance extends HelixProperty {
   }
 
   /**
-   * Gets the live instance's status. Returns null if the status field is not set.
+   * Gets the live instance's status. Returns {@link LiveInstanceStatus#NORMAL} if the status
+   * field is not set.
    */
   public LiveInstanceStatus getStatus() {
-    return _record.getEnumField(LiveInstanceProperty.STATUS.name(), LiveInstanceStatus.class,
null);
+    return _record.getEnumField(LiveInstanceProperty.STATUS.name(), LiveInstanceStatus.class,
+        LiveInstanceStatus.NORMAL);
   }
 
   /**
diff --git a/helix-core/src/test/java/org/apache/helix/controller/stages/TestManagementMessageGeneration.java
b/helix-core/src/test/java/org/apache/helix/controller/stages/TestManagementMessageGeneration.java
index c16b503..7c20b02 100644
--- a/helix-core/src/test/java/org/apache/helix/controller/stages/TestManagementMessageGeneration.java
+++ b/helix-core/src/test/java/org/apache/helix/controller/stages/TestManagementMessageGeneration.java
@@ -128,7 +128,7 @@ public class TestManagementMessageGeneration extends ManagementMessageGeneration
         RebalanceUtil.buildBestPossibleState(resourceMap.keySet(), currentStateOutput);
 
     // Process the event
-    ClusterManagementMode mode = new ClusterManagementMode(ClusterManagementMode.Type.CLUSTER_PAUSE,
+    ClusterManagementMode mode = new ClusterManagementMode(ClusterManagementMode.Type.CLUSTER_FREEZE,
         ClusterManagementMode.Status.IN_PROGRESS);
     event.addAttribute(AttributeName.BEST_POSSIBLE_STATE.name(), bestPossibleStateOutput);
     event.addAttribute(AttributeName.CLUSTER_STATUS.name(), mode);
diff --git a/helix-core/src/test/java/org/apache/helix/controller/stages/TestManagementModeStage.java
b/helix-core/src/test/java/org/apache/helix/controller/stages/TestManagementModeStage.java
index 2737bf7..1be5c6b 100644
--- a/helix-core/src/test/java/org/apache/helix/controller/stages/TestManagementModeStage.java
+++ b/helix-core/src/test/java/org/apache/helix/controller/stages/TestManagementModeStage.java
@@ -76,7 +76,7 @@ public class TestManagementModeStage extends ZkTestBase {
     // Freeze cluster
     ClusterManagementModeRequest request = ClusterManagementModeRequest.newBuilder()
         .withClusterName(_clusterName)
-        .withMode(ClusterManagementMode.Type.CLUSTER_PAUSE)
+        .withMode(ClusterManagementMode.Type.CLUSTER_FREEZE)
         .withReason("test")
         .build();
     _gSetupTool.getClusterManagementTool().setClusterManagementMode(request);
@@ -91,7 +91,7 @@ public class TestManagementModeStage extends ZkTestBase {
 
     // In frozen mode
     ClusterStatus clusterStatus = _accessor.getProperty(_accessor.keyBuilder().clusterStatus());
-    Assert.assertEquals(clusterStatus.getManagementMode(), ClusterManagementMode.Type.CLUSTER_PAUSE);
+    Assert.assertEquals(clusterStatus.getManagementMode(), ClusterManagementMode.Type.CLUSTER_FREEZE);
 
 
     // Mark a live instance to be pause state
diff --git a/helix-core/src/test/java/org/apache/helix/integration/controller/TestClusterFreezeMode.java
b/helix-core/src/test/java/org/apache/helix/integration/controller/TestClusterFreezeMode.java
index cbc8535..afaea91 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/controller/TestClusterFreezeMode.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/controller/TestClusterFreezeMode.java
@@ -153,7 +153,7 @@ public class TestClusterFreezeMode extends ZkTestBase {
     // Freeze cluster
     ClusterManagementModeRequest request = ClusterManagementModeRequest.newBuilder()
         .withClusterName(_clusterName)
-        .withMode(ClusterManagementMode.Type.CLUSTER_PAUSE)
+        .withMode(ClusterManagementMode.Type.CLUSTER_FREEZE)
         .withReason(methodName)
         .build();
     _gSetupTool.getClusterManagementTool().setClusterManagementMode(request);
@@ -164,7 +164,7 @@ public class TestClusterFreezeMode extends ZkTestBase {
 
     // Cluster is in progress to cluster pause because there is a pending state transition
message
     ClusterStatus expectedClusterStatus = new ClusterStatus();
-    expectedClusterStatus.setManagementMode(ClusterManagementMode.Type.CLUSTER_PAUSE);
+    expectedClusterStatus.setManagementMode(ClusterManagementMode.Type.CLUSTER_FREEZE);
     expectedClusterStatus.setManagementModeStatus(ClusterManagementMode.Status.IN_PROGRESS);
     verifyClusterStatus(expectedClusterStatus);
 
@@ -175,7 +175,7 @@ public class TestClusterFreezeMode extends ZkTestBase {
     verifyLiveInstanceStatus(_participants, LiveInstance.LiveInstanceStatus.PAUSED);
 
     expectedClusterStatus = new ClusterStatus();
-    expectedClusterStatus.setManagementMode(ClusterManagementMode.Type.CLUSTER_PAUSE);
+    expectedClusterStatus.setManagementMode(ClusterManagementMode.Type.CLUSTER_FREEZE);
     expectedClusterStatus.setManagementModeStatus(ClusterManagementMode.Status.COMPLETED);
     verifyClusterStatus(expectedClusterStatus);
 
@@ -187,7 +187,7 @@ public class TestClusterFreezeMode extends ZkTestBase {
         return false;
       }
       String lastHistory = managementHistory.get(managementHistory.size() - 1);
-      return lastHistory.contains("MODE=" + ClusterManagementMode.Type.CLUSTER_PAUSE)
+      return lastHistory.contains("MODE=" + ClusterManagementMode.Type.CLUSTER_FREEZE)
           && lastHistory.contains("STATUS=" + ClusterManagementMode.Status.COMPLETED)
           && lastHistory.contains("REASON=" + methodName);
     }, TestHelper.WAIT_DURATION));
@@ -303,7 +303,7 @@ public class TestClusterFreezeMode extends ZkTestBase {
         .build();
     _gSetupTool.getClusterManagementTool().setClusterManagementMode(request);
 
-    verifyLiveInstanceStatus(_participants, null);
+    verifyLiveInstanceStatus(_participants, LiveInstance.LiveInstanceStatus.NORMAL);
 
     ClusterStatus expectedClusterStatus = new ClusterStatus();
     expectedClusterStatus.setManagementMode(ClusterManagementMode.Type.NORMAL);
diff --git a/helix-core/src/test/java/org/apache/helix/integration/paticipant/TestParticipantFreeze.java
b/helix-core/src/test/java/org/apache/helix/integration/paticipant/TestParticipantFreeze.java
index fedee37..1eb760e 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/paticipant/TestParticipantFreeze.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/paticipant/TestParticipantFreeze.java
@@ -117,7 +117,9 @@ public class TestParticipantFreeze extends ZkTestBase {
   @Test
   public void testNormalLiveInstanceStatus() {
     LiveInstance liveInstance = _accessor.getProperty(_keyBuilder.liveInstance(_instanceName));
-    Assert.assertNull(liveInstance.getStatus());
+    Assert.assertEquals(liveInstance.getStatus(), LiveInstance.LiveInstanceStatus.NORMAL);
+    Assert.assertNull(
+        liveInstance.getRecord().getSimpleField(LiveInstance.LiveInstanceProperty.STATUS.name()));
   }
 
   @Test(dependsOnMethods = "testNormalLiveInstanceStatus")
@@ -151,7 +153,7 @@ public class TestParticipantFreeze extends ZkTestBase {
     // New live instance ephemeral node
     Assert.assertEquals(liveInstance.getEphemeralOwner(), _participants[1].getSessionId());
     // Status is not frozen because controller is not running, no freeze message sent.
-    verifyLiveInstanceStatus(_participants[1], null);
+    verifyLiveInstanceStatus(_participants[1], LiveInstance.LiveInstanceStatus.NORMAL);
 
     // Old session current state is deleted because of current state carry-over
     Assert.assertTrue(TestHelper.verify(
@@ -221,7 +223,7 @@ public class TestParticipantFreeze extends ZkTestBase {
 
     // Live instance status is NORMAL, but set to null value in both memory and zk.
     // After live instance status is updated, the process is completed.
-    verifyLiveInstanceStatus(_participants[0], null);
+    verifyLiveInstanceStatus(_participants[0], LiveInstance.LiveInstanceStatus.NORMAL);
     // Unfreeze message is correctly deleted
     Assert.assertNull(
         _accessor.getProperty(_keyBuilder.message(_instanceName, unfreezeMessage.getId())));
@@ -242,7 +244,7 @@ public class TestParticipantFreeze extends ZkTestBase {
 
   private void verifyLiveInstanceStatus(MockParticipantManager participant,
       LiveInstance.LiveInstanceStatus status) throws Exception {
-    // Live instance status is frozen in both memory and zk
+    // Verify live instance status in both memory and zk
     Assert.assertTrue(TestHelper.verify(() -> {
       LiveInstance.LiveInstanceStatus inMemoryLiveInstanceStatus =
           ((DefaultMessagingService) participant.getMessagingService()).getExecutor()
@@ -285,7 +287,8 @@ public class TestParticipantFreeze extends ZkTestBase {
     // Live instance status is frozen in both memory and zk
     verifyLiveInstanceStatus(participant, LiveInstance.LiveInstanceStatus.PAUSED);
     // Freeze message is correctly deleted
-    Assert.assertNull(_accessor
-        .getProperty(_keyBuilder.message(participant.getInstanceName(), freezeMessage.getId())));
+    Assert.assertTrue(TestHelper.verify(() -> !_gZkClient.exists(
+        _keyBuilder.message(participant.getInstanceName(), freezeMessage.getId()).getPath()),
+        TestHelper.WAIT_DURATION));
   }
 }
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java
index 7ddf677..968a5d4 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkHelixAdmin.java
@@ -1087,7 +1087,7 @@ public class TestZkHelixAdmin extends ZkUnitTestBase {
       try {
         ClusterManagementModeRequest request = ClusterManagementModeRequest.newBuilder()
             .withClusterName(clusterName)
-            .withMode(ClusterManagementMode.Type.CLUSTER_PAUSE)
+            .withMode(ClusterManagementMode.Type.CLUSTER_FREEZE)
             .withCancelPendingST(true)
             .withReason(methodName)
             .build();
@@ -1100,7 +1100,7 @@ public class TestZkHelixAdmin extends ZkUnitTestBase {
 
       ClusterManagementModeRequest request = ClusterManagementModeRequest.newBuilder()
           .withClusterName(clusterName)
-          .withMode(ClusterManagementMode.Type.CLUSTER_PAUSE)
+          .withMode(ClusterManagementMode.Type.CLUSTER_FREEZE)
           .withReason(methodName)
           .build();
       _gSetupTool.getClusterManagementTool().setClusterManagementMode(request);
diff --git a/helix-core/src/test/java/org/apache/helix/model/TestControllerHistoryModel.java
b/helix-core/src/test/java/org/apache/helix/model/TestControllerHistoryModel.java
index 2e0bab3..d77287a 100644
--- a/helix-core/src/test/java/org/apache/helix/model/TestControllerHistoryModel.java
+++ b/helix-core/src/test/java/org/apache/helix/model/TestControllerHistoryModel.java
@@ -37,7 +37,7 @@ public class TestControllerHistoryModel {
   public void testManagementModeHistory() {
     ControllerHistory controllerHistory = new ControllerHistory("HISTORY");
     String controller = "controller-0";
-    ClusterManagementMode mode = new ClusterManagementMode(ClusterManagementMode.Type.CLUSTER_PAUSE,
+    ClusterManagementMode mode = new ClusterManagementMode(ClusterManagementMode.Type.CLUSTER_FREEZE,
         ClusterManagementMode.Status.COMPLETED);
     long time = System.currentTimeMillis();
     String fromHost = NetworkUtil.getLocalhostName();
diff --git a/helix-core/src/test/java/org/apache/helix/model/TestLiveInstance.java b/helix-core/src/test/java/org/apache/helix/model/TestLiveInstance.java
index 18285f5..b8024bb 100644
--- a/helix-core/src/test/java/org/apache/helix/model/TestLiveInstance.java
+++ b/helix-core/src/test/java/org/apache/helix/model/TestLiveInstance.java
@@ -150,7 +150,9 @@ public class TestLiveInstance extends ZkUnitTestBase {
   @Test
   public void testLiveInstanceStatus() {
     LiveInstance testLiveInstance = new LiveInstance("testLiveInstanceStatus");
-    Assert.assertNull(testLiveInstance.getStatus());
+    Assert.assertNull(testLiveInstance.getRecord()
+        .getSimpleField(LiveInstance.LiveInstanceProperty.STATUS.name()));
+    Assert.assertEquals(testLiveInstance.getStatus(), LiveInstance.LiveInstanceStatus.NORMAL);
     testLiveInstance.setStatus(LiveInstance.LiveInstanceStatus.PAUSED);
     Assert.assertEquals(testLiveInstance.getStatus(), LiveInstance.LiveInstanceStatus.PAUSED);
   }
diff --git a/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
b/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
index 9efcdc7..552a530 100644
--- a/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
+++ b/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
@@ -344,7 +344,7 @@ public class ClusterAccessor extends AbstractHelixResource {
       List<LiveInstance> liveInstances = accessor.getChildValues(keyBuilder.liveInstances());
       BaseDataAccessor<ZNRecord> baseAccessor = accessor.getBaseDataAccessor();
 
-      if (ClusterManagementMode.Type.CLUSTER_PAUSE.equals(mode.getMode())) {
+      if (ClusterManagementMode.Type.CLUSTER_FREEZE.equals(mode.getMode())) {
         // Entering cluster freeze mode, check live instance freeze status and pending ST
         for (LiveInstance liveInstance : liveInstances) {
           String instanceName = liveInstance.getInstanceName();
@@ -370,7 +370,7 @@ public class ClusterAccessor extends AbstractHelixResource {
 
     participantDetails.put("status", status.name());
     participantDetails.put("liveInstancesInProgress", liveInstancesInProgress);
-    if (ClusterManagementMode.Type.CLUSTER_PAUSE.equals(mode.getMode())) {
+    if (ClusterManagementMode.Type.CLUSTER_FREEZE.equals(mode.getMode())) {
       // Add pending ST result for cluster freeze mode
       participantDetails.put("hasPendingStateTransition", hasPendingST);
     }
diff --git a/helix-rest/src/test/java/org/apache/helix/rest/server/TestClusterAccessor.java
b/helix-rest/src/test/java/org/apache/helix/rest/server/TestClusterAccessor.java
index 8d2de70..8b8f38a 100644
--- a/helix-rest/src/test/java/org/apache/helix/rest/server/TestClusterAccessor.java
+++ b/helix-rest/src/test/java/org/apache/helix/rest/server/TestClusterAccessor.java
@@ -1302,7 +1302,7 @@ public class TestClusterAccessor extends AbstractTestClass {
 
     // Set cluster pause mode
     ClusterManagementModeRequest request = ClusterManagementModeRequest.newBuilder()
-        .withMode(ClusterManagementMode.Type.CLUSTER_PAUSE)
+        .withMode(ClusterManagementMode.Type.CLUSTER_FREEZE)
         .withClusterName(cluster)
         .build();
     String payload = OBJECT_MAPPER.writeValueAsString(request);
@@ -1321,22 +1321,23 @@ public class TestClusterAccessor extends AbstractTestClass {
 
     // Verify get cluster status
     String body = get(endpoint, null, Response.Status.OK.getStatusCode(), true);
-    ClusterManagementMode mode =
-        OBJECT_MAPPER.readerFor(ClusterManagementMode.class).readValue(body);
-    Assert.assertEquals(mode.getMode(), ClusterManagementMode.Type.CLUSTER_PAUSE);
+    Map<String, Object> responseMap = OBJECT_MAPPER.readerFor(Map.class).readValue(body);
+    Assert.assertEquals(responseMap.get("mode"), ClusterManagementMode.Type.CLUSTER_FREEZE.name());
     // Depending on timing, it could IN_PROGRESS or COMPLETED.
     // It's just to verify the rest response format is correct
-    Assert.assertTrue(ClusterManagementMode.Status.IN_PROGRESS.equals(mode.getStatus())
-        || ClusterManagementMode.Status.COMPLETED.equals(mode.getStatus()));
+    String status = (String) responseMap.get("status");
+    Assert.assertTrue(ClusterManagementMode.Status.IN_PROGRESS.name().equals(status)
+        || ClusterManagementMode.Status.COMPLETED.name().equals(status));
 
     body = get(endpoint, ImmutableMap.of("showDetails", "true"), Response.Status.OK.getStatusCode(),
         true);
-    Map<String, Object> responseMap = OBJECT_MAPPER.readerFor(Map.class).readValue(body);
+    responseMap = OBJECT_MAPPER.readerFor(Map.class).readValue(body);
     Map<String, Object> detailsMap = (Map<String, Object>) responseMap.get("details");
+    status = (String) responseMap.get("status");
 
     Assert.assertEquals(responseMap.get("cluster"), cluster);
-    Assert.assertEquals(responseMap.get("mode"), mode.getMode().name());
-    Assert.assertEquals(responseMap.get("status"), mode.getStatus().name());
+    Assert.assertEquals(responseMap.get("mode"), ClusterManagementMode.Type.CLUSTER_FREEZE.name());
+    Assert.assertEquals(responseMap.get("status"), status);
     Assert.assertTrue(responseMap.containsKey("details"));
     Assert.assertTrue(detailsMap.containsKey("cluster"));
     Assert.assertTrue(detailsMap.containsKey("liveInstances"));

Mime
View raw message