helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject helix git commit: Added new DataSource values LIVEINSTANCES and INSTANCES and made CriteriaEvaluator support them
Date Wed, 08 Feb 2017 23:02:08 GMT
Repository: helix
Updated Branches:
  refs/heads/helix-0.6.x 3a61f5db1 -> fe7696945


Added new DataSource values LIVEINSTANCES and INSTANCES and made CriteriaEvaluator support
them


Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/fe769694
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/fe769694
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/fe769694

Branch: refs/heads/helix-0.6.x
Commit: fe76969458b551eb75ad983c55eafafaa39f0f3b
Parents: 3a61f5d
Author: Yinan Li <liyinan926@gmail.com>
Authored: Mon Feb 6 14:29:38 2017 -0800
Committer: Junkai Xue <jxue@linkedin.com>
Committed: Wed Feb 8 14:50:00 2017 -0800

----------------------------------------------------------------------
 .../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/fe769694/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/fe769694/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>();


Mime
View raw message