Repository: helix Updated Branches: refs/heads/master 9e51cb7bd -> e5fd7345c
Added new DataSource values LIVEINSTANCES and INSTANCES and made CriteriaEvaluator support them Signed-off-by: Yinan Li <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/helix/repo Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/70962a0d Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/70962a0d Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/70962a0d Branch: refs/heads/master Commit: 70962a0de5a58569e3f4f4d3f9533f540783db66 Parents: eb82c95 Author: Yinan Li <[email protected]> Authored: Fri Aug 28 13:33:04 2015 -0700 Committer: Yinan Li <[email protected]> Committed: Fri Aug 28 13:33:04 2015 -0700 ---------------------------------------------------------------------- .../src/main/java/org/apache/helix/Criteria.java | 4 +++- .../apache/helix/messaging/CriteriaEvaluator.java | 16 +++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/helix/blob/70962a0d/helix-core/src/main/java/org/apache/helix/Criteria.java ---------------------------------------------------------------------- diff --git a/helix-core/src/main/java/org/apache/helix/Criteria.java b/helix-core/src/main/java/org/apache/helix/Criteria.java index 75781e1..5750326 100644 --- a/helix-core/src/main/java/org/apache/helix/Criteria.java +++ b/helix-core/src/main/java/org/apache/helix/Criteria.java @@ -25,7 +25,9 @@ package org.apache.helix; public class Criteria { public enum DataSource { IDEALSTATES, - EXTERNALVIEW + EXTERNALVIEW, + LIVEINSTANCES, + INSTANCES } /** http://git-wip-us.apache.org/repos/asf/helix/blob/70962a0d/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 9ca20af..c57992f 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,7 +19,6 @@ package org.apache.helix.messaging; * under the License. */ -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -50,14 +49,19 @@ public class CriteriaEvaluator { // get the data HelixDataAccessor accessor = manager.getHelixDataAccessor(); PropertyKey.Builder keyBuilder = accessor.keyBuilder(); - Set<Map<String, String>> selected = Sets.newHashSet(); + List<HelixProperty> properties; - if (recipientCriteria.getDataSource() == DataSource.EXTERNALVIEW) { + DataSource dataSource = recipientCriteria.getDataSource(); + if (dataSource == DataSource.EXTERNALVIEW) { properties = accessor.getChildValues(keyBuilder.externalViews()); - } else if (recipientCriteria.getDataSource() == DataSource.IDEALSTATES) { + } else if (dataSource == DataSource.IDEALSTATES) { properties = accessor.getChildValues(keyBuilder.idealStates()); + } else if (dataSource == DataSource.LIVEINSTANCES) { + properties = accessor.getChildValues(keyBuilder.liveInstances()); + } else if (dataSource == DataSource.INSTANCES) { + properties = accessor.getChildValues(keyBuilder.instances()); } else { - return Collections.emptyList(); + return Lists.newArrayList(); } // flatten the data @@ -72,6 +76,8 @@ public class CriteriaEvaluator { } } + Set<Map<String, String>> selected = Sets.newHashSet(); + // deduplicate and convert the matches into the required format for (ZNRecordRow row : result) { Map<String, String> resultRow = new HashMap<String, String>();
