mirror of https://github.com/apache/lucene.git
SOLR-7499: Deprecate the 'name' parameter from the ADDREPLICA Collection API call
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1686827 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c0fd50b2ed
commit
f7dd8e3805
|
@ -100,6 +100,9 @@ Upgrading from Solr 5.2
|
|||
|
||||
* class TransformerWithContext is deprecated . Use DocTransformer directly
|
||||
|
||||
* The "name" parameter in ADDREPLICA Collections API call has be deprecated. One cannot specify
|
||||
the core name for a replica. See SOLR-7499 for more info.
|
||||
|
||||
Detailed Change List
|
||||
----------------------
|
||||
|
||||
|
@ -232,6 +235,9 @@ Other Changes
|
|||
* SOLR-7629: Have RulesTest consider disk space limitations of where the test is
|
||||
being run (Christine Poerschke via Ramkumar Aiyengar)
|
||||
|
||||
* The "name" parameter in ADDREPLICA Collections API call has be deprecated. One cannot specify
|
||||
the core name for a replica. See SOLR-7499 for more info. (Varun Thacker, noble, Erick Erickson)
|
||||
|
||||
================== 5.2.1 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release
|
||||
|
|
|
@ -2520,7 +2520,7 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
String replicaName = collection + "_" + shard + "_replica" + replicaNum;
|
||||
boolean exists = false;
|
||||
for (Replica replica : slice.getReplicas()) {
|
||||
if (replicaName.equals(replica.getStr("core"))) {
|
||||
if (replicaName.equals(replica.getStr(CORE_NAME_PROP))) {
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
|
@ -2529,6 +2529,17 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
else break;
|
||||
}
|
||||
coreName = collection + "_" + shard + "_replica" + replicaNum;
|
||||
} else {
|
||||
//Validate that the core name is unique in that collection
|
||||
for (Slice slice : coll.getSlices()) {
|
||||
for (Replica replica : slice.getReplicas()) {
|
||||
String replicaCoreName = replica.getStr(CORE_NAME_PROP);
|
||||
if (coreName.equals(replicaCoreName)) {
|
||||
throw new SolrException(ErrorCode.BAD_REQUEST, "Another replica with the same core name already exists" +
|
||||
" for this collection");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ import org.junit.Test;
|
|||
|
||||
import static org.apache.solr.cloud.OverseerCollectionProcessor.NUM_SLICES;
|
||||
import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
|
||||
import static org.apache.solr.common.cloud.ZkStateReader.CORE_NAME_PROP;
|
||||
import static org.apache.solr.common.cloud.ZkStateReader.MAX_SHARDS_PER_NODE;
|
||||
import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
|
||||
|
||||
|
@ -1143,8 +1144,23 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
|
|||
NamedList<Object> coreStatus = status.getCoreStatus(newReplica.getStr("core"));
|
||||
String instanceDirStr = (String) coreStatus.get("instanceDir");
|
||||
assertEquals(Paths.get(instanceDirStr).toString(), instancePathStr);
|
||||
}
|
||||
|
||||
//Test to make sure we can't create another replica with an existing core_name of that collection
|
||||
String coreName = newReplica.getStr(CORE_NAME_PROP);
|
||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
params.set("action", "addreplica");
|
||||
params.set("collection", collectionName);
|
||||
params.set("shard", "shard1");
|
||||
params.set("name", coreName);
|
||||
QueryRequest request = new QueryRequest(params);
|
||||
request.setPath("/admin/collections");
|
||||
try {
|
||||
client.request(request);
|
||||
fail("AddReplica call should not have been successful");
|
||||
} catch (SolrException e) {
|
||||
assertTrue(e.getMessage().contains("Another replica with the same core name already exists for this collection"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue