You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by no...@apache.org on 2023/01/18 07:09:36 UTC

[solr] branch main updated: SOLR-16593 : Redundant fields are present in the replica object of state.json (#1293)

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

noble pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 13857ba4dd7 SOLR-16593 : Redundant fields are present in the replica object of state.json (#1293)
13857ba4dd7 is described below

commit 13857ba4dd7b0ff651903de45ac03c7d174e952c
Author: Noble Paul <no...@users.noreply.github.com>
AuthorDate: Wed Jan 18 18:09:30 2023 +1100

    SOLR-16593 : Redundant fields are present in the replica object of state.json (#1293)
---
 .../SimpleCollectionCreateDeleteTest.java          | 28 ++++++++++++++++++++++
 .../java/org/apache/solr/common/cloud/Replica.java |  5 ----
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/SimpleCollectionCreateDeleteTest.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/SimpleCollectionCreateDeleteTest.java
index 7e33e65c6f7..3b048851f5b 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/SimpleCollectionCreateDeleteTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/SimpleCollectionCreateDeleteTest.java
@@ -17,15 +17,20 @@
 package org.apache.solr.cloud.api.collections;
 
 import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import org.apache.solr.client.solrj.request.CollectionAdminRequest;
 import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
 import org.apache.solr.cloud.OverseerCollectionConfigSetProcessor;
+import org.apache.solr.common.cloud.ClusterState;
+import org.apache.solr.common.cloud.DocCollection;
 import org.apache.solr.common.cloud.SolrZkClient;
 import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.common.util.TimeSource;
+import org.apache.solr.common.util.Utils;
 import org.apache.solr.core.CoreDescriptor;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.embedded.JettySolrRunner;
@@ -104,6 +109,29 @@ public class SimpleCollectionCreateDeleteTest extends AbstractFullDistribZkTestB
     }
   }
 
+  @Test
+  @SuppressWarnings("unchecked")
+  public void testPropertiesOfReplica() throws Exception {
+    String collectionName = "testPropertiesOfReplica_coll";
+    CollectionAdminRequest.Create create =
+        CollectionAdminRequest.createCollection(collectionName, 2, 1);
+    NamedList<Object> request = create.process(cloudClient).getResponse();
+    assertNotNull(request.get("success"));
+    SolrZkClient.NodeData node =
+        getZkClient().getNode(DocCollection.getCollectionPath(collectionName), null, true);
+
+    DocCollection c =
+        ClusterState.createFromCollectionMap(
+                0, (Map<String, Object>) Utils.fromJSON(node.data), Collections.emptySet())
+            .getCollection(collectionName);
+
+    c.forEachReplica(
+        (s, replica) -> {
+          assertFalse(replica.getProperties().containsKey("collection"));
+          assertFalse(replica.getProperties().containsKey("shard"));
+        });
+  }
+
   @Test
   @ShardsFixed(num = 1)
   public void testDeleteAlsoDeletesAutocreatedConfigSet() throws Exception {
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java b/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java
index bf1dca1ca96..f811fd40207 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java
@@ -240,9 +240,6 @@ public class Replica extends ZkNodeProps implements MapWriter {
     Objects.requireNonNull(baseUrl, "'base_url' must not be null");
 
     // make sure all declared props are in the propMap
-    propMap.put(ReplicaStateProps.COLLECTION, collection);
-    propMap.put(ReplicaStateProps.SHARD_ID, shard);
-    propMap.put(ReplicaStateProps.CORE_NODE_NAME, name);
     propMap.put(ReplicaStateProps.NODE_NAME, node);
     propMap.put(ReplicaStateProps.CORE_NAME, core);
     propMap.put(ReplicaStateProps.TYPE, type.toString());
@@ -398,8 +395,6 @@ public class Replica extends ZkNodeProps implements MapWriter {
 
       writer
           .put(ReplicaStateProps.CORE_NAME, core, p)
-          .put(ReplicaStateProps.SHARD_ID, shard, p)
-          .put(ReplicaStateProps.COLLECTION, collection, p)
           .put(ReplicaStateProps.NODE_NAME, node, p)
           .put(ReplicaStateProps.TYPE, type.toString(), p)
           .put(ReplicaStateProps.STATE, state.toString(), p);