You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2017/05/02 08:56:40 UTC

lucene-solr:feature/autoscaling: SOLR-10278: special case of global tags were not taken care of

Repository: lucene-solr
Updated Branches:
  refs/heads/feature/autoscaling 83f8ed863 -> 2818ee91d


SOLR-10278: special case of global tags were not taken care of


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/2818ee91
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/2818ee91
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/2818ee91

Branch: refs/heads/feature/autoscaling
Commit: 2818ee91dd035110d8ccf0234102a29460e800b8
Parents: 83f8ed8
Author: Noble Paul <no...@apache.org>
Authored: Tue May 2 18:26:31 2017 +0930
Committer: Noble Paul <no...@apache.org>
Committed: Tue May 2 18:26:31 2017 +0930

----------------------------------------------------------------------
 .../apache/solr/cloud/autoscaling/Clause.java   | 42 +++++++++++++-------
 1 file changed, 27 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2818ee91/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Clause.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Clause.java b/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Clause.java
index 4947fd4..dd113f8 100644
--- a/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Clause.java
+++ b/solr/solrj/src/java/org/apache/solr/cloud/autoscaling/Clause.java
@@ -96,9 +96,17 @@ public class Clause implements MapWriter, Comparable<Clause> {
 
   @Override
   public int compareTo(Clause that) {
-    int v = Integer.compare(this.tag.op.priority, that.tag.op.priority);
-    if (v != 0) return v;
-    return Integer.compare(this.replica.op.priority, that.replica.op.priority);
+    try {
+      int v = Integer.compare(this.tag.op.priority, that.tag.op.priority);
+      if (v != 0) return v;
+      return this.isPerCollectiontag() && that.isPerCollectiontag() ?
+          Integer.compare(this.replica.op.priority, that.replica.op.priority) :
+          0;
+    } catch (NullPointerException e) {
+      System.out.println("this: " + Utils.toJSONString(this));
+      System.out.println("thAt: " + Utils.toJSONString(that));
+      throw e;
+    }
   }
 
   static class Condition {
@@ -164,18 +172,22 @@ public class Clause implements MapWriter, Comparable<Clause> {
 
   TestStatus test(Row row) {
     AtomicReference<TestStatus> result = new AtomicReference<>(NOT_APPLICABLE);
-
-    for (Map.Entry<String, Map<String, List<ReplicaInfo>>> colls : row.replicaInfo.entrySet()) {
-      if (result.get() == FAIL) break;
-      if (!collection.isPass(colls.getKey())) continue;
-      int count = 0;
-      for (Map.Entry<String, List<ReplicaInfo>> shards : colls.getValue().entrySet()) {
-        if (!shard.isPass(shards.getKey()) || result.get() == FAIL) break;
-        count += shards.getValue().size();
-        if (shard.val.equals(EACH)) testReplicaCount(row, result, count);
-        if (EACH.equals(shard.val)) count = 0;
+    if (isPerCollectiontag()) {
+
+      for (Map.Entry<String, Map<String, List<ReplicaInfo>>> colls : row.replicaInfo.entrySet()) {
+        if (result.get() == FAIL) break;
+        if (!collection.isPass(colls.getKey())) continue;
+        int count = 0;
+        for (Map.Entry<String, List<ReplicaInfo>> shards : colls.getValue().entrySet()) {
+          if (!shard.isPass(shards.getKey()) || result.get() == FAIL) break;
+          count += shards.getValue().size();
+          if (shard.val.equals(EACH)) testReplicaCount(row, result, count);
+          if (EACH.equals(shard.val)) count = 0;
+        }
+        if (shard.val.equals(ANY)) testReplicaCount(row, result, count);
       }
-      if (shard.val.equals(ANY)) testReplicaCount(row, result, count);
+    } else {
+      if (!tag.isPass(row)) result.set(TestStatus.FAIL);
     }
     if (result.get() == FAIL) row.violations.add(this);
     return result.get();
@@ -183,7 +195,7 @@ public class Clause implements MapWriter, Comparable<Clause> {
   }
 
   private void testReplicaCount(Row row, AtomicReference<TestStatus> result, int count) {
-    if("node".equals(tag.name)) if(!tag.isPass(row.node)) return;
+    if ("node".equals(tag.name)) if (!tag.isPass(row.node)) return;
     boolean checkCount = replica.op.match(replica.val, 0) != PASS || count > 0;
     if (replica.op == WILDCARD && count > 0 && !tag.isPass(row)) {//nodeRole:'!overseer', strict:false
       result.set(FAIL);