You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by hu...@apache.org on 2019/08/06 21:16:54 UTC
[helix] branch master updated: Read ClusterConfig from ZK
selectively
This is an automated email from the ASF dual-hosted git repository.
hulee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
The following commit(s) were added to refs/heads/master by this push:
new 095f6cf Read ClusterConfig from ZK selectively
095f6cf is described below
commit 095f6cf34307f78e530498880d82bd1294c25afb
Author: Hunter Lee <hu...@linkedin.com>
AuthorDate: Tue Aug 6 11:32:16 2019 -0700
Read ClusterConfig from ZK selectively
Previously, ClusterConfig would be read from ZK every pipeline run. This PR makes it a selective read and also add to the set of all changed types so that cluster change detector could more easily tell whether ClusterConfig changed without having to store two copies of ClusterConfig objects.
---
.../dataproviders/BaseControllerDataProvider.java | 13 ++++++++++++-
.../TestControllerDataProviderSelectiveUpdate.java | 13 ++++++-------
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/helix-core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java b/helix-core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java
index 5eb6077..dc0d507 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java
@@ -220,6 +220,17 @@ public class BaseControllerDataProvider implements ControlContextProvider {
_instanceMessagesCache = new InstanceMessagesCache(_clusterName);
}
+ private void refreshClusterConfig(final HelixDataAccessor accessor,
+ Set<HelixConstants.ChangeType> refreshedType) {
+ if (_propertyDataChangedMap.get(HelixConstants.ChangeType.CLUSTER_CONFIG).getAndSet(false)) {
+ _clusterConfig = accessor.getProperty(accessor.keyBuilder().clusterConfig());
+ refreshedType.add(HelixConstants.ChangeType.CLUSTER_CONFIG);
+ } else {
+ LogUtil.logInfo(logger, getClusterEventId(), String.format(
+ "No ClusterConfig change for cluster %s, pipeline %s", _clusterName, getPipelineName()));
+ }
+ }
+
private void refreshIdealState(final HelixDataAccessor accessor,
Set<HelixConstants.ChangeType> refreshedType) {
if (_propertyDataChangedMap.get(HelixConstants.ChangeType.IDEAL_STATE).getAndSet(false)) {
@@ -307,7 +318,7 @@ public class BaseControllerDataProvider implements ControlContextProvider {
Set<HelixConstants.ChangeType> refreshedTypes = new HashSet<>();
// Refresh raw data
- _clusterConfig = accessor.getProperty(accessor.keyBuilder().clusterConfig());
+ refreshClusterConfig(accessor, refreshedTypes);
refreshIdealState(accessor, refreshedTypes);
refreshLiveInstances(accessor, refreshedTypes);
refreshInstanceConfigs(accessor, refreshedTypes);
diff --git a/helix-core/src/test/java/org/apache/helix/integration/controller/TestControllerDataProviderSelectiveUpdate.java b/helix-core/src/test/java/org/apache/helix/integration/controller/TestControllerDataProviderSelectiveUpdate.java
index 57e0d6e..a34c064 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/controller/TestControllerDataProviderSelectiveUpdate.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/controller/TestControllerDataProviderSelectiveUpdate.java
@@ -59,8 +59,7 @@ public class TestControllerDataProviderSelectiveUpdate extends ZkStandAloneCMTes
Assert.assertEquals(accessor.getReadCount(PropertyType.EXTERNALVIEW), 0);
Assert.assertEquals(accessor.getReadCount(PropertyType.LIVEINSTANCES), 0);
Assert.assertEquals(accessor.getReadCount(PropertyType.CURRENTSTATES), 0);
- // cluster config always get reloaded
- Assert.assertEquals(accessor.getReadCount(PropertyType.CONFIGS), 1);
+ Assert.assertEquals(accessor.getReadCount(PropertyType.CONFIGS), 0);
accessor.clearReadCounters();
// refresh again should read nothing as ideal state is same
@@ -70,7 +69,7 @@ public class TestControllerDataProviderSelectiveUpdate extends ZkStandAloneCMTes
Assert.assertEquals(accessor.getReadCount(PropertyType.EXTERNALVIEW), 0);
Assert.assertEquals(accessor.getReadCount(PropertyType.LIVEINSTANCES), 0);
Assert.assertEquals(accessor.getReadCount(PropertyType.CURRENTSTATES), 0);
- Assert.assertEquals(accessor.getReadCount(PropertyType.CONFIGS), 1);
+ Assert.assertEquals(accessor.getReadCount(PropertyType.CONFIGS), 0);
accessor.clearReadCounters();
cache.notifyDataChange(HelixConstants.ChangeType.LIVE_INSTANCE);
@@ -79,7 +78,7 @@ public class TestControllerDataProviderSelectiveUpdate extends ZkStandAloneCMTes
Assert.assertEquals(accessor.getReadCount(PropertyType.EXTERNALVIEW), 0);
Assert.assertEquals(accessor.getReadCount(PropertyType.LIVEINSTANCES), 0);
Assert.assertEquals(accessor.getReadCount(PropertyType.CURRENTSTATES), 0);
- Assert.assertEquals(accessor.getReadCount(PropertyType.CONFIGS), 1);
+ Assert.assertEquals(accessor.getReadCount(PropertyType.CONFIGS), 0);
}
@Test(dependsOnMethods = {"testUpdateOnNotification"})
@@ -105,7 +104,7 @@ public class TestControllerDataProviderSelectiveUpdate extends ZkStandAloneCMTes
Assert.assertEquals(accessor.getReadCount(PropertyType.EXTERNALVIEW), 0);
Assert.assertEquals(accessor.getReadCount(PropertyType.LIVEINSTANCES), 0);
Assert.assertEquals(accessor.getReadCount(PropertyType.CURRENTSTATES), 0);
- Assert.assertEquals(accessor.getReadCount(PropertyType.CONFIGS), 1);
+ Assert.assertEquals(accessor.getReadCount(PropertyType.CONFIGS), 0);
// add a new resource
_gSetupTool.addResourceToCluster(CLUSTER_NAME, "TestDB_1", _PARTITIONS, STATE_MODEL);
@@ -148,7 +147,7 @@ public class TestControllerDataProviderSelectiveUpdate extends ZkStandAloneCMTes
cache.notifyDataChange(HelixConstants.ChangeType.RESOURCE_CONFIG);
cache.refresh(accessor);
- // 1 Cluster Config change + 2 Resource Config Changes
- Assert.assertEquals(accessor.getReadCount(PropertyType.CONFIGS), 3);
+ // 2 Resource Config Changes
+ Assert.assertEquals(accessor.getReadCount(PropertyType.CONFIGS), 2);
}
}