junkaixue commented on code in PR #2106:
URL: https://github.com/apache/helix/pull/2106#discussion_r877498947
##########
helix-core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java:
##########
@@ -241,13 +244,87 @@ private void refreshClusterConfig(final HelixDataAccessor
accessor,
if
(_propertyDataChangedMap.get(HelixConstants.ChangeType.CLUSTER_CONFIG).getAndSet(false))
{
_clusterConfig =
accessor.getProperty(accessor.keyBuilder().clusterConfig());
refreshedType.add(HelixConstants.ChangeType.CLUSTER_CONFIG);
+ // TODO: This is a temp function to clean up incompatible batched
disabled instances format.
+ // Remove in later version.
+ if (checkBatchedDisabledInstanceFormat(_clusterConfig) &&
updateBatchDisableFormat(
+ accessor)) {
+ // read from zkz one more time
+ LogUtil.logInfo(logger, getClusterEventId(), String
+ .format("Clean ClusterConfig change for cluster %s, pipeline %s",
_clusterName,
+ getPipelineName()));
+ _clusterConfig =
accessor.getProperty(accessor.keyBuilder().clusterConfig());
+ }
refreshAbnormalStateResolverMap(_clusterConfig);
} else {
- LogUtil.logInfo(logger, getClusterEventId(), String.format(
- "No ClusterConfig change for cluster %s, pipeline %s", _clusterName,
getPipelineName()));
+ LogUtil.logInfo(logger, getClusterEventId(), String
+ .format("No ClusterConfig change for cluster %s, pipeline %s",
_clusterName,
+ getPipelineName()));
}
}
+ // TODO: This function is used to clean up incompatible batched disabled
instances format for
+ // "DISABLED_INSTANCES" introduced in 1.0.3.0. This temp change shoul dbe
reverted after 1.0.5.0 \
+ // or later version.
+ private boolean updateBatchDisableFormat(final HelixDataAccessor accessor) {
+ return accessor
+ .updateProperty(accessor.keyBuilder().clusterConfig(), new
DataUpdater<ZNRecord>() {
+ @Override
+ public ZNRecord update(ZNRecord currentData) {
+ if (currentData == null) {
+ throw new HelixException(
+ "Cluster: " + _clusterConfig.getClusterName() + ": cluster
config is null");
+ }
+
+ ClusterConfig clusterConfig = new ClusterConfig(currentData);
+ Map<String, String> disabledInstances =
clusterConfig.getDisabledInstances();
+ Map<String, String> DisabledInstancesWithInfo =
+ clusterConfig.getDisabledInstancesWithInfo();
+
+ ClusterConfig newClusterConfig = new ClusterConfig(currentData);
+ Map<String, String> newDisabledInstances =
+ new TreeMap<>(newClusterConfig.getDisabledInstances());
+ Map<String, String> newDisabledInstancesWithInfo =
+ new TreeMap<>(newClusterConfig.getDisabledInstancesWithInfo());
+
+ // iterate through all k,v pairs and check for string format.
+ for (Map.Entry<String, String> instanceInfo :
disabledInstances.entrySet()) {
+ String instanceName = instanceInfo.getKey();
+ if (!StringUtils.isNumeric(instanceInfo.getValue())) {
+ newDisabledInstances.put(instanceName,
+
ConfigStringUtil.parseConcatenatedConfig(instanceInfo.getValue()).get(
+
ClusterConfig.ClusterConfigProperty.HELIX_ENABLED_DISABLE_TIMESTAMP
+ .toString()));
+ newDisabledInstancesWithInfo.put(instanceName,
instanceInfo.getValue());
+ } else {
+ if (!DisabledInstancesWithInfo.containsKey(instanceName)) {
+ newDisabledInstancesWithInfo.put(instanceName,
ConfigStringUtil
+ .concatenateMapping(Collections.singletonMap(
+
ClusterConfig.ClusterConfigProperty.HELIX_ENABLED_DISABLE_TIMESTAMP
+ .toString(), instanceInfo.getValue())));
Review Comment:
NIT: Usually we use .name()
##########
helix-core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java:
##########
@@ -241,13 +244,87 @@ private void refreshClusterConfig(final HelixDataAccessor
accessor,
if
(_propertyDataChangedMap.get(HelixConstants.ChangeType.CLUSTER_CONFIG).getAndSet(false))
{
_clusterConfig =
accessor.getProperty(accessor.keyBuilder().clusterConfig());
refreshedType.add(HelixConstants.ChangeType.CLUSTER_CONFIG);
+ // TODO: This is a temp function to clean up incompatible batched
disabled instances format.
+ // Remove in later version.
+ if (checkBatchedDisabledInstanceFormat(_clusterConfig) &&
updateBatchDisableFormat(
+ accessor)) {
+ // read from zkz one more time
+ LogUtil.logInfo(logger, getClusterEventId(), String
+ .format("Clean ClusterConfig change for cluster %s, pipeline %s",
_clusterName,
+ getPipelineName()));
+ _clusterConfig =
accessor.getProperty(accessor.keyBuilder().clusterConfig());
+ }
refreshAbnormalStateResolverMap(_clusterConfig);
} else {
- LogUtil.logInfo(logger, getClusterEventId(), String.format(
- "No ClusterConfig change for cluster %s, pipeline %s", _clusterName,
getPipelineName()));
+ LogUtil.logInfo(logger, getClusterEventId(), String
Review Comment:
Let's put it to debug level?
##########
helix-core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java:
##########
@@ -241,13 +244,87 @@ private void refreshClusterConfig(final HelixDataAccessor
accessor,
if
(_propertyDataChangedMap.get(HelixConstants.ChangeType.CLUSTER_CONFIG).getAndSet(false))
{
_clusterConfig =
accessor.getProperty(accessor.keyBuilder().clusterConfig());
refreshedType.add(HelixConstants.ChangeType.CLUSTER_CONFIG);
+ // TODO: This is a temp function to clean up incompatible batched
disabled instances format.
+ // Remove in later version.
+ if (checkBatchedDisabledInstanceFormat(_clusterConfig) &&
updateBatchDisableFormat(
+ accessor)) {
+ // read from zkz one more time
+ LogUtil.logInfo(logger, getClusterEventId(), String
+ .format("Clean ClusterConfig change for cluster %s, pipeline %s",
_clusterName,
+ getPipelineName()));
+ _clusterConfig =
accessor.getProperty(accessor.keyBuilder().clusterConfig());
Review Comment:
Let's not read this again. Helix computation is based on a snapshot of all
data for ZK clusters. If you read cluster config in the middle of the pipeline,
then cluster config is a newer version of snapshot instead of original one.
My suggestion is just reformat whatever we need to update in memory. But do
not read cluster config back. Let next round pipe line refresh to refresh
cluster config since there should be such type of config change notification.
--
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]