You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2016/09/15 05:35:04 UTC

lucene-solr:master: SOLR-9484: The modify collection API should wait for the modified properties to show up in the cluster state

Repository: lucene-solr
Updated Branches:
  refs/heads/master 5b770b56d -> 70fd627ca


SOLR-9484: The modify collection API should wait for the modified properties to show up in the cluster state


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

Branch: refs/heads/master
Commit: 70fd627ca78ed58d0316e6c173a398efc69aaa5e
Parents: 5b770b5
Author: Shalin Shekhar Mangar <sh...@apache.org>
Authored: Thu Sep 15 11:04:48 2016 +0530
Committer: Shalin Shekhar Mangar <sh...@apache.org>
Committed: Thu Sep 15 11:04:48 2016 +0530

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  3 ++
 .../cloud/OverseerCollectionMessageHandler.java | 20 +++++++++++++
 .../org/apache/solr/cloud/rule/RulesTest.java   | 31 +++++++-------------
 3 files changed, 34 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/70fd627c/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 333a787..333cfb1 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -126,6 +126,9 @@ Bug Fixes
   one or more sub-shards replicas do not recover due to the leader crashing or restarting between the time
   the replicas are created and before they can recover. This can cause data loss. (shalin)
 
+* SOLR-9484: The modify collection API should wait for the modified properties to show up in the
+  cluster state. (Cao Manh Dat, shalin)
+
 Optimizations
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/70fd627c/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionMessageHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionMessageHandler.java b/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionMessageHandler.java
index 36b5105..9f14e45 100644
--- a/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionMessageHandler.java
+++ b/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionMessageHandler.java
@@ -662,6 +662,26 @@ public class OverseerCollectionMessageHandler implements OverseerMessageHandler
     }
     
     overseer.getStateUpdateQueue(zkStateReader.getZkClient()).offer(Utils.toJSON(message));
+
+    TimeOut timeout = new TimeOut(30, TimeUnit.SECONDS);
+    boolean areChangesVisible = true;
+    while (!timeout.hasTimedOut()) {
+      DocCollection collection = zkStateReader.getClusterState().getCollection(collectionName);
+      areChangesVisible = true;
+      for (Map.Entry<String,Object> updateEntry : message.getProperties().entrySet()) {
+        String updateKey = updateEntry.getKey();
+        if (!updateKey.equals(ZkStateReader.COLLECTION_PROP)
+            && !updateKey.equals(Overseer.QUEUE_OPERATION)
+            && !collection.get(updateKey).equals(updateEntry.getValue())){
+          areChangesVisible = false;
+          break;
+        }
+      }
+      if (areChangesVisible) break;
+      Thread.sleep(100);
+    }
+    if (!areChangesVisible)
+      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Could not modify collection " + message);
   }
 
   void cleanupCollection(String collectionName, NamedList results) throws Exception {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/70fd627c/solr/core/src/test/org/apache/solr/cloud/rule/RulesTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/rule/RulesTest.java b/solr/core/src/test/org/apache/solr/cloud/rule/RulesTest.java
index 83f02b1..5cb329a 100644
--- a/solr/core/src/test/org/apache/solr/cloud/rule/RulesTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/rule/RulesTest.java
@@ -234,25 +234,16 @@ public class RulesTest extends AbstractFullDistribZkTestBase {
     }
 
 
-    for (int i = 0; i < 20; i++) {
-      DocCollection rulesCollection = ZkStateReader.getCollectionLive(cloudClient.getZkStateReader(), rulesColl);
-      log.info("version_of_coll {}  ", rulesCollection.getZNodeVersion());
-      List list = (List) rulesCollection.get("rule");
-      assertEquals(3, list.size());
-      if (!"<5".equals(((Map) list.get(0)).get("cores"))) {
-        if (i < 19) {
-          Thread.sleep(100);
-          continue;
-        }
-
-      }
-      assertEquals("<5", ((Map) list.get(0)).get("cores"));
-      assertEquals("1", ((Map) list.get(1)).get("replica"));
-      assertEquals(">"+minGB2, ((Map) list.get(2)).get("freedisk"));
-      assertEquals("true", String.valueOf(rulesCollection.getProperties().get("autoAddReplicas")));
-      list = (List) rulesCollection.get("snitch");
-      assertEquals(1, list.size());
-      assertEquals("ImplicitSnitch", ((Map) list.get(0)).get("class"));
-    }
+    DocCollection rulesCollection = ZkStateReader.getCollectionLive(cloudClient.getZkStateReader(), rulesColl);
+    log.info("version_of_coll {}  ", rulesCollection.getZNodeVersion());
+    List list = (List) rulesCollection.get("rule");
+    assertEquals(3, list.size());
+    assertEquals("<5", ((Map) list.get(0)).get("cores"));
+    assertEquals("1", ((Map) list.get(1)).get("replica"));
+    assertEquals(">"+minGB2, ((Map) list.get(2)).get("freedisk"));
+    assertEquals("true", String.valueOf(rulesCollection.getProperties().get("autoAddReplicas")));
+    list = (List) rulesCollection.get("snitch");
+    assertEquals(1, list.size());
+    assertEquals("ImplicitSnitch", ((Map) list.get(0)).get("class"));
   }
 }