You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/10/28 16:46:39 UTC

[lucene-solr] branch reference_impl_dev updated: @1053 Polish last commit.

This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/reference_impl_dev by this push:
     new 3f40438  @1053 Polish last commit.
3f40438 is described below

commit 3f40438196340f987ea976d57f48599557c083e2
Author: markrmiller <ma...@gmail.com>
AuthorDate: Wed Oct 28 11:41:16 2020 -0500

    @1053 Polish last commit.
---
 solr/core/src/java/org/apache/solr/cloud/ZkController.java |  2 +-
 .../java/org/apache/solr/schema/ManagedIndexSchema.java    | 14 ++++++++------
 .../apache/solr/cloud/NestedShardedAtomicUpdateTest.java   |  1 +
 .../src/test/org/apache/solr/cloud/ShardRoutingTest.java   |  5 ++---
 .../solr/cloud/api/collections/SplitByPrefixTest.java      |  2 +-
 5 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
index b9a88b4..89c0aae 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java
@@ -1035,7 +1035,7 @@ public class ZkController implements Closeable, Runnable {
         DistributedLock lock = new DistributedLock(zkClient, "/cluster/cluster_lock", zkClient.getZkACLProvider().getACLsToAdd("/cluster/cluster_lock"));
         if (log.isDebugEnabled()) log.debug("get cluster lock");
         while (!lock.lock()) {
-          Thread.sleep(250);
+          Thread.sleep(50);
         }
         try {
 
diff --git a/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java b/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java
index da3a47c..e22525a 100644
--- a/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/ManagedIndexSchema.java
@@ -96,7 +96,7 @@ public final class ManagedIndexSchema extends IndexSchema {
   public static final DynamicField[] EMPTY_DYNAMIC_FIELDS = {};
   public static final DynamicCopy[] EMPTY_DYNAMIC_COPY_FIELDS = {};
   private final boolean isMutable;
-  private String collection;
+  private final String collection;
 
   @Override public boolean isMutable() { return isMutable; }
 
@@ -194,7 +194,7 @@ public final class ManagedIndexSchema extends IndexSchema {
       if (log.isDebugEnabled()) log.debug("get cluster lock");
       try {
         while (!lock.lock()) {
-          Thread.sleep(250);
+          Thread.sleep(50);
         }
       } catch (KeeperException e) {
         throw new SolrException(ErrorCode.SERVER_ERROR, e);
@@ -404,7 +404,6 @@ public final class ManagedIndexSchema extends IndexSchema {
               }
               // rather than waiting and re-polling, let's be proactive and tell the replica
               // to refresh its schema from ZooKeeper, if that fails, then the
-              Thread.sleep(500); // slight delay before requesting version again
               log.info("Replica {} returned schema version {} and has not applied schema version {}"
                   , coreUrl, remoteVersion, expectedZkVersion);
             }
@@ -467,6 +466,8 @@ public final class ManagedIndexSchema extends IndexSchema {
       newSchema.requiredFields.addAll(requiredFields);
       newSchema.fieldsWithDefaultValue = ConcurrentHashMap.newKeySet(fieldsWithDefaultValue.size());
       newSchema.fieldsWithDefaultValue.addAll(fieldsWithDefaultValue);
+      newSchema.fieldTypes = new ConcurrentHashMap<>(fieldTypes.size());
+      newSchema.fieldTypes.putAll(fieldTypes);
 
       Map<String,Collection<String>> finalCopyFieldNames = copyFieldNames;
       newFields.forEach(newField -> {
@@ -1434,13 +1435,14 @@ public final class ManagedIndexSchema extends IndexSchema {
     }
   }
   
-  private ManagedIndexSchema(Version luceneVersion, SolrResourceLoader loader, boolean isMutable,
+  private ManagedIndexSchema(String collection, Version luceneVersion, SolrResourceLoader loader, boolean isMutable,
                              String managedSchemaResourceName, int schemaZkVersion, ReentrantLock schemaUpdateLock, Properties substitutableProps) {
     super(luceneVersion, loader, substitutableProps);
     this.isMutable = isMutable;
     this.managedSchemaResourceName = managedSchemaResourceName;
     this.schemaZkVersion = schemaZkVersion;
     this.schemaUpdateLock = schemaUpdateLock;
+    this.collection = collection;
   }
 
   /**
@@ -1454,7 +1456,7 @@ public final class ManagedIndexSchema extends IndexSchema {
    */
    ManagedIndexSchema shallowCopy(boolean includeFieldDataStructures) {
      ManagedIndexSchema newSchema = new ManagedIndexSchema
-         (luceneVersion, loader, isMutable, managedSchemaResourceName, schemaZkVersion, getSchemaUpdateLock(), substitutableProperties);
+         (collection, luceneVersion, loader, isMutable, managedSchemaResourceName, schemaZkVersion, getSchemaUpdateLock(), substitutableProperties);
 
     newSchema.name = name;
     newSchema.version = version;
@@ -1473,10 +1475,10 @@ public final class ManagedIndexSchema extends IndexSchema {
       newSchema.fields.putAll(fields);
       newSchema.fieldsWithDefaultValue.addAll(fieldsWithDefaultValue);
       newSchema.requiredFields.addAll(requiredFields);
+      newSchema.fieldTypes = fieldTypes;
     }
 
     // These don't need new collections - addFields() won't add members to them
-    newSchema.fieldTypes = fieldTypes;
     newSchema.dynamicFields = dynamicFields;
     newSchema.dynamicCopyFields = dynamicCopyFields;
     newSchema.copyFieldsMap = copyFieldsMap;
diff --git a/solr/core/src/test/org/apache/solr/cloud/NestedShardedAtomicUpdateTest.java b/solr/core/src/test/org/apache/solr/cloud/NestedShardedAtomicUpdateTest.java
index c50f0af..ba90453 100644
--- a/solr/core/src/test/org/apache/solr/cloud/NestedShardedAtomicUpdateTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/NestedShardedAtomicUpdateTest.java
@@ -59,6 +59,7 @@ public class NestedShardedAtomicUpdateTest extends SolrCloudBridgeTestCase {
   }
 
   public void doRootShardRoutingTest() throws Exception {
+    cloudClient.getZkStateReader().forciblyRefreshAllClusterStateSlow();
     assertEquals(4, cloudClient.getZkStateReader().getClusterState().getCollection(DEFAULT_COLLECTION).getSlices().size());
     final String[] ids = {"3", "4", "5", "6"};
 
diff --git a/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java b/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java
index 431c5d6..ff7584e 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ShardRoutingTest.java
@@ -23,13 +23,11 @@ import org.apache.solr.client.solrj.request.UpdateRequest;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.params.ShardParams;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.lang.invoke.MethodHandles;
-import java.util.List;
 import java.util.Map;
 
 public class ShardRoutingTest extends SolrCloudBridgeTestCase {
@@ -50,6 +48,7 @@ public class ShardRoutingTest extends SolrCloudBridgeTestCase {
 
   public ShardRoutingTest() throws Exception {
     super.sliceCount = 4;
+    numJettys = 8;
     handle.clear();
     handle.put("timestamp", SKIPVAL);
 
@@ -279,7 +278,7 @@ public class ShardRoutingTest extends SolrCloudBridgeTestCase {
   public void doAtomicUpdate() throws Exception {
     log.info("### STARTING doAtomicUpdate");
     int nClients = clients.size();
-    assertEquals(3, nClients);
+    assertEquals(8, nClients);
 
     int expectedVal = 0;
     for (SolrClient client : clients) {
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/SplitByPrefixTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/SplitByPrefixTest.java
index d4e7b13..f16336a 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/SplitByPrefixTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/SplitByPrefixTest.java
@@ -269,7 +269,7 @@ public class SplitByPrefixTest extends SolrCloudTestCase {
       splitShard.setAsyncId("SPLIT5");
     }
     splitShard.process(client);
-    cluster.waitForActiveCollection(COLLECTION_NAME, 5, 6);
+    cluster.waitForActiveCollection(COLLECTION_NAME, 6, 6);
 
     collection = client.getZkStateReader().getClusterState().getCollection(COLLECTION_NAME);
     slices1 = collection.getRouter().getSearchSlicesSingle(uniquePrefixes.get(0).key, null, collection);