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
|
* SOLR-7143: MoreLikeThis Query parser should handle multiple field names
|
||||||
(Jens Wille, Anshum Gupta)
|
(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
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -2493,6 +2493,9 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
||||||
String node = message.getStr("node");
|
String node = message.getStr("node");
|
||||||
String shard = message.getStr(SHARD_ID_PROP);
|
String shard = message.getStr(SHARD_ID_PROP);
|
||||||
String coreName = message.getStr(CoreAdminParams.NAME);
|
String coreName = message.getStr(CoreAdminParams.NAME);
|
||||||
|
if (StringUtils.isBlank(coreName)) {
|
||||||
|
coreName = message.getStr(CoreAdminParams.PROPERTY_PREFIX + CoreAdminParams.NAME);
|
||||||
|
}
|
||||||
|
|
||||||
final String asyncId = message.getStr(ASYNC);
|
final String asyncId = message.getStr(ASYNC);
|
||||||
|
|
||||||
|
@ -2507,7 +2510,6 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
||||||
ShardHandler shardHandler = shardHandlerFactory.getShardHandler();
|
ShardHandler shardHandler = shardHandlerFactory.getShardHandler();
|
||||||
|
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
|
|
||||||
node = getNodesForNewShard(clusterState, collection, shard, 1, null,
|
node = getNodesForNewShard(clusterState, collection, shard, 1, null,
|
||||||
overseer.getZkController().getCoreContainer()).get(0).nodeName;
|
overseer.getZkController().getCoreContainer()).get(0).nodeName;
|
||||||
log.info("Node not provided, Identified {} for creating new replica", node);
|
log.info("Node not provided, Identified {} for creating new replica", node);
|
||||||
|
|
|
@ -486,7 +486,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
|
||||||
|
|
||||||
// in both cases, the collection should have default to the core name
|
// in both cases, the collection should have default to the core name
|
||||||
cloudClient.getZkStateReader().updateClusterState(true);
|
cloudClient.getZkStateReader().updateClusterState(true);
|
||||||
assertTrue( cloudClient.getZkStateReader().getClusterState().hasCollection("corewithnocollection"));
|
assertTrue(cloudClient.getZkStateReader().getClusterState().hasCollection("corewithnocollection"));
|
||||||
assertTrue(cloudClient.getZkStateReader().getClusterState().hasCollection("corewithnocollection2"));
|
assertTrue(cloudClient.getZkStateReader().getClusterState().hasCollection("corewithnocollection2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1098,45 +1098,22 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
|
||||||
String newReplicaName = Assign.assignNode(collectionName, client.getZkStateReader().getClusterState());
|
String newReplicaName = Assign.assignNode(collectionName, client.getZkStateReader().getClusterState());
|
||||||
ArrayList<String> nodeList = new ArrayList<>(client.getZkStateReader().getClusterState().getLiveNodes());
|
ArrayList<String> nodeList = new ArrayList<>(client.getZkStateReader().getClusterState().getLiveNodes());
|
||||||
Collections.shuffle(nodeList, random());
|
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 = doAddReplica(collectionName, "shard1",
|
||||||
Replica newReplica = null;
|
Assign.assignNode(collectionName, client.getZkStateReader().getClusterState()),
|
||||||
|
nodeList.get(0), client, null);
|
||||||
for (; System.currentTimeMillis() < timeout; ) {
|
|
||||||
Slice slice = client.getZkStateReader().getClusterState().getSlice(collectionName, "shard1");
|
|
||||||
newReplica = slice.getReplica(newReplicaName);
|
|
||||||
}
|
|
||||||
|
|
||||||
assertNotNull(newReplica);
|
|
||||||
|
|
||||||
log.info("newReplica {},\n{} ", newReplica, client.getZkStateReader().getBaseUrlForNodeName(nodeList.get(0)));
|
log.info("newReplica {},\n{} ", newReplica, client.getZkStateReader().getBaseUrlForNodeName(nodeList.get(0)));
|
||||||
|
|
||||||
assertEquals("Replica should be created on the right node",
|
assertEquals("Replica should be created on the right node",
|
||||||
client.getZkStateReader().getBaseUrlForNodeName(nodeList.get(0)), newReplica.getStr(ZkStateReader.BASE_URL_PROP));
|
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();
|
Properties props = new Properties();
|
||||||
String instancePathStr = createTempDir().toString();
|
String instancePathStr = createTempDir().toString();
|
||||||
props.put(CoreAdminParams.INSTANCE_DIR, instancePathStr); //Use name via the property.instanceDir method
|
props.put(CoreAdminParams.INSTANCE_DIR, instancePathStr); //Use name via the property.instanceDir method
|
||||||
addReplica.setProperties(props);
|
newReplica = doAddReplica(collectionName, "shard2",
|
||||||
client.request(addReplica);
|
Assign.assignNode(collectionName, client.getZkStateReader().getClusterState()),
|
||||||
|
null, client, props);
|
||||||
timeout = System.currentTimeMillis() + 3000;
|
|
||||||
newReplica = null;
|
|
||||||
|
|
||||||
for (; System.currentTimeMillis() < timeout; ) {
|
|
||||||
Slice slice = client.getZkStateReader().getClusterState().getSlice(collectionName, "shard2");
|
|
||||||
newReplica = slice.getReplica(newReplicaName);
|
|
||||||
}
|
|
||||||
|
|
||||||
assertNotNull(newReplica);
|
assertNotNull(newReplica);
|
||||||
|
|
||||||
HttpSolrClient coreclient = new HttpSolrClient(newReplica.getStr(ZkStateReader.BASE_URL_PROP));
|
HttpSolrClient coreclient = new HttpSolrClient(newReplica.getStr(ZkStateReader.BASE_URL_PROP));
|
||||||
|
@ -1160,9 +1137,44 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
|
||||||
} catch (SolrException e) {
|
} catch (SolrException e) {
|
||||||
assertTrue(e.getMessage().contains("Another replica with the same core name already exists for this collection"));
|
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
|
@Override
|
||||||
protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException, IOException {
|
protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException, IOException {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue