mirror of https://github.com/apache/lucene.git
SOLR-4075: A logical shard that has had all of it's SolrCores unloaded should be removed from the cluster state.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1411450 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
58a8e8be6b
commit
1464045268
|
@ -209,6 +209,9 @@ Bug Fixes
|
|||
|
||||
* SOLR-3959: Ensure the internal comma separator of poly fields is escaped
|
||||
for CSVResponseWriter. (Areek Zillur via Robert Muir)
|
||||
|
||||
* SOLR-4075: A logical shard that has had all of it's SolrCores unloaded should
|
||||
be removed from the cluster state. (Mark Miller, Gilles Comeau)
|
||||
|
||||
Other Changes
|
||||
----------------------
|
||||
|
|
|
@ -398,8 +398,11 @@ public class Overseer {
|
|||
if(slice.getReplicasMap().containsKey(coreNodeName)) {
|
||||
Map<String, Replica> newReplicas = slice.getReplicasCopy();
|
||||
newReplicas.remove(coreNodeName);
|
||||
Slice newSlice = new Slice(slice.getName(), newReplicas, slice.getProperties());
|
||||
newSlices.put(slice.getName(), newSlice);
|
||||
if (newReplicas.size() != 0) {
|
||||
Slice newSlice = new Slice(slice.getName(), newReplicas,
|
||||
slice.getProperties());
|
||||
newSlices.put(slice.getName(), newSlice);
|
||||
}
|
||||
} else {
|
||||
newSlices.put(slice.getName(), slice);
|
||||
}
|
||||
|
|
|
@ -343,12 +343,82 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||
testCoreUnloadAndLeaders();
|
||||
testUnloadLotsOfCores();
|
||||
testStopAndStartCoresInOneInstance();
|
||||
testUnloadShardAndCollection();
|
||||
// Thread.sleep(10000000000L);
|
||||
if (DEBUG) {
|
||||
super.printLayout();
|
||||
}
|
||||
}
|
||||
|
||||
private void testUnloadShardAndCollection() throws Exception{
|
||||
// create one leader and one replica
|
||||
|
||||
Create createCmd = new Create();
|
||||
createCmd.setCoreName("test_unload_shard_and_collection_1");
|
||||
String collection = "test_unload_shard_and_collection";
|
||||
createCmd.setCollection(collection);
|
||||
String coreDataDir = dataDir.getAbsolutePath() + File.separator
|
||||
+ System.currentTimeMillis() + collection + "1";
|
||||
createCmd.setDataDir(coreDataDir);
|
||||
createCmd.setNumShards(2);
|
||||
|
||||
SolrServer client = clients.get(0);
|
||||
String url1 = getBaseUrl(client);
|
||||
HttpSolrServer server = new HttpSolrServer(url1);
|
||||
|
||||
server.request(createCmd);
|
||||
|
||||
createCmd = new Create();
|
||||
createCmd.setCoreName("test_unload_shard_and_collection_2");
|
||||
collection = "test_unload_shard_and_collection";
|
||||
createCmd.setCollection(collection);
|
||||
coreDataDir = dataDir.getAbsolutePath() + File.separator
|
||||
+ System.currentTimeMillis() + collection + "2";
|
||||
createCmd.setDataDir(coreDataDir);
|
||||
|
||||
server.request(createCmd);
|
||||
|
||||
// now unload one of the two
|
||||
Unload unloadCmd = new Unload(false);
|
||||
unloadCmd.setCoreName("test_unload_shard_and_collection_2");
|
||||
server.request(unloadCmd);
|
||||
|
||||
// there should be only one shard
|
||||
Slice shard2 = solrj.getZkStateReader().getClusterState().getSlice(collection, "shard2");
|
||||
long timeoutAt = System.currentTimeMillis() + 30000;
|
||||
while (shard2 != null) {
|
||||
if (System.currentTimeMillis() > timeoutAt) {
|
||||
printLayout();
|
||||
fail("Still found shard");
|
||||
}
|
||||
|
||||
Thread.sleep(50);
|
||||
shard2 = solrj.getZkStateReader().getClusterState().getSlice(collection, "shard2");
|
||||
}
|
||||
|
||||
Slice shard1 = solrj.getZkStateReader().getClusterState().getSlice(collection, "shard1");
|
||||
assertNotNull(shard1);
|
||||
assertTrue(solrj.getZkStateReader().getClusterState().getCollections().contains(collection));
|
||||
|
||||
// now unload one of the other
|
||||
unloadCmd = new Unload(false);
|
||||
unloadCmd.setCoreName("test_unload_shard_and_collection_1");
|
||||
server.request(unloadCmd);
|
||||
|
||||
//printLayout();
|
||||
// the collection should be gone
|
||||
timeoutAt = System.currentTimeMillis() + 30000;
|
||||
while (solrj.getZkStateReader().getClusterState().getCollections().contains(collection)) {
|
||||
if (System.currentTimeMillis() > timeoutAt) {
|
||||
printLayout();
|
||||
fail("Still found collection");
|
||||
}
|
||||
|
||||
Thread.sleep(50);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception on any problem
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue