mirror of https://github.com/apache/lucene.git
SOLR-11861 baseConfigSet default
This commit is contained in:
parent
e0eb7bac02
commit
b1b0963947
|
@ -198,6 +198,9 @@ New Features
|
||||||
* SOLR-12715: NodeAddedTrigger should support adding replicas to new nodes by setting preferredOperation=addreplica.
|
* SOLR-12715: NodeAddedTrigger should support adding replicas to new nodes by setting preferredOperation=addreplica.
|
||||||
(shalin)
|
(shalin)
|
||||||
|
|
||||||
|
* SOLR-11861: When creating a configSet via the API, the "baseConfigSet" parameter now defaults to "_default".
|
||||||
|
(Amrit Sarkar, David Smiley)
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import static org.apache.solr.common.params.CommonParams.NAME;
|
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.CREATE;
|
||||||
|
import static org.apache.solr.handler.admin.ConfigSetsHandlerApi.DEFAULT_CONFIGSET_NAME;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link OverseerMessageHandler} that handles ConfigSets API related
|
* A {@link OverseerMessageHandler} that handles ConfigSets API related
|
||||||
|
@ -210,7 +211,11 @@ public class OverseerConfigSetMessageHandler implements OverseerMessageHandler {
|
||||||
operation = operation.substring(CONFIGSETS_ACTION_PREFIX.length());
|
operation = operation.substring(CONFIGSETS_ACTION_PREFIX.length());
|
||||||
ConfigSetParams.ConfigSetAction action = ConfigSetParams.ConfigSetAction.get(operation);
|
ConfigSetParams.ConfigSetAction action = ConfigSetParams.ConfigSetAction.get(operation);
|
||||||
if (action == CREATE) {
|
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;
|
return null;
|
||||||
|
@ -283,10 +288,7 @@ public class OverseerConfigSetMessageHandler implements OverseerMessageHandler {
|
||||||
throw new SolrException(ErrorCode.BAD_REQUEST, "ConfigSet name not specified");
|
throw new SolrException(ErrorCode.BAD_REQUEST, "ConfigSet name not specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
String baseConfigSetName = message.getStr(BASE_CONFIGSET);
|
String baseConfigSetName = message.getStr(BASE_CONFIGSET, DEFAULT_CONFIGSET_NAME);
|
||||||
if (baseConfigSetName == null || baseConfigSetName.length() == 0) {
|
|
||||||
throw new SolrException(ErrorCode.BAD_REQUEST, "Base ConfigSet name not specified");
|
|
||||||
}
|
|
||||||
|
|
||||||
ZkConfigManager configManager = new ZkConfigManager(zkStateReader.getZkClient());
|
ZkConfigManager configManager = new ZkConfigManager(zkStateReader.getZkClient());
|
||||||
if (configManager.configExists(configSetName)) {
|
if (configManager.configExists(configSetName)) {
|
||||||
|
|
|
@ -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.CREATE;
|
||||||
import static org.apache.solr.common.params.ConfigSetParams.ConfigSetAction.DELETE;
|
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.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.
|
* 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() {
|
public String getDescription() {
|
||||||
return "Manage SolrCloud ConfigSets";
|
return "Manage SolrCloud ConfigSets";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Category getCategory() {
|
public Category getCategory() {
|
||||||
return Category.ADMIN;
|
return Category.ADMIN;
|
||||||
|
@ -263,7 +265,9 @@ public class ConfigSetsHandler extends RequestHandlerBase implements PermissionN
|
||||||
CREATE_OP(CREATE) {
|
CREATE_OP(CREATE) {
|
||||||
@Override
|
@Override
|
||||||
Map<String, Object> call(SolrQueryRequest req, SolrQueryResponse rsp, ConfigSetsHandler h) throws Exception {
|
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 + ".");
|
return copyPropertiesWithPrefix(req.getParams(), props, PROPERTY_PREFIX + ".");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,11 +16,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.solr.cloud;
|
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.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -99,6 +94,10 @@ import org.noggit.ObjectBuilder;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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.
|
* Simple ConfigSets API tests on user errors and simple success cases.
|
||||||
*/
|
*/
|
||||||
|
@ -136,9 +135,8 @@ public class TestConfigSetsAPI extends SolrTestCaseJ4 {
|
||||||
CreateNoErrorChecking create = new CreateNoErrorChecking();
|
CreateNoErrorChecking create = new CreateNoErrorChecking();
|
||||||
verifyException(solrClient, create, NAME);
|
verifyException(solrClient, create, NAME);
|
||||||
|
|
||||||
// no base ConfigSet name
|
// set ConfigSet
|
||||||
create.setConfigSetName("configSetName");
|
create.setConfigSetName("configSetName");
|
||||||
verifyException(solrClient, create, BASE_CONFIGSET);
|
|
||||||
|
|
||||||
// ConfigSet already exists
|
// ConfigSet already exists
|
||||||
Create alreadyExists = new Create();
|
Create alreadyExists = new Create();
|
||||||
|
@ -156,7 +154,7 @@ public class TestConfigSetsAPI extends SolrTestCaseJ4 {
|
||||||
@Test
|
@Test
|
||||||
public void testCreate() throws Exception {
|
public void testCreate() throws Exception {
|
||||||
// no old, no new
|
// no old, no new
|
||||||
verifyCreate("baseConfigSet1", "configSet1", null, null);
|
verifyCreate(null, "configSet1", null, null);
|
||||||
|
|
||||||
// no old, new
|
// no old, new
|
||||||
verifyCreate("baseConfigSet2", "configSet2",
|
verifyCreate("baseConfigSet2", "configSet2",
|
||||||
|
|
|
@ -130,7 +130,7 @@ name::
|
||||||
The configset to be created. This parameter is required.
|
The configset to be created. This parameter is required.
|
||||||
|
|
||||||
baseConfigSet::
|
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_::
|
configSetProp._property_=_value_::
|
||||||
A configset property from the base configset to override in the copied configset.
|
A configset property from the base configset to override in the copied configset.
|
||||||
|
|
|
@ -135,10 +135,9 @@ public abstract class ConfigSetAdminRequest
|
||||||
@Override
|
@Override
|
||||||
public SolrParams getParams() {
|
public SolrParams getParams() {
|
||||||
ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
|
ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
|
||||||
if (baseConfigSetName == null) {
|
if (baseConfigSetName != null) {
|
||||||
throw new RuntimeException( "no Base ConfigSet specified!" );
|
|
||||||
}
|
|
||||||
params.set("baseConfigSet", baseConfigSetName);
|
params.set("baseConfigSet", baseConfigSetName);
|
||||||
|
}
|
||||||
if (properties != null) {
|
if (properties != null) {
|
||||||
for (Map.Entry entry : properties.entrySet()) {
|
for (Map.Entry entry : properties.entrySet()) {
|
||||||
params.set(PROPERTY_PREFIX + "." + entry.getKey().toString(),
|
params.set(PROPERTY_PREFIX + "." + entry.getKey().toString(),
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
"additionalProperties" : true
|
"additionalProperties" : true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required" : ["name", "baseConfigSet"]
|
"required" : ["name"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,6 @@ public class TestConfigSetAdminRequest extends SolrTestCaseJ4 {
|
||||||
ConfigSetAdminRequest.Create create = new ConfigSetAdminRequest.Create();
|
ConfigSetAdminRequest.Create create = new ConfigSetAdminRequest.Create();
|
||||||
verifyException(create, "ConfigSet");
|
verifyException(create, "ConfigSet");
|
||||||
create.setConfigSetName("name");
|
create.setConfigSetName("name");
|
||||||
verifyException(create, "Base ConfigSet");
|
|
||||||
create.setBaseConfigSetName("baseConfigSet");
|
|
||||||
create.getParams();
|
create.getParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue