xyuanlu commented on code in PR #2149:
URL: https://github.com/apache/helix/pull/2149#discussion_r900529931
##########
helix-core/src/main/java/org/apache/helix/cloud/event/helix/HelixEventHandlingUtil.java:
##########
@@ -19,40 +19,103 @@
* under the License.
*/
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.helix.AccessOption;
import org.apache.helix.BaseDataAccessor;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixException;
+import org.apache.helix.PropertyPathBuilder;
+import org.apache.helix.constants.InstanceConstants;
+import org.apache.helix.manager.zk.ZKHelixAdmin;
+import org.apache.helix.model.ClusterConfig;
+import org.apache.helix.model.InstanceConfig;
+import org.apache.helix.util.ConfigStringUtil;
+import org.apache.helix.util.InstanceValidationUtil;
+import org.apache.helix.zookeeper.datamodel.ZNRecord;
+import org.apache.helix.zookeeper.zkclient.DataUpdater;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
- class HelixEventHandlingUtil {
+class HelixEventHandlingUtil {
+ private static Logger LOG =
LoggerFactory.getLogger(HelixEventHandlingUtil.class);
/**
- * Enable or disable an instance for cloud event.
- * It will enable/disable Helix for that instance. Also add the instance
cloud event info to
- * clusterConfig Znode when enable.
- * @param clusterName
+ * check if instance is disabled by cloud event.
* @param instanceName
- * @param message
- * @param isEnable
* @param dataAccessor
- * @return return failure when either enable/disable failed or update
cluster ZNode failed.
+ * @return return true only when instance is Helix disabled and the disabled
reason in
+ * instanceConfig is cloudEvent
*/
- static boolean enableInstanceForCloudEvent(String clusterName, String
instanceName, String message,
- boolean isEnable, BaseDataAccessor dataAccessor) {
- // TODO add impl here
- return true;
+ static boolean isInstanceDisabledForCloudEvent(String instanceName,
+ HelixDataAccessor dataAccessor) {
+ InstanceConfig instanceConfig =
+
dataAccessor.getProperty(dataAccessor.keyBuilder().instanceConfig(instanceName));
+ return !InstanceValidationUtil.isEnabled(dataAccessor, instanceName) &&
instanceConfig
+ .getInstanceDisabledType()
Review Comment:
I don't feel like we need to...If we do not check, it will throw a run time
exception. If we check we will also throw a runtime exception (Same as how
ZkHelixAdmin do). But I added anyway..
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]