SOLR-5208: Support for the setting of core.properties key/values at create-time on Collections API

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1543969 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erick Erickson 2013-11-20 22:15:17 +00:00
parent 51a45c9f4d
commit 4dc4d39cb9
3 changed files with 31 additions and 2 deletions

View File

@ -91,6 +91,9 @@ New Features
* SOLR-5456: Admin UI - Allow creating new Files (steffkes)
* SOLR-5208: Support for the setting of core.properties key/values at create-time on
Collections API (Erick Erickson)
Bug Fixes
----------------------

View File

@ -111,6 +111,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
public static final String COLL_CONF = "collection.configName";
public static final String COLL_PROP_PREFIX = "property.";
public static final Map<String,Object> COLL_PROPS = ZkNodeProps.makeMap(
ROUTER, DocRouter.DEFAULT_NAME,
@ -545,6 +546,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
params.set(CoreAdminParams.COLLECTION, collectionName);
params.set(CoreAdminParams.SHARD, sliceName);
params.set(ZkStateReader.NUM_SHARDS_PROP, numSlices);
addPropertyParams(message, params);
ShardRequest sreq = new ShardRequest();
params.set("qt", adminPath);
@ -739,7 +741,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
params.set(CoreAdminParams.SHARD_RANGE, subRange.toString());
params.set(CoreAdminParams.SHARD_STATE, Slice.CONSTRUCTION);
params.set(CoreAdminParams.SHARD_PARENT, parentSlice.getName());
addPropertyParams(message, params);
sendShardRequest(nodeName, params);
}
@ -849,6 +851,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
params.set(CoreAdminParams.NAME, shardName);
params.set(CoreAdminParams.COLLECTION, collectionName);
params.set(CoreAdminParams.SHARD, sliceName);
addPropertyParams(message, params);
// TODO: Figure the config used by the parent shard and use it.
//params.set("collection.configName", configName);
@ -1287,6 +1290,14 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
shardHandler.submit(sreq, replica, sreq.params);
}
private void addPropertyParams(ZkNodeProps message, ModifiableSolrParams params) {
// Now add the property.key=value pairs
for (String key : message.keySet()) {
if (key.indexOf(COLL_PROP_PREFIX) != -1) {
params.set(key, message.getStr(key));
}
}
}
private void createCollection(ClusterState clusterState, ZkNodeProps message, NamedList results) throws KeeperException, InterruptedException {
String collectionName = message.getStr("name");
if (clusterState.getCollections().contains(collectionName)) {
@ -1401,6 +1412,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
params.set(CoreAdminParams.COLLECTION, collectionName);
params.set(CoreAdminParams.SHARD, sliceName);
params.set(ZkStateReader.NUM_SHARDS_PROP, numSlices);
addPropertyParams(message, params);
ShardRequest sreq = new ShardRequest();
params.set("qt", adminPath);

View File

@ -318,6 +318,7 @@ public class CollectionsHandler extends RequestHandlerBase {
SHARDS_PROP,
"router.");
copyPropertiesIfNotNull(req.getParams(), props);
ZkNodeProps m = new ZkNodeProps(props);
handleResponse(OverseerCollectionProcessor.CREATECOLLECTION, m, rsp);
@ -342,6 +343,7 @@ public class CollectionsHandler extends RequestHandlerBase {
Map<String, Object> map = makeMap(QUEUE_OPERATION, CREATESHARD);
copyIfNotNull(req.getParams(),map,COLLECTION_PROP, SHARD_ID_PROP, REPLICATION_FACTOR,CREATE_NODE_SET);
copyPropertiesIfNotNull(req.getParams(), map);
ZkNodeProps m = new ZkNodeProps(map);
handleResponse(CREATESHARD, m, rsp);
}
@ -372,7 +374,18 @@ public class CollectionsHandler extends RequestHandlerBase {
}
}
private void copyPropertiesIfNotNull(SolrParams params, Map<String, Object> props) {
Iterator<String> iter = params.getParameterNamesIterator();
while (iter.hasNext()) {
String param = iter.next();
if (param.indexOf(OverseerCollectionProcessor.COLL_PROP_PREFIX) != -1) {
props.put(param, params.get(param));
}
}
}
private void handleDeleteShardAction(SolrQueryRequest req,
SolrQueryResponse rsp) throws InterruptedException, KeeperException {
log.info("Deleting Shard : " + req.getParamString());
@ -420,6 +433,7 @@ public class CollectionsHandler extends RequestHandlerBase {
if (rangesStr != null) {
props.put(CoreAdminParams.RANGES, rangesStr);
}
copyPropertiesIfNotNull(req.getParams(), props);
ZkNodeProps m = new ZkNodeProps(props);