Repository: helix
Updated Branches:
  refs/heads/master 1c68b1ca8 -> 17ca0f328


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/17ca0f32
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/17ca0f32
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/17ca0f32

Branch: refs/heads/master
Commit: 17ca0f328368ca44ed7b97c2b51d90104950c9ca
Parents: 1c68b1c
Author: Eric Kim <[email protected]>
Authored: Mon Jan 8 17:07:06 2018 -0800
Committer: Eric Kim <[email protected]>
Committed: Mon Jan 8 17:07:06 2018 -0800

----------------------------------------------------------------------
 .../apache/helix/messaging/CriteriaEvaluator.java   | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/17ca0f32/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..67e2de1 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,8 @@ package org.apache.helix.messaging;
  * under the License.
  */
 
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -54,9 +56,19 @@ 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 {
+        properties = 
Collections.singletonList(accessor.getProperty(keyBuilder.externalView(resourceName)));
+      }
     } else if (dataSource == DataSource.IDEALSTATES) {
-      properties = accessor.getChildValues(keyBuilder.idealStates());
+      String resourceName = recipientCriteria.getResource();
+      if (Strings.isNullOrEmpty(resourceName)) {
+        properties = accessor.getChildValues(keyBuilder.idealStates());
+      } else {
+        properties = 
Collections.singletonList(accessor.getProperty(keyBuilder.idealStates(resourceName)));
+      }
     } else if (dataSource == DataSource.LIVEINSTANCES) {
       properties = accessor.getChildValues(keyBuilder.liveInstances());
     } else if (dataSource == DataSource.INSTANCES) {

Reply via email to