xyuanlu commented on code in PR #2149:
URL: https://github.com/apache/helix/pull/2149#discussion_r900530420
##########
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()
+ .equals(InstanceConstants.InstanceDisabledType.CLOUD_EVENT.name());
}
/**
- * check if instance is disabled by cloud event.
- * @param clusterName
- * @param instanceName
- * @param dataAccessor
- * @return return true only when instance is Helix disabled and has the
cloud event info in
- * clusterConfig ZNode.
+ * Update map field disabledInstancesWithInfo in clusterConfig with
cloudEvent instance info
*/
- static boolean IsInstanceDisabledForCloudEvent(String clusterName, String
instanceName,
- BaseDataAccessor dataAccessor) {
- // TODO add impl here
- return true;
+ static void updateCloudEventOperationInClusterConfig(String clusterName,
String instanceName,
Review Comment:
Although this method is only used for DefaultCloudEventCallbackImpl for now,
I feel that we should keep the util function signature to be more generic.
--
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]