Repository: helix Updated Branches: refs/heads/master 17ca0f328 -> 16f4a9b7c (forced update)
In CriteriaEvaluator.evaluateCriteria, if resourcename is provided, avoid downloading data for all resources Project: http://git-wip-us.apache.org/repos/asf/helix/repo Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/16f4a9b7 Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/16f4a9b7 Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/16f4a9b7 Branch: refs/heads/master Commit: 16f4a9b7c7864e15076bf4b9c4d2d2eda7d0ce78 Parents: 1c68b1c Author: Eric Kim <[email protected]> Authored: Mon Jan 8 17:07:06 2018 -0800 Committer: Junkai Xue <[email protected]> Committed: Mon Jan 8 17:51:37 2018 -0800 ---------------------------------------------------------------------- .../helix/messaging/CriteriaEvaluator.java | 26 ++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/helix/blob/16f4a9b7/helix-core/src/main/java/org/apache/helix/messaging/CriteriaEvaluator.java ---------------------------------------------------------------------- diff --git a/helix-core/src/main/java/org/apache/helix/messaging/CriteriaEvaluator.java b/helix-core/src/main/java/org/apache/helix/messaging/CriteriaEvaluator.java index 11f4b82..398ef2b 100644 --- a/helix-core/src/main/java/org/apache/helix/messaging/CriteriaEvaluator.java +++ b/helix-core/src/main/java/org/apache/helix/messaging/CriteriaEvaluator.java @@ -19,6 +19,7 @@ package org.apache.helix.messaging; * under the License. */ +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -28,6 +29,7 @@ import java.util.regex.Pattern; import org.apache.helix.Criteria; import org.apache.helix.Criteria.DataSource; import org.apache.helix.HelixDataAccessor; +import org.apache.helix.HelixException; import org.apache.helix.HelixManager; import org.apache.helix.HelixProperty; import org.apache.helix.PropertyKey; @@ -54,9 +56,29 @@ public class CriteriaEvaluator { List<HelixProperty> properties; DataSource dataSource = recipientCriteria.getDataSource(); if (dataSource == DataSource.EXTERNALVIEW) { - properties = accessor.getChildValues(keyBuilder.externalViews()); + String resourceName = recipientCriteria.getResource(); + if (Strings.isNullOrEmpty(resourceName)) { + properties = accessor.getChildValues(keyBuilder.externalViews()); + } else { + HelixProperty data = accessor.getProperty(keyBuilder.externalView(resourceName)); + if (data == null) { + throw new HelixException( + String.format("Specified resource %s externalView is not found!", resourceName)); + } + properties = Collections.singletonList(data); + } } else if (dataSource == DataSource.IDEALSTATES) { - properties = accessor.getChildValues(keyBuilder.idealStates()); + String resourceName = recipientCriteria.getResource(); + if (Strings.isNullOrEmpty(resourceName)) { + properties = accessor.getChildValues(keyBuilder.idealStates()); + } else { + HelixProperty data = accessor.getProperty(keyBuilder.idealStates(resourceName)); + if (data == null) { + throw new HelixException( + String.format("Specified resource %s idealState is not found!", resourceName)); + } + properties = Collections.singletonList(data); + } } else if (dataSource == DataSource.LIVEINSTANCES) { properties = accessor.getChildValues(keyBuilder.liveInstances()); } else if (dataSource == DataSource.INSTANCES) {
