helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [09/50] [abbrv] helix git commit: Import EvaluateCriteria change from master branch
Date Thu, 22 Jun 2017 22:57:28 GMT
Import EvaluateCriteria change from master branch

Import partial of code change of:
https://github.com/apache/helix/commit/2a2908ac3d536cf3595bb2eb23d49c8153c51d5e


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

Branch: refs/heads/master
Commit: da8906ad145d7195e0b4eb7f3c1e21662c980957
Parents: fe76969
Author: Yinan Li <liyinan926@gmail.com>
Authored: Wed Feb 8 20:22:54 2017 -0800
Committer: Junkai Xue <jxue@linkedin.com>
Committed: Wed Feb 8 20:24:11 2017 -0800

----------------------------------------------------------------------
 .../helix/messaging/CriteriaEvaluator.java       | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/da8906ad/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 c57992f..11f4b82 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
@@ -33,6 +33,7 @@ import org.apache.helix.HelixProperty;
 import org.apache.helix.PropertyKey;
 import org.apache.log4j.Logger;
 
+import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 
@@ -71,7 +72,9 @@ public class CriteriaEvaluator {
     Set<String> liveParticipants = accessor.getChildValuesMap(keyBuilder.liveInstances()).keySet();
     List<ZNRecordRow> result = Lists.newArrayList();
     for (ZNRecordRow row : allRows) {
-      if (rowMatches(recipientCriteria, row) && liveParticipants.contains(row.getMapSubKey()))
{
+      // The participant instance name is stored in the return value of either getRecordId()
or getMapSubKey()
+      if (rowMatches(recipientCriteria, row) &&
+          (liveParticipants.contains(row.getRecordId()) || liveParticipants.contains(row.getMapSubKey())))
{
         result.add(row);
       }
     }
@@ -81,8 +84,9 @@ public class CriteriaEvaluator {
     // deduplicate and convert the matches into the required format
     for (ZNRecordRow row : result) {
       Map<String, String> resultRow = new HashMap<String, String>();
-      resultRow.put("instanceName",
-          !recipientCriteria.getInstanceName().equals("") ? row.getMapSubKey() : "");
+      resultRow.put("instanceName", !recipientCriteria.getInstanceName().equals("") ?
+          (!Strings.isNullOrEmpty(row.getMapSubKey()) ? row.getMapSubKey() : row.getRecordId())
:
+          "");
       resultRow.put("resourceName", !recipientCriteria.getResource().equals("") ? row.getRecordId()
           : "");
       resultRow.put("partitionName", !recipientCriteria.getPartition().equals("") ? row.getMapKey()
@@ -106,10 +110,11 @@ public class CriteriaEvaluator {
     String resourceName = normalizePattern(criteria.getResource());
     String partitionName = normalizePattern(criteria.getPartition());
     String partitionState = normalizePattern(criteria.getPartitionState());
-    return stringMatches(instanceName, row.getMapSubKey())
-        && stringMatches(resourceName, row.getRecordId())
-        && stringMatches(partitionName, row.getMapKey())
-        && stringMatches(partitionState, row.getMapValue());
+    return (stringMatches(instanceName, Strings.nullToEmpty(row.getMapSubKey())) ||
+            stringMatches(instanceName, Strings.nullToEmpty(row.getRecordId())))
+        && stringMatches(resourceName, Strings.nullToEmpty(row.getRecordId()))
+        && stringMatches(partitionName, Strings.nullToEmpty(row.getMapKey()))
+        && stringMatches(partitionState, Strings.nullToEmpty(row.getMapValue()));
   }
 
   /**


Mime
View raw message