Skip to content

Commit 722e1e8

Browse files
authored
SOLR-18163: Remove v2-disabling sysprop (#4233)
This will allow Solr and other tooling to start relying on the v2 API.
1 parent 4f7b46d commit 722e1e8

File tree

12 files changed

+90
-106
lines changed

12 files changed

+90
-106
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
title: Remove experimental 'solr.api.v2.enabled' sysprop, formerly used to disable the v2 API.
2+
type: removed
3+
authors:
4+
- name: Jason Gerlowski
5+
links:
6+
- name: SOLR-18163
7+
url: https://issues.apache.org/jira/browse/SOLR-18163

solr/core/src/java/org/apache/solr/core/CoreContainer.java

Lines changed: 54 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@
124124
import org.apache.solr.handler.admin.ZookeeperInfoHandler;
125125
import org.apache.solr.handler.admin.ZookeeperRead;
126126
import org.apache.solr.handler.admin.ZookeeperStatusHandler;
127-
import org.apache.solr.handler.api.V2ApiUtils;
128127
import org.apache.solr.handler.component.ShardHandlerFactory;
129128
import org.apache.solr.handler.designer.SchemaDesignerAPI;
130129
import org.apache.solr.jersey.InjectionFactories;
@@ -721,15 +720,15 @@ public ObjectCache getObjectCache() {
721720
return objectCache;
722721
}
723722

724-
private void registerV2ApiIfEnabled(Object apiObject) {
723+
private void registerV2Api(Object apiObject) {
725724
if (apiObject == null || containerHandlers.getApiBag() == null) {
726725
return;
727726
}
728727

729728
containerHandlers.getApiBag().registerObject(apiObject);
730729
}
731730

732-
private void registerV2ApiIfEnabled(Class<? extends JerseyResource> clazz) {
731+
private void registerV2Api(Class<? extends JerseyResource> clazz) {
733732
if (containerHandlers.getJerseyEndpoints() == null) {
734733
return;
735734
}
@@ -845,12 +844,12 @@ private void loadInternal() {
845844
Attributes.builder().put(HANDLER_ATTR, "/authentication/pki").build());
846845

847846
fileStore = new DistribFileStore(this);
848-
registerV2ApiIfEnabled(ClusterFileStore.class);
847+
registerV2Api(ClusterFileStore.class);
849848

850849
packageLoader = new SolrPackageLoader(this);
851-
registerV2ApiIfEnabled(packageLoader.getPackageAPI().editAPI);
852-
registerV2ApiIfEnabled(packageLoader.getPackageAPI().readAPI);
853-
registerV2ApiIfEnabled(ZookeeperRead.class);
850+
registerV2Api(packageLoader.getPackageAPI().editAPI);
851+
registerV2Api(packageLoader.getPackageAPI().readAPI);
852+
registerV2Api(ZookeeperRead.class);
854853
}
855854

856855
MDCLoggingContext.setNode(this);
@@ -872,11 +871,11 @@ private void loadInternal() {
872871
createHandler(
873872
CONFIGSETS_HANDLER_PATH, cfg.getConfigSetsHandlerClass(), ConfigSetsHandler.class);
874873
ClusterAPI clusterAPI = new ClusterAPI(collectionsHandler, configSetsHandler);
875-
registerV2ApiIfEnabled(clusterAPI);
876-
registerV2ApiIfEnabled(clusterAPI.commands);
874+
registerV2Api(clusterAPI);
875+
registerV2Api(clusterAPI.commands);
877876

878877
if (isZooKeeperAware()) {
879-
registerV2ApiIfEnabled(new SchemaDesignerAPI(this));
878+
registerV2Api(new SchemaDesignerAPI(this));
880879
} // else Schema Designer not available in standalone (non-cloud) mode
881880

882881
/*
@@ -1027,8 +1026,8 @@ private void loadInternal() {
10271026
if (isZooKeeperAware()) {
10281027
containerPluginsRegistry.refresh();
10291028
getZkController().zkStateReader.registerClusterPropertiesListener(containerPluginsRegistry);
1030-
registerV2ApiIfEnabled(pluginsSource.getReadApi());
1031-
registerV2ApiIfEnabled(pluginsSource.getEditApi());
1029+
registerV2Api(pluginsSource.getReadApi());
1030+
registerV2Api(pluginsSource.getEditApi());
10321031

10331032
// initialize the placement plugin factory wrapper
10341033
// with the plugin configuration from the registry
@@ -1051,51 +1050,49 @@ private void loadInternal() {
10511050
});
10521051
}
10531052

1054-
if (V2ApiUtils.isEnabled()) {
1055-
final CoreContainer thisCCRef = this;
1056-
// Init the Jersey app once all CC endpoints have been registered
1057-
containerHandlers
1058-
.getJerseyEndpoints()
1059-
.register(
1060-
new AbstractBinder() {
1061-
@Override
1062-
protected void configure() {
1063-
bindFactory(new InjectionFactories.SingletonFactory<>(thisCCRef))
1064-
.to(CoreContainer.class)
1065-
.in(Singleton.class);
1066-
}
1067-
})
1068-
.register(
1069-
new AbstractBinder() {
1070-
@Override
1071-
protected void configure() {
1072-
bindFactory(new InjectionFactories.SingletonFactory<>(nodeKeyPair))
1073-
.to(SolrNodeKeyPair.class)
1074-
.in(Singleton.class);
1075-
}
1076-
})
1077-
.register(
1078-
new AbstractBinder() {
1079-
@Override
1080-
protected void configure() {
1081-
bindFactory(new InjectionFactories.SingletonFactory<>(fileStore))
1082-
.to(DistribFileStore.class)
1083-
.in(Singleton.class);
1084-
}
1085-
})
1086-
.register(
1087-
new AbstractBinder() {
1088-
@Override
1089-
protected void configure() {
1090-
bindFactory(
1091-
new InjectionFactories.SingletonFactory<>(
1092-
coreAdminHandler.getCoreAdminAsyncTracker()))
1093-
.to(CoreAdminHandler.CoreAdminAsyncTracker.class)
1094-
.in(Singleton.class);
1095-
}
1096-
});
1097-
jerseyAppHandler = new ApplicationHandler(containerHandlers.getJerseyEndpoints());
1098-
}
1053+
final CoreContainer thisCCRef = this;
1054+
// Init the Jersey app once all CC endpoints have been registered
1055+
containerHandlers
1056+
.getJerseyEndpoints()
1057+
.register(
1058+
new AbstractBinder() {
1059+
@Override
1060+
protected void configure() {
1061+
bindFactory(new InjectionFactories.SingletonFactory<>(thisCCRef))
1062+
.to(CoreContainer.class)
1063+
.in(Singleton.class);
1064+
}
1065+
})
1066+
.register(
1067+
new AbstractBinder() {
1068+
@Override
1069+
protected void configure() {
1070+
bindFactory(new InjectionFactories.SingletonFactory<>(nodeKeyPair))
1071+
.to(SolrNodeKeyPair.class)
1072+
.in(Singleton.class);
1073+
}
1074+
})
1075+
.register(
1076+
new AbstractBinder() {
1077+
@Override
1078+
protected void configure() {
1079+
bindFactory(new InjectionFactories.SingletonFactory<>(fileStore))
1080+
.to(DistribFileStore.class)
1081+
.in(Singleton.class);
1082+
}
1083+
})
1084+
.register(
1085+
new AbstractBinder() {
1086+
@Override
1087+
protected void configure() {
1088+
bindFactory(
1089+
new InjectionFactories.SingletonFactory<>(
1090+
coreAdminHandler.getCoreAdminAsyncTracker()))
1091+
.to(CoreAdminHandler.CoreAdminAsyncTracker.class)
1092+
.in(Singleton.class);
1093+
}
1094+
});
1095+
jerseyAppHandler = new ApplicationHandler(containerHandlers.getJerseyEndpoints());
10991096

11001097
// Do Node setup logic after all handlers have been registered.
11011098
if (isZooKeeperAware()) {

solr/core/src/java/org/apache/solr/core/PluginBag.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import org.apache.solr.common.SolrException;
4343
import org.apache.solr.common.util.StrUtils;
4444
import org.apache.solr.handler.RequestHandlerBase;
45-
import org.apache.solr.handler.api.V2ApiUtils;
4645
import org.apache.solr.handler.component.SearchComponent;
4746
import org.apache.solr.jersey.APIConfigProvider;
4847
import org.apache.solr.jersey.APIConfigProviderBinder;
@@ -95,7 +94,7 @@ public JaxrsResourceToHandlerMappings getJaxrsRegistry() {
9594

9695
/** Pass needThreadSafety=true if plugins can be added and removed concurrently with lookups. */
9796
public PluginBag(Class<T> klass, SolrCore core, boolean needThreadSafety) {
98-
if (klass == SolrRequestHandler.class && V2ApiUtils.isEnabled()) {
97+
if (klass == SolrRequestHandler.class) {
9998
this.loadV2ApisIfPresent = true;
10099
this.apiBag = new ApiBag(core != null);
101100
this.jaxrsResourceRegistry = new JaxrsResourceToHandlerMappings();
@@ -251,7 +250,7 @@ public PluginHolder<T> put(String name, PluginHolder<T> plugin) {
251250
if (registerApi == null) registerApi = apiSupport.registerV2();
252251
if (disableV1 == null) disableV1 = !apiSupport.registerV1();
253252

254-
if (registerApi && V2ApiUtils.isEnabled()) {
253+
if (registerApi) {
255254
Collection<Api> apis = apiSupport.getApis();
256255
if (apis != null) {
257256
Map<String, String> nameSubstitutes = singletonMap(HANDLER_NAME, name);

solr/core/src/java/org/apache/solr/core/SolrCore.java

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@
110110
import org.apache.solr.handler.IndexFetcher;
111111
import org.apache.solr.handler.RequestHandlerBase;
112112
import org.apache.solr.handler.SolrConfigHandler;
113-
import org.apache.solr.handler.api.V2ApiUtils;
114113
import org.apache.solr.handler.component.HighlightComponent;
115114
import org.apache.solr.handler.component.SearchComponent;
116115
import org.apache.solr.logging.MDCLoggingContext;
@@ -1146,23 +1145,19 @@ protected SolrCore(
11461145
updateProcessorChains = loadUpdateProcessorChains();
11471146
reqHandlers = new RequestHandlers(this);
11481147
reqHandlers.initHandlersFromConfig(solrConfig);
1149-
if (V2ApiUtils.isEnabled()) {
1150-
final String effectiveConfigSetId = configSet.getName() + "-" + solrConfig.effectiveId();
1151-
jerseyAppHandler =
1152-
coreContainer
1153-
.getJerseyAppHandlerCache()
1154-
.computeIfAbsent(
1155-
effectiveConfigSetId,
1156-
() -> {
1157-
log.debug(
1158-
"Creating Jersey ApplicationHandler for 'effective solrConfig' [{}]",
1159-
effectiveConfigSetId);
1160-
return new ApplicationHandler(
1161-
reqHandlers.getRequestHandlers().getJerseyEndpoints());
1162-
});
1163-
} else {
1164-
jerseyAppHandler = null;
1165-
}
1148+
final String effectiveConfigSetId = configSet.getName() + "-" + solrConfig.effectiveId();
1149+
jerseyAppHandler =
1150+
coreContainer
1151+
.getJerseyAppHandlerCache()
1152+
.computeIfAbsent(
1153+
effectiveConfigSetId,
1154+
() -> {
1155+
log.debug(
1156+
"Creating Jersey ApplicationHandler for 'effective solrConfig' [{}]",
1157+
effectiveConfigSetId);
1158+
return new ApplicationHandler(
1159+
reqHandlers.getRequestHandlers().getJerseyEndpoints());
1160+
});
11661161

11671162
// cause the executor to stall so firstSearcher events won't fire
11681163
// until after inform() has been called for all components.

solr/core/src/java/org/apache/solr/handler/api/V2ApiUtils.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.apache.solr.client.api.model.SolrJerseyResponse;
2929
import org.apache.solr.common.MapWriter.EntryWriter;
3030
import org.apache.solr.common.params.SolrParams;
31-
import org.apache.solr.common.util.EnvUtils;
3231
import org.apache.solr.common.util.NamedList;
3332
import org.apache.solr.common.util.StrUtils;
3433
import org.apache.solr.common.util.Utils;
@@ -42,10 +41,6 @@ private V2ApiUtils() {
4241
/* Private ctor prevents instantiation */
4342
}
4443

45-
public static boolean isEnabled() {
46-
return EnvUtils.getPropertyAsBool("solr.api.v2.enabled", true);
47-
}
48-
4944
public static void flattenMapWithPrefix(
5045
Map<String, Object> toFlatten, Map<String, Object> destination, String additionalPrefix) {
5146
if (toFlatten == null || toFlatten.isEmpty() || destination == null) {

solr/core/src/java/org/apache/solr/servlet/SolrServlet.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.apache.solr.common.util.ExecutorUtil;
3333
import org.apache.solr.core.CoreContainer;
3434
import org.apache.solr.core.NodeRoles;
35-
import org.apache.solr.handler.api.V2ApiUtils;
3635
import org.slf4j.Logger;
3736
import org.slf4j.LoggerFactory;
3837

@@ -156,7 +155,7 @@ default HttpSolrCall createInstance(
156155
HttpServletRequest request,
157156
HttpServletResponse response,
158157
boolean retry) {
159-
if (V2ApiUtils.isEnabled() && (path.startsWith("/____v2/") || path.equals("/____v2"))) {
158+
if (path.startsWith("/____v2/") || path.equals("/____v2")) {
160159
return new V2HttpCall(cores, request, response, retry);
161160
} else {
162161
return new HttpSolrCall(cores, request, response, retry);

solr/core/src/test/org/apache/solr/handler/api/V2ApiUtilsTest.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,6 @@
2727

2828
public class V2ApiUtilsTest extends SolrTestCaseJ4 {
2929

30-
@Test
31-
public void testReadsEnableV2ApiSysprop() {
32-
System.clearProperty("solr.api.v2.enabled");
33-
assertTrue("v2 API should be enabled if sysprop not specified", V2ApiUtils.isEnabled());
34-
35-
System.setProperty("solr.api.v2.enabled", "true");
36-
assertTrue("v2 API should be enabled if sysprop explicitly enables it", V2ApiUtils.isEnabled());
37-
38-
System.setProperty("solr.api.v2.enabled", "false");
39-
assertFalse(
40-
"v2 API should be disabled if sysprop explicitly disables it", V2ApiUtils.isEnabled());
41-
}
42-
4330
@Test
4431
public void testConvertsWtToMediaTypeString() {
4532
assertEquals("someDefault", V2ApiUtils.getMediaTypeFromWtParam(SolrParams.of(), "someDefault"));

solr/packaging/test/test_start_solr.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ teardown() {
8484
}
8585

8686
@test "deprecated system properties converted to modern properties" {
87-
solr start -Ddisable.v2.api=true
88-
assert_file_contains "${SOLR_LOGS_DIR}/solr.log" 'You are passing in deprecated system property disable.v2.api and should upgrade to using solr.api.v2.enabled instead.'
87+
solr start -Ddisable.config.edit=true
88+
assert_file_contains "${SOLR_LOGS_DIR}/solr.log" 'You are passing in deprecated system property disable.config.edit and should upgrade to using solr.api.config.edit.enabled instead.'
8989
}
9090

9191
@test "start with custom jetty options" {

solr/solr-ref-guide/modules/configuration-guide/pages/solr-properties.adoc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ NOTE: Properties marked with "!" indicate inverted meaning between pre Solr 10 a
3232

3333
|solr.api.config.edit.enabled|!disable.config.edit|true|Controls whether configuration editing via API is enabled. When set to `true`, configuration editing is enabled.
3434

35-
|solr.api.v2.enabled|!disable.v2.api|true|Controls whether the V2 API is enabled. When set to `true`, the V2 API is enabled.
36-
3735
|solr.auth.jwt.outbound.http.enabled|solr.auth.jwt.allowOutboundHttp|false|Controls whether JWT authentication for outbound HTTP connections is enabled.
3836

3937
|solr.auth.superuser|solr.authorization.superuser|solr|Specifies the superuser for authorization. This user has all permissions when using SASL authentication.
@@ -159,13 +157,13 @@ Many Solr properties follow a standard naming convention. Newer properties typic
159157

160158
System properties can be set in several ways:
161159

162-
1. JVM command line arguments using `-D`: `-Dsolr.api.v2.enabled=true`
160+
1. JVM command line arguments using `-D`: `-Dsolr.api.config.edit.enabled=true`
163161
2. In `solr.in.sh` (Unix) or `solr.in.cmd` (Windows) using environment variables
164162
3. Through environment variables (with appropriate naming conventions)
165163

166164
Environment variables can also be used to set these properties.
167165
You may find this useful in environments such as Docker.
168-
Environment variables should be uppercase with dot notations equivalents, e.g. `SOLR_API_V2_ENABLED` for the property `solr.api.v2.enabled`.
166+
Environment variables should be uppercase with dot notations equivalents, e.g. `SOLR_API_CONFIG_EDIT_ENABLED` for the property `solr.api.config.edit.enabled`.
169167

170168
== See Also
171169

solr/solr-ref-guide/modules/configuration-guide/pages/v2-api.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
The v2 API is a modernized self-documenting API interface covering most current Solr APIs.
2121
It is anticipated that once the v2 API reaches full coverage, and Solr-internal API usages like SolrJ and the Admin UI have been converted from the old API to the v2 API, the old API will eventually be retired.
2222
Today, the two API styles coexist, and all the old APIs will continue to work without any change.
23-
You can disable all v2 API endpoints if desired by starting your servers with this system property: `-Dsolr.api.v2.enabled=false`.
2423

2524
NOTE: The v2 API is classified as "experimental".
2625
It may change in backwards-incompatible ways as it evolves to cover additional functionality.

0 commit comments

Comments
 (0)