SOLR-11861 baseConfigSet default

This commit is contained in:
David Smiley 2018-09-04 14:02:46 -04:00
parent e0eb7bac02
commit b1b0963947
8 changed files with 41 additions and 37 deletions

View File

@ -198,6 +198,9 @@ New Features
* SOLR-12715: NodeAddedTrigger should support adding replicas to new nodes by setting preferredOperation=addreplica.
(shalin)
* SOLR-11861: When creating a configSet via the API, the "baseConfigSet" parameter now defaults to "_default".
(Amrit Sarkar, David Smiley)
Bug Fixes
----------------------

View File

@ -47,6 +47,7 @@ import org.slf4j.LoggerFactory;
import static org.apache.solr.common.params.CommonParams.NAME;
import static org.apache.solr.common.params.ConfigSetParams.ConfigSetAction.CREATE;
import static org.apache.solr.handler.admin.ConfigSetsHandlerApi.DEFAULT_CONFIGSET_NAME;
/**
* A {@link OverseerMessageHandler} that handles ConfigSets API related
@ -210,7 +211,11 @@ public class OverseerConfigSetMessageHandler implements OverseerMessageHandler {
operation = operation.substring(CONFIGSETS_ACTION_PREFIX.length());
ConfigSetParams.ConfigSetAction action = ConfigSetParams.ConfigSetAction.get(operation);
if (action == CREATE) {
return message.getStr(BASE_CONFIGSET);
String baseConfigSetName = message.getStr(BASE_CONFIGSET);
if (baseConfigSetName == null || baseConfigSetName.length() == 0) {
baseConfigSetName = DEFAULT_CONFIGSET_NAME;
}
return baseConfigSetName;
}
}
return null;
@ -283,10 +288,7 @@ public class OverseerConfigSetMessageHandler implements OverseerMessageHandler {
throw new SolrException(ErrorCode.BAD_REQUEST, "ConfigSet name not specified");
}
String baseConfigSetName = message.getStr(BASE_CONFIGSET);
if (baseConfigSetName == null || baseConfigSetName.length() == 0) {
throw new SolrException(ErrorCode.BAD_REQUEST, "Base ConfigSet name not specified");
}
String baseConfigSetName = message.getStr(BASE_CONFIGSET, DEFAULT_CONFIGSET_NAME);
ZkConfigManager configManager = new ZkConfigManager(zkStateReader.getZkClient());
if (configManager.configExists(configSetName)) {

View File

@ -66,6 +66,7 @@ import static org.apache.solr.common.params.CommonParams.NAME;
import static org.apache.solr.common.params.ConfigSetParams.ConfigSetAction.CREATE;
import static org.apache.solr.common.params.ConfigSetParams.ConfigSetAction.DELETE;
import static org.apache.solr.common.params.ConfigSetParams.ConfigSetAction.LIST;
import static org.apache.solr.handler.admin.ConfigSetsHandlerApi.DEFAULT_CONFIGSET_NAME;
/**
* A {@link org.apache.solr.request.SolrRequestHandler} for ConfigSets API requests.
@ -254,6 +255,7 @@ public class ConfigSetsHandler extends RequestHandlerBase implements PermissionN
public String getDescription() {
return "Manage SolrCloud ConfigSets";
}
@Override
public Category getCategory() {
return Category.ADMIN;
@ -263,7 +265,9 @@ public class ConfigSetsHandler extends RequestHandlerBase implements PermissionN
CREATE_OP(CREATE) {
@Override
Map<String, Object> call(SolrQueryRequest req, SolrQueryResponse rsp, ConfigSetsHandler h) throws Exception {
Map<String, Object> props = CollectionsHandler.copy(req.getParams().required(), null, NAME, BASE_CONFIGSET);
String baseConfigSetName = req.getParams().get(BASE_CONFIGSET, DEFAULT_CONFIGSET_NAME);
Map<String, Object> props = CollectionsHandler.copy(req.getParams().required(), null, NAME);
props.put(BASE_CONFIGSET, baseConfigSetName);
return copyPropertiesWithPrefix(req.getParams(), props, PROPERTY_PREFIX + ".");
}
},

View File

@ -16,11 +16,6 @@
*/
package org.apache.solr.cloud;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.solr.cloud.OverseerConfigSetMessageHandler.BASE_CONFIGSET;
import static org.apache.solr.common.params.CommonParams.NAME;
import static org.apache.solr.core.ConfigSetProperties.DEFAULT_FILENAME;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
@ -99,6 +94,10 @@ import org.noggit.ObjectBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.solr.common.params.CommonParams.NAME;
import static org.apache.solr.core.ConfigSetProperties.DEFAULT_FILENAME;
/**
* Simple ConfigSets API tests on user errors and simple success cases.
*/
@ -136,9 +135,8 @@ public class TestConfigSetsAPI extends SolrTestCaseJ4 {
CreateNoErrorChecking create = new CreateNoErrorChecking();
verifyException(solrClient, create, NAME);
// no base ConfigSet name
// set ConfigSet
create.setConfigSetName("configSetName");
verifyException(solrClient, create, BASE_CONFIGSET);
// ConfigSet already exists
Create alreadyExists = new Create();
@ -156,7 +154,7 @@ public class TestConfigSetsAPI extends SolrTestCaseJ4 {
@Test
public void testCreate() throws Exception {
// no old, no new
verifyCreate("baseConfigSet1", "configSet1", null, null);
verifyCreate(null, "configSet1", null, null);
// no old, new
verifyCreate("baseConfigSet2", "configSet2",

View File

@ -130,7 +130,7 @@ name::
The configset to be created. This parameter is required.
baseConfigSet::
The name of the configset to copy as a base. This parameter is required.
The name of the configset to copy as a base. This defaults to `_default`
configSetProp._property_=_value_::
A configset property from the base configset to override in the copied configset.

View File

@ -135,10 +135,9 @@ public abstract class ConfigSetAdminRequest
@Override
public SolrParams getParams() {
ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
if (baseConfigSetName == null) {
throw new RuntimeException( "no Base ConfigSet specified!" );
}
if (baseConfigSetName != null) {
params.set("baseConfigSet", baseConfigSetName);
}
if (properties != null) {
for (Map.Entry entry : properties.entrySet()) {
params.set(PROPERTY_PREFIX + "." + entry.getKey().toString(),

View File

@ -28,7 +28,7 @@
"additionalProperties" : true
}
},
"required" : ["name", "baseConfigSet"]
"required" : ["name"]
}
}
}

View File

@ -38,8 +38,6 @@ public class TestConfigSetAdminRequest extends SolrTestCaseJ4 {
ConfigSetAdminRequest.Create create = new ConfigSetAdminRequest.Create();
verifyException(create, "ConfigSet");
create.setConfigSetName("name");
verifyException(create, "Base ConfigSet");
create.setBaseConfigSetName("baseConfigSet");
create.getParams();
}