mirror of https://github.com/apache/lucene.git
SOLR-7132: The Collections API ADDREPLICA command property.name is not reflected in the clusterstate until after Solr restarts
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1690190 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eff521bcd7
commit
63da283f04
|
@ -218,6 +218,9 @@ Bug Fixes
|
|||
* SOLR-7143: MoreLikeThis Query parser should handle multiple field names
|
||||
(Jens Wille, Anshum Gupta)
|
||||
|
||||
* SOLR-7132: The Collections API ADDREPLICA command property.name is not reflected
|
||||
in the clusterstate until after Solr restarts (Erick Erickson)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -2493,6 +2493,9 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
String node = message.getStr("node");
|
||||
String shard = message.getStr(SHARD_ID_PROP);
|
||||
String coreName = message.getStr(CoreAdminParams.NAME);
|
||||
if (StringUtils.isBlank(coreName)) {
|
||||
coreName = message.getStr(CoreAdminParams.PROPERTY_PREFIX + CoreAdminParams.NAME);
|
||||
}
|
||||
|
||||
final String asyncId = message.getStr(ASYNC);
|
||||
|
||||
|
@ -2507,7 +2510,6 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
ShardHandler shardHandler = shardHandlerFactory.getShardHandler();
|
||||
|
||||
if (node == null) {
|
||||
|
||||
node = getNodesForNewShard(clusterState, collection, shard, 1, null,
|
||||
overseer.getZkController().getCoreContainer()).get(0).nodeName;
|
||||
log.info("Node not provided, Identified {} for creating new replica", node);
|
||||
|
|
|
@ -475,18 +475,18 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
|
|||
if (secondConfigSet) {
|
||||
createCmd.setCollectionConfigName("conf1");
|
||||
}
|
||||
|
||||
|
||||
makeRequest(getBaseUrl((HttpSolrClient) clients.get(1)), createCmd);
|
||||
|
||||
// try and create a SolrCore with no collection name
|
||||
createCmd.setCollection(null);
|
||||
createCmd.setCoreName("corewithnocollection2");
|
||||
|
||||
|
||||
makeRequest(getBaseUrl((HttpSolrClient) clients.get(1)), createCmd);
|
||||
|
||||
// in both cases, the collection should have default to the core name
|
||||
cloudClient.getZkStateReader().updateClusterState(true);
|
||||
assertTrue( cloudClient.getZkStateReader().getClusterState().hasCollection("corewithnocollection"));
|
||||
assertTrue(cloudClient.getZkStateReader().getClusterState().hasCollection("corewithnocollection"));
|
||||
assertTrue(cloudClient.getZkStateReader().getClusterState().hasCollection("corewithnocollection2"));
|
||||
}
|
||||
|
||||
|
@ -1098,45 +1098,22 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
|
|||
String newReplicaName = Assign.assignNode(collectionName, client.getZkStateReader().getClusterState());
|
||||
ArrayList<String> nodeList = new ArrayList<>(client.getZkStateReader().getClusterState().getLiveNodes());
|
||||
Collections.shuffle(nodeList, random());
|
||||
CollectionAdminRequest.AddReplica addReplica = new CollectionAdminRequest.AddReplica();
|
||||
addReplica.setCollectionName(collectionName);
|
||||
addReplica.setShardName("shard1");
|
||||
addReplica.setNode(nodeList.get(0));
|
||||
client.request(addReplica);
|
||||
|
||||
long timeout = System.currentTimeMillis() + 3000;
|
||||
Replica newReplica = null;
|
||||
|
||||
for (; System.currentTimeMillis() < timeout; ) {
|
||||
Slice slice = client.getZkStateReader().getClusterState().getSlice(collectionName, "shard1");
|
||||
newReplica = slice.getReplica(newReplicaName);
|
||||
}
|
||||
|
||||
assertNotNull(newReplica);
|
||||
Replica newReplica = doAddReplica(collectionName, "shard1",
|
||||
Assign.assignNode(collectionName, client.getZkStateReader().getClusterState()),
|
||||
nodeList.get(0), client, null);
|
||||
|
||||
log.info("newReplica {},\n{} ", newReplica, client.getZkStateReader().getBaseUrlForNodeName(nodeList.get(0)));
|
||||
|
||||
assertEquals("Replica should be created on the right node",
|
||||
client.getZkStateReader().getBaseUrlForNodeName(nodeList.get(0)), newReplica.getStr(ZkStateReader.BASE_URL_PROP));
|
||||
|
||||
newReplicaName = Assign.assignNode(collectionName, client.getZkStateReader().getClusterState());
|
||||
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;
|
||||
newReplica = null;
|
||||
|
||||
for (; System.currentTimeMillis() < timeout; ) {
|
||||
Slice slice = client.getZkStateReader().getClusterState().getSlice(collectionName, "shard2");
|
||||
newReplica = slice.getReplica(newReplicaName);
|
||||
}
|
||||
|
||||
newReplica = doAddReplica(collectionName, "shard2",
|
||||
Assign.assignNode(collectionName, client.getZkStateReader().getClusterState()),
|
||||
null, client, props);
|
||||
assertNotNull(newReplica);
|
||||
|
||||
HttpSolrClient coreclient = new HttpSolrClient(newReplica.getStr(ZkStateReader.BASE_URL_PROP));
|
||||
|
@ -1160,9 +1137,44 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
|
|||
} catch (SolrException e) {
|
||||
assertTrue(e.getMessage().contains("Another replica with the same core name already exists for this collection"));
|
||||
}
|
||||
|
||||
|
||||
// Check that specifying property.name works. DO NOT remove this when the "name" property is deprecated
|
||||
// for ADDREPLICA, this is "property.name". See SOLR-7132
|
||||
props = new Properties();
|
||||
props.put(CoreAdminParams.NAME, "propertyDotName");
|
||||
|
||||
newReplica = doAddReplica(collectionName, "shard1",
|
||||
Assign.assignNode(collectionName, client.getZkStateReader().getClusterState()),
|
||||
nodeList.get(0), client, props);
|
||||
assertEquals("'core' should be 'propertyDotName' ", "propertyDotName", newReplica.getStr("core"));
|
||||
}
|
||||
}
|
||||
|
||||
private Replica doAddReplica(String collectionName, String shard, String newReplicaName, String node,
|
||||
CloudSolrClient client, Properties props) throws IOException, SolrServerException {
|
||||
CollectionAdminRequest.AddReplica addReplica = new CollectionAdminRequest.AddReplica();
|
||||
|
||||
addReplica.setCollectionName(collectionName);
|
||||
addReplica.setShardName(shard);
|
||||
if (node != null) {
|
||||
addReplica.setNode(node);
|
||||
}
|
||||
if (props != null) {
|
||||
addReplica.setProperties(props);
|
||||
}
|
||||
client.request(addReplica);
|
||||
long timeout = System.currentTimeMillis() + 3000;
|
||||
Replica newReplica = null;
|
||||
|
||||
for (; System.currentTimeMillis() < timeout; ) {
|
||||
Slice slice = client.getZkStateReader().getClusterState().getSlice(collectionName, shard);
|
||||
newReplica = slice.getReplica(newReplicaName);
|
||||
}
|
||||
|
||||
assertNotNull(newReplica);
|
||||
return newReplica;
|
||||
}
|
||||
@Override
|
||||
protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException, IOException {
|
||||
|
||||
|
|
Loading…
Reference in New Issue