mirror of https://github.com/apache/lucene.git
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
|
* SOLR-6101: Shard splitting doesn't work when legacyCloud=false is set in
|
||||||
cluster properties. (shalin)
|
cluster properties. (shalin)
|
||||||
|
|
||||||
|
* SOLR-6111: The 'deleteshard' collection API should be able to delete a shard
|
||||||
|
in 'construction' state. (shalin)
|
||||||
|
|
||||||
Other Changes
|
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).
|
// For now, only allow for deletions of Inactive slices or custom hashes (range==null).
|
||||||
// TODO: Add check for range gaps on Slice deletion
|
// 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,
|
throw new SolrException(ErrorCode.BAD_REQUEST,
|
||||||
"The slice: " + slice.getName() + " is currently "
|
"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();
|
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.cloud.ZkStateReader;
|
||||||
import org.apache.solr.common.params.CollectionParams;
|
import org.apache.solr.common.params.CollectionParams;
|
||||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||||
import org.apache.solr.handler.admin.CollectionsHandler;
|
|
||||||
import org.apache.zookeeper.KeeperException;
|
import org.apache.zookeeper.KeeperException;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -91,7 +90,14 @@ public class DeleteShardTest extends AbstractFullDistribZkTestBase {
|
||||||
assertEquals("Shard1 is not active", Slice.ACTIVE, slice1.getState());
|
assertEquals("Shard1 is not active", Slice.ACTIVE, slice1.getState());
|
||||||
assertEquals("Shard2 is not active", Slice.ACTIVE, slice2.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();
|
clusterState = cloudClient.getZkStateReader().getClusterState();
|
||||||
|
|
||||||
|
@ -102,6 +108,10 @@ public class DeleteShardTest extends AbstractFullDistribZkTestBase {
|
||||||
deleteShard(SHARD1);
|
deleteShard(SHARD1);
|
||||||
|
|
||||||
confirmShardDeletion(SHARD1);
|
confirmShardDeletion(SHARD1);
|
||||||
|
|
||||||
|
setSliceState(SHARD2, Slice.CONSTRUCTION);
|
||||||
|
deleteShard(SHARD2);
|
||||||
|
confirmShardDeletion(SHARD2);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void confirmShardDeletion(String shard) throws SolrServerException, KeeperException,
|
protected void confirmShardDeletion(String shard) throws SolrServerException, KeeperException,
|
||||||
|
@ -143,12 +153,12 @@ public class DeleteShardTest extends AbstractFullDistribZkTestBase {
|
||||||
baseServer.shutdown();
|
baseServer.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setSliceAsInactive(String slice) throws SolrServerException, IOException,
|
protected void setSliceState(String slice, String state) throws SolrServerException, IOException,
|
||||||
KeeperException, InterruptedException {
|
KeeperException, InterruptedException {
|
||||||
DistributedQueue inQueue = Overseer.getInQueue(cloudClient.getZkStateReader().getZkClient());
|
DistributedQueue inQueue = Overseer.getInQueue(cloudClient.getZkStateReader().getZkClient());
|
||||||
Map<String, Object> propMap = new HashMap<>();
|
Map<String, Object> propMap = new HashMap<>();
|
||||||
propMap.put(Overseer.QUEUE_OPERATION, "updateshardstate");
|
propMap.put(Overseer.QUEUE_OPERATION, "updateshardstate");
|
||||||
propMap.put(slice, Slice.INACTIVE);
|
propMap.put(slice, state);
|
||||||
propMap.put(ZkStateReader.COLLECTION_PROP, "collection1");
|
propMap.put(ZkStateReader.COLLECTION_PROP, "collection1");
|
||||||
ZkNodeProps m = new ZkNodeProps(propMap);
|
ZkNodeProps m = new ZkNodeProps(propMap);
|
||||||
ZkStateReader zkStateReader = cloudClient.getZkStateReader();
|
ZkStateReader zkStateReader = cloudClient.getZkStateReader();
|
||||||
|
@ -159,7 +169,7 @@ public class DeleteShardTest extends AbstractFullDistribZkTestBase {
|
||||||
zkStateReader.updateClusterState(true);
|
zkStateReader.updateClusterState(true);
|
||||||
ClusterState clusterState = zkStateReader.getClusterState();
|
ClusterState clusterState = zkStateReader.getClusterState();
|
||||||
String sliceState = clusterState.getSlice("collection1", slice).getState();
|
String sliceState = clusterState.getSlice("collection1", slice).getState();
|
||||||
if (sliceState.equals(Slice.INACTIVE)) {
|
if (sliceState.equals(state)) {
|
||||||
transition = true;
|
transition = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +177,7 @@ public class DeleteShardTest extends AbstractFullDistribZkTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!transition) {
|
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…
Reference in New Issue