mirror of https://github.com/apache/lucene.git
SOLR-6482: Add an onlyIfDown flag for DELETEREPLICA collections API command
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1624930 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0dcd2f3e65
commit
e381b67e93
|
@ -151,6 +151,9 @@ New Features
|
|||
|
||||
* SOLR-5810 : Support for SOLR-5473 in solr admin UI (Timothy Potter, Noble Paul)
|
||||
|
||||
* SOLR-6482: Add an onlyIfDown flag for DELETEREPLICA collections API command
|
||||
(Erick Erickson)
|
||||
|
||||
Bug Fixes
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ import static org.apache.solr.cloud.Assign.getNodesForNewShard;
|
|||
import static org.apache.solr.common.cloud.ZkStateReader.COLLECTION_PROP;
|
||||
import static org.apache.solr.common.cloud.ZkStateReader.REPLICA_PROP;
|
||||
import static org.apache.solr.common.cloud.ZkStateReader.SHARD_ID_PROP;
|
||||
import static org.apache.solr.common.cloud.ZkStateReader.ONLY_IF_DOWN;
|
||||
|
||||
import static org.apache.solr.common.params.CollectionParams.CollectionAction.ADDREPLICA;
|
||||
import static org.apache.solr.common.params.CollectionParams.CollectionAction.ADDROLE;
|
||||
import static org.apache.solr.common.params.CollectionParams.CollectionAction.CLUSTERSTATUS;
|
||||
|
@ -881,6 +883,15 @@ public class OverseerCollectionProcessor implements Runnable, Closeable {
|
|||
+ shard + "/"+ collectionName + " available replicas are "+ StrUtils.join(l,','));
|
||||
}
|
||||
|
||||
// If users are being safe and only want to remove a shard if it is down, they can specify onlyIfDown=true
|
||||
// on the command.
|
||||
if (Boolean.parseBoolean(message.getStr(ONLY_IF_DOWN)) &&
|
||||
ZkStateReader.DOWN.equals(replica.getStr(ZkStateReader.STATE_PROP)) == false) {
|
||||
throw new SolrException(ErrorCode.BAD_REQUEST, "Attempted to remove replica : " + collectionName + "/" +
|
||||
shard+"/" + replicaName +
|
||||
" with onlyIfDown='true', but state is '" + replica.getStr(ZkStateReader.STATE_PROP) + "'");
|
||||
}
|
||||
|
||||
String baseUrl = replica.getStr(ZkStateReader.BASE_URL_PROP);
|
||||
String core = replica.getStr(ZkStateReader.CORE_NAME_PROP);
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import static org.apache.solr.cloud.OverseerCollectionProcessor.ROUTER;
|
|||
import static org.apache.solr.cloud.OverseerCollectionProcessor.SHARDS_PROP;
|
||||
import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;
|
||||
import static org.apache.solr.common.cloud.ZkStateReader.COLLECTION_PROP;
|
||||
import static org.apache.solr.common.cloud.ZkStateReader.ONLY_IF_DOWN;
|
||||
import static org.apache.solr.common.cloud.ZkStateReader.SHARD_ID_PROP;
|
||||
import static org.apache.solr.common.params.CollectionParams.CollectionAction.ADDROLE;
|
||||
import static org.apache.solr.common.params.CollectionParams.CollectionAction.CLUSTERPROP;
|
||||
|
@ -493,7 +494,7 @@ public class CollectionsHandler extends RequestHandlerBase {
|
|||
log.info("Remove replica: " + req.getParamString());
|
||||
req.getParams().required().check(COLLECTION_PROP, SHARD_ID_PROP, "replica");
|
||||
Map<String, Object> map = makeMap(QUEUE_OPERATION, DELETEREPLICA);
|
||||
copyIfNotNull(req.getParams(),map,COLLECTION_PROP,SHARD_ID_PROP,"replica", ASYNC);
|
||||
copyIfNotNull(req.getParams(),map,COLLECTION_PROP,SHARD_ID_PROP,"replica", ASYNC, ONLY_IF_DOWN);
|
||||
ZkNodeProps m = new ZkNodeProps(map);
|
||||
handleResponse(DELETEREPLICA, m, rsp);
|
||||
}
|
||||
|
|
|
@ -102,6 +102,8 @@ public class ZkStateReader implements Closeable {
|
|||
public static final String LEADER_ELECT_ZKNODE = "/leader_elect";
|
||||
|
||||
public static final String SHARD_LEADERS_ZKNODE = "leaders";
|
||||
public static final String ONLY_IF_DOWN = "onlyIfDown";
|
||||
|
||||
private final Set<String> watchedCollections = new HashSet<String>();
|
||||
|
||||
/**These are collections which are actively watched by this instance .
|
||||
|
|
Loading…
Reference in New Issue