mirror of
https://github.com/apache/lucene.git
synced 2025-02-22 18:27:21 +00:00
SOLR-6111: The 'deleteshard' collection API should be able to delete a shard in 'construction' state
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1597077 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5810ff2d0e
commit
7954c8584d
@ -134,6 +134,9 @@ Bug Fixes
|
||||
* SOLR-6101: Shard splitting doesn't work when legacyCloud=false is set in
|
||||
cluster properties. (shalin)
|
||||
|
||||
* SOLR-6111: The 'deleteshard' collection API should be able to delete a shard
|
||||
in 'construction' state. (shalin)
|
||||
|
||||
Other Changes
|
||||
---------------------
|
||||
|
||||
|
@ -1686,10 +1686,11 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
|
||||
}
|
||||
// For now, only allow for deletions of Inactive slices or custom hashes (range==null).
|
||||
// TODO: Add check for range gaps on Slice deletion
|
||||
if (!(slice.getRange() == null || slice.getState().equals(Slice.INACTIVE) || slice.getState().equals(Slice.RECOVERY))) {
|
||||
if (!(slice.getRange() == null || slice.getState().equals(Slice.INACTIVE)
|
||||
|| slice.getState().equals(Slice.RECOVERY) || slice.getState().equals(Slice.CONSTRUCTION))) {
|
||||
throw new SolrException(ErrorCode.BAD_REQUEST,
|
||||
"The slice: " + slice.getName() + " is currently "
|
||||
+ slice.getState() + ". Only INACTIVE (or custom-hashed) slices can be deleted.");
|
||||
+ slice.getState() + ". Only non-active (or custom-hashed) slices can be deleted.");
|
||||
}
|
||||
ShardHandler shardHandler = shardHandlerFactory.getShardHandler();
|
||||
|
||||
|
@ -28,7 +28,6 @@ import org.apache.solr.common.cloud.ZkNodeProps;
|
||||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.common.params.CollectionParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.handler.admin.CollectionsHandler;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@ -91,7 +90,14 @@ public class DeleteShardTest extends AbstractFullDistribZkTestBase {
|
||||
assertEquals("Shard1 is not active", Slice.ACTIVE, slice1.getState());
|
||||
assertEquals("Shard2 is not active", Slice.ACTIVE, slice2.getState());
|
||||
|
||||
setSliceAsInactive(SHARD1);
|
||||
try {
|
||||
deleteShard(SHARD1);
|
||||
fail("Deleting an active shard should not have succeeded");
|
||||
} catch (HttpSolrServer.RemoteSolrException e) {
|
||||
// expected
|
||||
}
|
||||
|
||||
setSliceState(SHARD1, Slice.INACTIVE);
|
||||
|
||||
clusterState = cloudClient.getZkStateReader().getClusterState();
|
||||
|
||||
@ -102,6 +108,10 @@ public class DeleteShardTest extends AbstractFullDistribZkTestBase {
|
||||
deleteShard(SHARD1);
|
||||
|
||||
confirmShardDeletion(SHARD1);
|
||||
|
||||
setSliceState(SHARD2, Slice.CONSTRUCTION);
|
||||
deleteShard(SHARD2);
|
||||
confirmShardDeletion(SHARD2);
|
||||
}
|
||||
|
||||
protected void confirmShardDeletion(String shard) throws SolrServerException, KeeperException,
|
||||
@ -143,12 +153,12 @@ public class DeleteShardTest extends AbstractFullDistribZkTestBase {
|
||||
baseServer.shutdown();
|
||||
}
|
||||
|
||||
protected void setSliceAsInactive(String slice) throws SolrServerException, IOException,
|
||||
protected void setSliceState(String slice, String state) throws SolrServerException, IOException,
|
||||
KeeperException, InterruptedException {
|
||||
DistributedQueue inQueue = Overseer.getInQueue(cloudClient.getZkStateReader().getZkClient());
|
||||
Map<String, Object> propMap = new HashMap<>();
|
||||
propMap.put(Overseer.QUEUE_OPERATION, "updateshardstate");
|
||||
propMap.put(slice, Slice.INACTIVE);
|
||||
propMap.put(slice, state);
|
||||
propMap.put(ZkStateReader.COLLECTION_PROP, "collection1");
|
||||
ZkNodeProps m = new ZkNodeProps(propMap);
|
||||
ZkStateReader zkStateReader = cloudClient.getZkStateReader();
|
||||
@ -159,7 +169,7 @@ public class DeleteShardTest extends AbstractFullDistribZkTestBase {
|
||||
zkStateReader.updateClusterState(true);
|
||||
ClusterState clusterState = zkStateReader.getClusterState();
|
||||
String sliceState = clusterState.getSlice("collection1", slice).getState();
|
||||
if (sliceState.equals(Slice.INACTIVE)) {
|
||||
if (sliceState.equals(state)) {
|
||||
transition = true;
|
||||
break;
|
||||
}
|
||||
@ -167,7 +177,7 @@ public class DeleteShardTest extends AbstractFullDistribZkTestBase {
|
||||
}
|
||||
|
||||
if (!transition) {
|
||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Could not set shard [" + slice + "] as INACTIVE");
|
||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Could not set shard [" + slice + "] as " + state);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user