diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index e28ba9e2968..a8b4cb01a36 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -139,6 +139,9 @@ Bug Fixes operate on stale cluster state due to overseer holding the state update lock for a long time. (Mark Miller, shalin) +* SOLR-7104: Propagate property prefix parameters for ADDREPLICA Collections API call. + (Varun Thacker via Anshum Gupta) + Optimizations ---------------------- * SOLR-7049: Move work done by the LIST Collections API call to the Collections diff --git a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java index ce0c1f8d125..5ad3fe6cfcc 100644 --- a/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/admin/CollectionsHandler.java @@ -1023,6 +1023,7 @@ public class CollectionsHandler extends RequestHandlerBase { props.put(Overseer.QUEUE_OPERATION, CollectionAction.ADDREPLICA.toString()); copyIfNotNull(req.getParams(), props, COLLECTION_PROP, "node", SHARD_ID_PROP, ShardParams._ROUTE_, CoreAdminParams.NAME, CoreAdminParams.INSTANCE_DIR, CoreAdminParams.DATA_DIR, ASYNC); + copyPropertiesIfNotNull(req.getParams(), props); ZkNodeProps m = new ZkNodeProps(props); handleResponse(CollectionAction.ADDREPLICA.toString(), m, rsp); } diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java index 9b30edda3f5..db88c115eda 100644 --- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java @@ -46,6 +46,7 @@ import org.apache.solr.common.cloud.ZkCoreNodeProps; import org.apache.solr.common.cloud.ZkNodeProps; import org.apache.solr.common.cloud.ZkStateReader; import org.apache.solr.common.params.CollectionParams.CollectionAction; +import org.apache.solr.common.params.CoreAdminParams; import org.apache.solr.common.params.MapSolrParams; import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.util.NamedList; @@ -80,6 +81,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; +import java.util.Properties; import java.util.Set; import java.util.concurrent.CompletionService; import java.util.concurrent.ExecutorCompletionService; @@ -197,6 +199,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa clusterPropTest(); // last deleteCollectionWithDownNodes(); + addReplicaTest(); if (DEBUG) { super.printLayout(); @@ -1115,6 +1118,10 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa addReplica = new CollectionAdminRequest.AddReplica(); addReplica.setCollectionName(collectionName); addReplica.setShardName("shard2"); + Properties props = new Properties(); + String instancePathStr = createTempDir().toString(); + props.put(CoreAdminParams.INSTANCE_DIR, instancePathStr); //Use name via the property.instanceDir method + addReplica.setProperties(props); client.request(addReplica); timeout = System.currentTimeMillis() + 3000; @@ -1127,6 +1134,11 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa assertNotNull(newReplica); + HttpSolrClient coreclient = new HttpSolrClient(newReplica.getStr(ZkStateReader.BASE_URL_PROP)); + CoreAdminResponse status = CoreAdminRequest.getStatus(newReplica.getStr("core"), coreclient); + NamedList coreStatus = status.getCoreStatus(newReplica.getStr("core")); + String instanceDirStr = (String) coreStatus.get("instanceDir"); + assertEquals(Paths.get(instanceDirStr).toString(), instancePathStr); } }