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 ac877c5c631c12ad570969e897528824625a0461 Author: Huizhi Lu <[email protected]> AuthorDate: Thu Jul 15 20:26:11 2021 -0700 Rename property CLUSTER_PAUSE to CLUSTER_FREEZE in PauseSignal (#1820) Rename property CLUSTER_PAUSE to CLUSTER_FREEZE in PauseSignal. --- .../helix/controller/stages/ManagementModeStage.java | 16 +++++++++++----- .../main/java/org/apache/helix/model/PauseSignal.java | 6 +++--- .../integration/controller/TestClusterFreezeMode.java | 6 +++++- 3 files changed, 19 insertions(+), 9 deletions(-) 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 a281e08..3329d8c 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 @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.Map; import java.util.Set; +import com.google.common.collect.ImmutableSet; import org.apache.helix.AccessOption; import org.apache.helix.HelixDataAccessor; import org.apache.helix.HelixManager; @@ -53,11 +54,17 @@ import org.slf4j.LoggerFactory; public class ManagementModeStage extends AbstractBaseStage { private static final Logger LOG = LoggerFactory.getLogger(ManagementModeStage.class); + // Check message types to determine instance is in progress to be frozen + private static final Set<String> PENDING_MESSAGE_TYPES = ImmutableSet.of( + MessageType.PARTICIPANT_STATUS_CHANGE.name(), + MessageType.STATE_TRANSITION.name(), + MessageType.STATE_TRANSITION_CANCELLATION.name() + ); + @Override public void process(ClusterEvent event) throws Exception { // TODO: implement the stage _eventId = event.getEventId(); - String clusterName = event.getClusterName(); HelixManager manager = event.getAttribute(AttributeName.helixmanager.name()); if (manager == null) { throw new StageException("HelixManager attribute value is null"); @@ -120,13 +127,12 @@ public class ManagementModeStage extends AbstractBaseStage { // 2. No pending participant status change message. return enabledLiveInstances.stream().noneMatch( instance -> !LiveInstanceStatus.FROZEN.equals(liveInstanceMap.get(instance).getStatus()) - || hasPendingMessage(allInstanceMessages.get(instance), - MessageType.PARTICIPANT_STATUS_CHANGE)); + || hasPendingMessage(allInstanceMessages.get(instance))); } - private boolean hasPendingMessage(Collection<Message> messages, MessageType type) { + private boolean hasPendingMessage(Collection<Message> messages) { return messages != null && messages.stream() - .anyMatch(message -> type.name().equals(message.getMsgType())); + .anyMatch(message -> PENDING_MESSAGE_TYPES.contains(message.getMsgType())); } private void recordClusterStatus(ClusterManagementMode mode, HelixDataAccessor accessor) { diff --git a/helix-core/src/main/java/org/apache/helix/model/PauseSignal.java b/helix-core/src/main/java/org/apache/helix/model/PauseSignal.java index bcfd17d..65674ad 100644 --- a/helix-core/src/main/java/org/apache/helix/model/PauseSignal.java +++ b/helix-core/src/main/java/org/apache/helix/model/PauseSignal.java @@ -32,7 +32,7 @@ public class PauseSignal extends HelixProperty { public enum PauseSignalProperty { REASON, - CLUSTER_PAUSE, + CLUSTER_FREEZE, FROM_HOST, CANCEL_PENDING_ST, TRIGGER_TIME @@ -76,11 +76,11 @@ public class PauseSignal extends HelixProperty { } public void setClusterPause(boolean pause) { - _record.setBooleanField(PauseSignalProperty.CLUSTER_PAUSE.name(), pause); + _record.setBooleanField(PauseSignalProperty.CLUSTER_FREEZE.name(), pause); } public boolean isClusterPause() { - return _record.getBooleanField(PauseSignalProperty.CLUSTER_PAUSE.name(), false); + return _record.getBooleanField(PauseSignalProperty.CLUSTER_FREEZE.name(), false); } public void setFromHost(String host) { 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 09de4dc..e068f38 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 @@ -158,11 +158,15 @@ public class TestClusterFreezeMode extends ZkTestBase { .build(); _gSetupTool.getClusterManagementTool().setClusterManagementMode(request); + // Wait for all live instances are marked as frozen + verifyLiveInstanceStatus(_participants, LiveInstance.LiveInstanceStatus.FROZEN); + // Pending ST message exists Assert.assertTrue( _gZkClient.exists(keyBuilder.message(message.getTgtName(), message.getMsgId()).getPath())); - // Cluster is in progress to cluster pause because there is a pending state transition message + // Even live instance status is marked as frozen, Cluster is in progress to cluster freeze + // because there is a pending state transition message ClusterStatus expectedClusterStatus = new ClusterStatus(); expectedClusterStatus.setManagementMode(ClusterManagementMode.Type.CLUSTER_FREEZE); expectedClusterStatus.setManagementModeStatus(ClusterManagementMode.Status.IN_PROGRESS);
