You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2021/05/17 18:41:16 UTC
[GitHub] [helix] jiajunwang commented on a change in pull request #1740: Add java api for enable/disable cluster pause mode
jiajunwang commented on a change in pull request #1740:
URL: https://github.com/apache/helix/pull/1740#discussion_r633763117
##########
File path: helix-core/src/main/java/org/apache/helix/HelixAdmin.java
##########
@@ -367,6 +368,41 @@ void manuallyEnableMaintenanceMode(String clusterName, boolean enabled, String r
*/
boolean isInMaintenanceMode(String clusterName);
+ /**
+ * Puts a cluster into pause mode, which will pause controller and participants.
+ * This can be used to retain the cluster state. When this method returns, it means
+ * the pause signal has been successfully sent, but it does not mean the cluster has
+ * fully entered pause mode. Because the cluster can take some time to finish the pause and
+ * process possible pending state transitions if necessary.
+ * <p>
+ * To check the cluster pause status, call {@link #getClusterPauseStatus(String)}.
+ *
+ * @param clusterName Participant cluster name.
+ * @param cancelPendingST whether or not cancel the pending state transitions for participants.
+ * @param reason The reason to put the cluster into pause mode.
+ */
+ void enableClusterPauseMode(String clusterName, boolean cancelPendingST, String reason);
+
+ /**
+ * Gets cluster pause status {@link ClusterPauseStatus}.
+ *
+ * @param clusterName cluster name.
+ * @return {@link ClusterPauseStatus}
+ */
+ ClusterPauseStatus getClusterPauseStatus(String clusterName);
Review comment:
I suggest to make some meaningful refactoring instead of introducing more patches.
1. ClusterPauseStatus -> ClusterManagementStatus {NORMAL, CONTROLLER_PAUSED, CLUSTER_PAUSING, CLUSTER_PAUSED, CLUSTER_UNPAUSING, CONTROLLER_MAINTENANCE}
2. No more enable or disable, just call it set status.
3. Deprecate all the other existing method to pause or maintain the cluster.
##########
File path: helix-core/src/main/java/org/apache/helix/api/exceptions/HelixPauseExitsException.java
##########
@@ -0,0 +1,28 @@
+package org.apache.helix.api.exceptions;
+
+/*
+ * 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.
+ */
+
+import org.apache.helix.HelixException;
+
+public class HelixPauseExitsException extends HelixException {
+ public HelixPauseExitsException(String message) {
Review comment:
Question, why we need an additional exception type here? Could you please share more thoughts?
##########
File path: helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
##########
@@ -497,6 +499,67 @@ public boolean isInMaintenanceMode(String clusterName) {
.exists(keyBuilder.maintenance().getPath(), AccessOption.PERSISTENT);
}
+ @Override
+ public void enableClusterPauseMode(String clusterName, boolean cancelPendingST, String reason) {
+ logger.info("Enable cluster pause mode for cluster: {}. Cancel pending ST: {}. Reason: {}.",
+ clusterName, cancelPendingST, reason);
+
+ PauseSignal pauseSignal = new PauseSignal("pause");
+ pauseSignal.setPauseCluster(Boolean.toString(true));
+ pauseSignal.setCancelPendingST(cancelPendingST);
+ pauseSignal.setFromHost(NetworkUtil.getLocalhostName());
+ pauseSignal.setTriggerTime(Instant.now().toString());
+ if (reason != null && !reason.isEmpty()) {
+ pauseSignal.setReason(reason);
+ }
+
+ BaseDataAccessor<ZNRecord> baseDataAccessor = new ZkBaseDataAccessor<>(_zkClient);
+ HelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName, baseDataAccessor);
+
+ if (baseDataAccessor.exists(accessor.keyBuilder().pause().getPath(), AccessOption.PERSISTENT)) {
+ throw new HelixPauseExitsException(clusterName + " pause signal already exits");
Review comment:
1. The description does not necessarily match the Exception class name. Do you mean "exits" or "exists"?
2. If pause mode has existed, shall we consider the operation is done? But I agree that we should not just return nothing, since it might be paused due to a different reason.
This makes me think about whether or not we shall enter pause mode if the cluster is in controller pause or maintenance mode. My preference is don't mix things up. Reject the call under any confusing situations. So you have to check for the other signals here.
##########
File path: zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/NetworkUtil.java
##########
@@ -120,7 +120,7 @@ public static String getLocalhostName() {
try {
return InetAddress.getLocalHost().getHostName();
} catch (final UnknownHostException e) {
- throw new RuntimeException("unable to retrieve localhost name");
+ return "UNKNOWN";
Review comment:
Why? If you return "UNKNOWN" when getLocalhostName() gets an error, the application will continue executing and cause bigger trouble.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org