Rename property CLUSTER_PAUSE to CLUSTER_FREEZE in PauseSignal (#1820)
Rename property CLUSTER_PAUSE to CLUSTER_FREEZE in PauseSignal.
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.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 @@
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 @@
// 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 enum PauseSignalProperty {
REASON,
- CLUSTER_PAUSE,
+ CLUSTER_FREEZE,
FROM_HOST,
CANCEL_PENDING_ST,
TRIGGER_TIME
@@ -76,11 +76,11 @@
}
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 @@
.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);