You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by jx...@apache.org on 2019/11/21 00:32:49 UTC
[helix] branch master updated (e3a7a0c -> b857af7)
This is an automated email from the ASF dual-hosted git repository.
jxue pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git.
from e3a7a0c Add default implementation to new interface methods (#626)
new 634484d Fix RoutingDataCache always requiring full refresh for current state.
new 1d1eae0 Remove unnecessary boxing for boolean values.
new 9935fe5 Add unit test.
new 25ccf97 Remove println.
new b857af7 Format long lines.
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../helix/common/caches/BasicClusterDataCache.java | 10 ++---
.../apache/helix/spectator/RoutingDataCache.java | 4 +-
.../helix/spectator/TestRoutingDataCache.java | 45 ++++++++++++++++++++++
3 files changed, 52 insertions(+), 7 deletions(-)
[helix] 02/05: Remove unnecessary boxing for boolean values.
Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jxue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
View the commit online:
https://github.com/apache/helix/commit/1d1eae0f4c6ea7d7fe2366983349dcf5f35e85d5
commit 1d1eae0f4c6ea7d7fe2366983349dcf5f35e85d5
Author: Huizhi Lu <ih...@gmail.com>
AuthorDate: Wed Sep 18 17:09:06 2019 -0700
Remove unnecessary boxing for boolean values.
---
.../org/apache/helix/common/caches/BasicClusterDataCache.java | 9 ++++-----
.../main/java/org/apache/helix/spectator/RoutingDataCache.java | 3 +--
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/helix-core/src/main/java/org/apache/helix/common/caches/BasicClusterDataCache.java b/helix-core/src/main/java/org/apache/helix/common/caches/BasicClusterDataCache.java
index 5389493..1260a2b 100644
--- a/helix-core/src/main/java/org/apache/helix/common/caches/BasicClusterDataCache.java
+++ b/helix-core/src/main/java/org/apache/helix/common/caches/BasicClusterDataCache.java
@@ -107,13 +107,13 @@ public class BasicClusterDataCache implements ControlContextProvider {
long startTime = System.currentTimeMillis();
if (_propertyDataChangedMap.get(HelixConstants.ChangeType.EXTERNAL_VIEW)) {
- _propertyDataChangedMap.put(HelixConstants.ChangeType.EXTERNAL_VIEW, Boolean.valueOf(false));
+ _propertyDataChangedMap.put(HelixConstants.ChangeType.EXTERNAL_VIEW, false);
_externalViewCache.refresh(accessor);
}
if (_propertyDataChangedMap.get(HelixConstants.ChangeType.LIVE_INSTANCE)) {
long start = System.currentTimeMillis();
- _propertyDataChangedMap.put(HelixConstants.ChangeType.LIVE_INSTANCE, Boolean.valueOf(false));
+ _propertyDataChangedMap.put(HelixConstants.ChangeType.LIVE_INSTANCE, false);
_propertyDataChangedMap.put(HelixConstants.ChangeType.CURRENT_STATE, true);
_liveInstancePropertyCache.refresh(accessor);
LOG.info("Reload LiveInstances: " + _liveInstancePropertyCache.getPropertyMap().keySet()
@@ -122,8 +122,7 @@ public class BasicClusterDataCache implements ControlContextProvider {
if (_propertyDataChangedMap.get(HelixConstants.ChangeType.INSTANCE_CONFIG)) {
long start = System.currentTimeMillis();
- _propertyDataChangedMap.put(HelixConstants.ChangeType.INSTANCE_CONFIG,
- Boolean.valueOf(false));
+ _propertyDataChangedMap.put(HelixConstants.ChangeType.INSTANCE_CONFIG, false);
_instanceConfigPropertyCache.refresh(accessor);
LOG.info("Reload InstanceConfig: " + _instanceConfigPropertyCache.getPropertyMap().keySet()
+ ". Takes " + (System.currentTimeMillis() - start) + " ms");
@@ -184,7 +183,7 @@ public class BasicClusterDataCache implements ControlContextProvider {
* @param changeType
*/
public void notifyDataChange(HelixConstants.ChangeType changeType) {
- _propertyDataChangedMap.put(changeType, Boolean.valueOf(true));
+ _propertyDataChangedMap.put(changeType, true);
}
/**
diff --git a/helix-core/src/main/java/org/apache/helix/spectator/RoutingDataCache.java b/helix-core/src/main/java/org/apache/helix/spectator/RoutingDataCache.java
index fad3c92..b5fdd72 100644
--- a/helix-core/src/main/java/org/apache/helix/spectator/RoutingDataCache.java
+++ b/helix-core/src/main/java/org/apache/helix/spectator/RoutingDataCache.java
@@ -69,8 +69,7 @@ class RoutingDataCache extends BasicClusterDataCache {
if (_sourceDataType.equals(PropertyType.TARGETEXTERNALVIEW) && _propertyDataChangedMap
.get(HelixConstants.ChangeType.TARGET_EXTERNAL_VIEW)) {
long start = System.currentTimeMillis();
- _propertyDataChangedMap
- .put(HelixConstants.ChangeType.TARGET_EXTERNAL_VIEW, Boolean.valueOf(false));
+ _propertyDataChangedMap.put(HelixConstants.ChangeType.TARGET_EXTERNAL_VIEW, false);
_targetExternalViewCache.refresh(accessor);
LOG.info("Reload " + _targetExternalViewCache.getExternalViewMap().keySet().size()
+ " TargetExternalViews. Takes " + (System.currentTimeMillis() - start) + " ms");
[helix] 04/05: Remove println.
Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jxue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
View the commit online:
https://github.com/apache/helix/commit/25ccf975415f0c52336cc9d623d891e7bf243692
commit 25ccf975415f0c52336cc9d623d891e7bf243692
Author: Huizhi Lu <ih...@gmail.com>
AuthorDate: Thu Nov 7 10:31:13 2019 -0800
Remove println.
---
.../main/java/org/apache/helix/common/caches/BasicClusterDataCache.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/helix-core/src/main/java/org/apache/helix/common/caches/BasicClusterDataCache.java b/helix-core/src/main/java/org/apache/helix/common/caches/BasicClusterDataCache.java
index 3584b36..1260a2b 100644
--- a/helix-core/src/main/java/org/apache/helix/common/caches/BasicClusterDataCache.java
+++ b/helix-core/src/main/java/org/apache/helix/common/caches/BasicClusterDataCache.java
@@ -113,7 +113,6 @@ public class BasicClusterDataCache implements ControlContextProvider {
if (_propertyDataChangedMap.get(HelixConstants.ChangeType.LIVE_INSTANCE)) {
long start = System.currentTimeMillis();
- System.out.println("reloading live instances");
_propertyDataChangedMap.put(HelixConstants.ChangeType.LIVE_INSTANCE, false);
_propertyDataChangedMap.put(HelixConstants.ChangeType.CURRENT_STATE, true);
_liveInstancePropertyCache.refresh(accessor);
[helix] 05/05: Format long lines.
Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jxue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
View the commit online:
https://github.com/apache/helix/commit/b857af74e5a323aa37f0bf0b6989c7f4b4a9961d
commit b857af74e5a323aa37f0bf0b6989c7f4b4a9961d
Author: Huizhi Lu <ih...@gmail.com>
AuthorDate: Thu Nov 7 10:32:51 2019 -0800
Format long lines.
---
.../test/java/org/apache/helix/spectator/TestRoutingDataCache.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/helix-core/src/test/java/org/apache/helix/spectator/TestRoutingDataCache.java b/helix-core/src/test/java/org/apache/helix/spectator/TestRoutingDataCache.java
index bf10bf4..2cfc62a 100644
--- a/helix-core/src/test/java/org/apache/helix/spectator/TestRoutingDataCache.java
+++ b/helix-core/src/test/java/org/apache/helix/spectator/TestRoutingDataCache.java
@@ -138,7 +138,8 @@ public class TestRoutingDataCache extends ZkStandAloneCMTestBase {
// 1. Initial cache refresh.
cache.refresh(accessor);
- Map<String, Map<String, Map<String, CurrentState>>> currentStatesV1 = cache.getCurrentStatesMap();
+ Map<String, Map<String, Map<String, CurrentState>>> currentStatesV1 =
+ cache.getCurrentStatesMap();
// Current states map is not empty and size equals to number of live instances.
Assert.assertFalse(currentStatesV1.isEmpty());
@@ -153,7 +154,8 @@ public class TestRoutingDataCache extends ZkStandAloneCMTestBase {
_participants[0].syncStop();
cache.notifyDataChange(HelixConstants.ChangeType.LIVE_INSTANCE);
cache.refresh(accessor);
- Map<String, Map<String, Map<String, CurrentState>>> currentStatesV2 = cache.getCurrentStatesMap();
+ Map<String, Map<String, Map<String, CurrentState>>> currentStatesV2 =
+ cache.getCurrentStatesMap();
// Current states cache should refresh and change.
Assert.assertFalse(currentStatesV2.isEmpty());
[helix] 03/05: Add unit test.
Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jxue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
View the commit online:
https://github.com/apache/helix/commit/9935fe51d83ab29e880165c11458f460cbff1d73
commit 9935fe51d83ab29e880165c11458f460cbff1d73
Author: Huizhi Lu <ih...@gmail.com>
AuthorDate: Tue Nov 5 18:35:51 2019 -0800
Add unit test.
---
.../helix/common/caches/BasicClusterDataCache.java | 1 +
.../helix/spectator/TestRoutingDataCache.java | 43 ++++++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/helix-core/src/main/java/org/apache/helix/common/caches/BasicClusterDataCache.java b/helix-core/src/main/java/org/apache/helix/common/caches/BasicClusterDataCache.java
index 1260a2b..3584b36 100644
--- a/helix-core/src/main/java/org/apache/helix/common/caches/BasicClusterDataCache.java
+++ b/helix-core/src/main/java/org/apache/helix/common/caches/BasicClusterDataCache.java
@@ -113,6 +113,7 @@ public class BasicClusterDataCache implements ControlContextProvider {
if (_propertyDataChangedMap.get(HelixConstants.ChangeType.LIVE_INSTANCE)) {
long start = System.currentTimeMillis();
+ System.out.println("reloading live instances");
_propertyDataChangedMap.put(HelixConstants.ChangeType.LIVE_INSTANCE, false);
_propertyDataChangedMap.put(HelixConstants.ChangeType.CURRENT_STATE, true);
_liveInstancePropertyCache.refresh(accessor);
diff --git a/helix-core/src/test/java/org/apache/helix/spectator/TestRoutingDataCache.java b/helix-core/src/test/java/org/apache/helix/spectator/TestRoutingDataCache.java
index 09bcac4..bf10bf4 100644
--- a/helix-core/src/test/java/org/apache/helix/spectator/TestRoutingDataCache.java
+++ b/helix-core/src/test/java/org/apache/helix/spectator/TestRoutingDataCache.java
@@ -19,6 +19,8 @@ package org.apache.helix.spectator;
* under the License.
*/
+import java.util.Map;
+
import org.apache.helix.HelixConstants;
import org.apache.helix.PropertyType;
import org.apache.helix.TestHelper;
@@ -26,6 +28,7 @@ import org.apache.helix.ZNRecord;
import org.apache.helix.integration.common.ZkStandAloneCMTestBase;
import org.apache.helix.manager.zk.ZkBaseDataAccessor;
import org.apache.helix.mock.MockZkHelixDataAccessor;
+import org.apache.helix.model.CurrentState;
import org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier;
import org.apache.helix.tools.ClusterVerifiers.ZkHelixClusterVerifier;
import org.testng.Assert;
@@ -122,4 +125,44 @@ public class TestRoutingDataCache extends ZkStandAloneCMTestBase {
cache.refresh(accessor);
Assert.assertEquals(accessor.getReadCount(PropertyType.EXTERNALVIEW), 1);
}
+
+ @Test
+ public void testCurrentStatesSelectiveUpdate() {
+ String clusterName = "CLUSTER_" + TestHelper.getTestClassName();
+ MockZkHelixDataAccessor accessor =
+ new MockZkHelixDataAccessor(CLUSTER_NAME, new ZkBaseDataAccessor<>(_gZkClient));
+ RoutingDataCache cache = new RoutingDataCache(clusterName, PropertyType.CURRENTSTATES);
+
+ // Empty current states map before refreshing.
+ Assert.assertTrue(cache.getCurrentStatesMap().isEmpty());
+
+ // 1. Initial cache refresh.
+ cache.refresh(accessor);
+ Map<String, Map<String, Map<String, CurrentState>>> currentStatesV1 = cache.getCurrentStatesMap();
+
+ // Current states map is not empty and size equals to number of live instances.
+ Assert.assertFalse(currentStatesV1.isEmpty());
+ Assert.assertEquals(currentStatesV1.size(), _participants.length);
+
+ // 2. Without any change, refresh routing data cache.
+ cache.refresh(accessor);
+ // Because of no current states change, current states cache doesn't refresh.
+ Assert.assertEquals(cache.getCurrentStatesMap(), currentStatesV1);
+
+ // 3. Stop one participant to make live instance change and refresh routing data cache.
+ _participants[0].syncStop();
+ cache.notifyDataChange(HelixConstants.ChangeType.LIVE_INSTANCE);
+ cache.refresh(accessor);
+ Map<String, Map<String, Map<String, CurrentState>>> currentStatesV2 = cache.getCurrentStatesMap();
+
+ // Current states cache should refresh and change.
+ Assert.assertFalse(currentStatesV2.isEmpty());
+ Assert.assertEquals(currentStatesV2.size(), _participants.length - 1);
+ Assert.assertFalse(currentStatesV1.equals(currentStatesV2));
+
+ cache.refresh(accessor);
+
+ // No change.
+ Assert.assertEquals(cache.getCurrentStatesMap(), currentStatesV2);
+ }
}
[helix] 01/05: Fix RoutingDataCache always requiring full refresh
for current state.
Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jxue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
View the commit online:
https://github.com/apache/helix/commit/634484d96f1854ef733f6615919df87c601d024c
commit 634484d96f1854ef733f6615919df87c601d024c
Author: Huizhi Lu <ih...@gmail.com>
AuthorDate: Wed Sep 18 16:50:39 2019 -0700
Fix RoutingDataCache always requiring full refresh for current state.
---
.../main/java/org/apache/helix/common/caches/BasicClusterDataCache.java | 1 +
.../src/main/java/org/apache/helix/spectator/RoutingDataCache.java | 1 +
2 files changed, 2 insertions(+)
diff --git a/helix-core/src/main/java/org/apache/helix/common/caches/BasicClusterDataCache.java b/helix-core/src/main/java/org/apache/helix/common/caches/BasicClusterDataCache.java
index d4ffedd..5389493 100644
--- a/helix-core/src/main/java/org/apache/helix/common/caches/BasicClusterDataCache.java
+++ b/helix-core/src/main/java/org/apache/helix/common/caches/BasicClusterDataCache.java
@@ -114,6 +114,7 @@ public class BasicClusterDataCache implements ControlContextProvider {
if (_propertyDataChangedMap.get(HelixConstants.ChangeType.LIVE_INSTANCE)) {
long start = System.currentTimeMillis();
_propertyDataChangedMap.put(HelixConstants.ChangeType.LIVE_INSTANCE, Boolean.valueOf(false));
+ _propertyDataChangedMap.put(HelixConstants.ChangeType.CURRENT_STATE, true);
_liveInstancePropertyCache.refresh(accessor);
LOG.info("Reload LiveInstances: " + _liveInstancePropertyCache.getPropertyMap().keySet()
+ ". Takes " + (System.currentTimeMillis() - start) + " ms");
diff --git a/helix-core/src/main/java/org/apache/helix/spectator/RoutingDataCache.java b/helix-core/src/main/java/org/apache/helix/spectator/RoutingDataCache.java
index 49a4057..fad3c92 100644
--- a/helix-core/src/main/java/org/apache/helix/spectator/RoutingDataCache.java
+++ b/helix-core/src/main/java/org/apache/helix/spectator/RoutingDataCache.java
@@ -79,6 +79,7 @@ class RoutingDataCache extends BasicClusterDataCache {
if (_sourceDataType.equals(PropertyType.CURRENTSTATES) && _propertyDataChangedMap
.get(HelixConstants.ChangeType.CURRENT_STATE)) {
long start = System.currentTimeMillis();
+ _propertyDataChangedMap.put(HelixConstants.ChangeType.CURRENT_STATE, false);
Map<String, LiveInstance> liveInstanceMap = getLiveInstances();
_currentStateCache.refresh(accessor, liveInstanceMap);
LOG.info("Reload CurrentStates. Takes " + (System.currentTimeMillis() - start) + " ms");