Remove support for Solr as it is not compatible with Jetty 11
Closes gh-31054
This commit is contained in:
parent
c4beca3e01
commit
96c2d08fc4
|
@ -93,9 +93,6 @@ dependencies {
|
|||
}
|
||||
optional("org.apache.kafka:kafka-clients")
|
||||
optional("org.apache.kafka:kafka-streams")
|
||||
optional("org.apache.solr:solr-solrj") {
|
||||
exclude group: "org.slf4j", module: "jcl-over-slf4j"
|
||||
}
|
||||
optional("org.apache.tomcat.embed:tomcat-embed-core")
|
||||
optional("org.apache.tomcat.embed:tomcat-embed-el")
|
||||
optional("org.apache.tomcat:tomcat-jdbc")
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.solr;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.CompositeHealthContributorConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.HealthContributor;
|
||||
import org.springframework.boot.actuate.solr.SolrHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for {@link SolrHealthIndicator}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Stephane Nicoll
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@AutoConfiguration(after = SolrAutoConfiguration.class)
|
||||
@ConditionalOnClass(SolrClient.class)
|
||||
@ConditionalOnBean(SolrClient.class)
|
||||
@ConditionalOnEnabledHealthIndicator("solr")
|
||||
public class SolrHealthContributorAutoConfiguration
|
||||
extends CompositeHealthContributorConfiguration<SolrHealthIndicator, SolrClient> {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = { "solrHealthIndicator", "solrHealthContributor" })
|
||||
public HealthContributor solrHealthContributor(Map<String, SolrClient> solrClients) {
|
||||
return createContributor(solrClients);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Auto-configuration for actuator Solr concerns.
|
||||
*/
|
||||
package org.springframework.boot.actuate.autoconfigure.solr;
|
|
@ -267,12 +267,6 @@
|
|||
"description": "Whether to enable Redis health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.health.solr.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Whether to enable Solr health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.health.status.order",
|
||||
"defaultValue": [
|
||||
|
|
|
@ -91,7 +91,6 @@ org.springframework.boot.actuate.autoconfigure.scheduling.ScheduledTasksEndpoint
|
|||
org.springframework.boot.actuate.autoconfigure.security.reactive.ReactiveManagementWebSecurityAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.session.SessionsEndpointAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.solr.SolrHealthContributorAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.startup.StartupEndpointAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.system.DiskSpaceHealthContributorAutoConfiguration
|
||||
org.springframework.boot.actuate.autoconfigure.trace.http.HttpTraceAutoConfiguration
|
||||
|
|
|
@ -41,7 +41,6 @@ import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfigurati
|
|||
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration;
|
||||
import org.springframework.boot.context.annotation.UserConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
|
||||
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
||||
|
@ -82,7 +81,7 @@ class WebEndpointsAutoConfigurationIntegrationTests {
|
|||
Neo4jRepositoriesAutoConfiguration.class, MongoAutoConfiguration.class, MongoDataAutoConfiguration.class,
|
||||
MongoReactiveAutoConfiguration.class, MongoReactiveDataAutoConfiguration.class,
|
||||
RepositoryRestMvcAutoConfiguration.class, HazelcastAutoConfiguration.class,
|
||||
ElasticsearchDataAutoConfiguration.class, SolrAutoConfiguration.class, RedisAutoConfiguration.class,
|
||||
ElasticsearchDataAutoConfiguration.class, RedisAutoConfiguration.class,
|
||||
RedisRepositoriesAutoConfiguration.class, MetricsAutoConfiguration.class, WavefrontAutoConfiguration.class,
|
||||
BraveAutoConfiguration.class, OpenTelemetryAutoConfiguration.class })
|
||||
@SpringBootConfiguration
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.autoconfigure.solr;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
|
||||
import org.springframework.boot.actuate.solr.SolrHealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link SolrHealthContributorAutoConfiguration}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class SolrHealthContributorAutoConfigurationTests {
|
||||
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(SolrAutoConfiguration.class,
|
||||
SolrHealthContributorAutoConfiguration.class, HealthContributorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(SolrHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.solr.enabled:false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean(SolrHealthIndicator.class));
|
||||
}
|
||||
|
||||
}
|
|
@ -36,9 +36,6 @@ dependencies {
|
|||
}
|
||||
optional("javax.cache:cache-api")
|
||||
optional("jakarta.jms:jakarta.jms-api")
|
||||
optional("org.apache.solr:solr-solrj") {
|
||||
exclude group: "org.slf4j", module: "jcl-over-slf4j"
|
||||
}
|
||||
optional("org.apache.tomcat.embed:tomcat-embed-core")
|
||||
optional("org.aspectj:aspectjweaver")
|
||||
optional("org.cache2k:cache2k-micrometer")
|
||||
|
|
|
@ -1,136 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.solr;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteSolrException;
|
||||
import org.apache.solr.client.solrj.request.CoreAdminRequest;
|
||||
import org.apache.solr.common.params.CoreAdminParams;
|
||||
|
||||
import org.springframework.boot.actuate.health.AbstractHealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.boot.actuate.health.Status;
|
||||
|
||||
/**
|
||||
* {@link HealthIndicator} for Apache Solr.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Stephane Nicoll
|
||||
* @author Markus Schuch
|
||||
* @author Phillip Webb
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class SolrHealthIndicator extends AbstractHealthIndicator {
|
||||
|
||||
private static final int HTTP_NOT_FOUND_STATUS = 404;
|
||||
|
||||
private final SolrClient solrClient;
|
||||
|
||||
private volatile StatusCheck statusCheck;
|
||||
|
||||
public SolrHealthIndicator(SolrClient solrClient) {
|
||||
super("Solr health check failed");
|
||||
this.solrClient = solrClient;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doHealthCheck(Health.Builder builder) throws Exception {
|
||||
int statusCode = initializeStatusCheck();
|
||||
Status status = (statusCode != 0) ? Status.DOWN : Status.UP;
|
||||
builder.status(status).withDetail("status", statusCode).withDetail("detectedPathType",
|
||||
this.statusCheck.getPathType());
|
||||
}
|
||||
|
||||
private int initializeStatusCheck() throws Exception {
|
||||
StatusCheck statusCheck = this.statusCheck;
|
||||
if (statusCheck != null) {
|
||||
// Already initialized
|
||||
return statusCheck.getStatus(this.solrClient);
|
||||
}
|
||||
try {
|
||||
return initializeStatusCheck(new RootStatusCheck());
|
||||
}
|
||||
catch (RemoteSolrException ex) {
|
||||
// 404 is thrown when SolrClient has a baseUrl pointing to a particular core.
|
||||
if (ex.code() == HTTP_NOT_FOUND_STATUS) {
|
||||
return initializeStatusCheck(new ParticularCoreStatusCheck());
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
private int initializeStatusCheck(StatusCheck statusCheck) throws Exception {
|
||||
int result = statusCheck.getStatus(this.solrClient);
|
||||
this.statusCheck = statusCheck;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strategy used to perform the status check.
|
||||
*/
|
||||
private abstract static class StatusCheck {
|
||||
|
||||
private final String pathType;
|
||||
|
||||
StatusCheck(String pathType) {
|
||||
this.pathType = pathType;
|
||||
}
|
||||
|
||||
abstract int getStatus(SolrClient client) throws Exception;
|
||||
|
||||
String getPathType() {
|
||||
return this.pathType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link StatusCheck} used when {@code baseUrl} points to the root context.
|
||||
*/
|
||||
private static class RootStatusCheck extends StatusCheck {
|
||||
|
||||
RootStatusCheck() {
|
||||
super("root");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatus(SolrClient client) throws Exception {
|
||||
CoreAdminRequest request = new CoreAdminRequest();
|
||||
request.setAction(CoreAdminParams.CoreAdminAction.STATUS);
|
||||
return request.process(client).getStatus();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link StatusCheck} used when {@code baseUrl} points to the particular core.
|
||||
*/
|
||||
private static class ParticularCoreStatusCheck extends StatusCheck {
|
||||
|
||||
ParticularCoreStatusCheck() {
|
||||
super("particular core");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatus(SolrClient client) throws Exception {
|
||||
return client.ping().getStatus();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Actuator support for Solr.
|
||||
*/
|
||||
package org.springframework.boot.actuate.solr;
|
|
@ -1,145 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.actuate.solr;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteSolrException;
|
||||
import org.apache.solr.client.solrj.request.CoreAdminRequest;
|
||||
import org.apache.solr.client.solrj.response.SolrPingResponse;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.Status;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
||||
/**
|
||||
* Tests for {@link SolrHealthIndicator}
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Markus Schuch
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class SolrHealthIndicatorTests {
|
||||
|
||||
@Test
|
||||
void healthWhenSolrStatusUpAndBaseUrlPointsToRootReturnsUp() throws Exception {
|
||||
SolrClient solrClient = mock(SolrClient.class);
|
||||
given(solrClient.request(any(CoreAdminRequest.class), isNull())).willReturn(mockResponse(0));
|
||||
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
|
||||
assertHealth(healthIndicator, Status.UP, 0, "root");
|
||||
then(solrClient).should().request(any(CoreAdminRequest.class), isNull());
|
||||
then(solrClient).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
void healthWhenSolrStatusDownAndBaseUrlPointsToRootReturnsDown() throws Exception {
|
||||
SolrClient solrClient = mock(SolrClient.class);
|
||||
given(solrClient.request(any(CoreAdminRequest.class), isNull())).willReturn(mockResponse(400));
|
||||
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
|
||||
assertHealth(healthIndicator, Status.DOWN, 400, "root");
|
||||
then(solrClient).should().request(any(CoreAdminRequest.class), isNull());
|
||||
then(solrClient).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
void healthWhenSolrStatusUpAndBaseUrlPointsToParticularCoreReturnsUp() throws Exception {
|
||||
SolrClient solrClient = mock(SolrClient.class);
|
||||
given(solrClient.request(any(CoreAdminRequest.class), isNull()))
|
||||
.willThrow(new RemoteSolrException("mock", 404, "", null));
|
||||
given(solrClient.ping()).willReturn(mockPingResponse(0));
|
||||
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
|
||||
assertHealth(healthIndicator, Status.UP, 0, "particular core");
|
||||
then(solrClient).should().request(any(CoreAdminRequest.class), isNull());
|
||||
then(solrClient).should().ping();
|
||||
then(solrClient).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
void healthWhenSolrStatusDownAndBaseUrlPointsToParticularCoreReturnsDown() throws Exception {
|
||||
SolrClient solrClient = mock(SolrClient.class);
|
||||
given(solrClient.request(any(CoreAdminRequest.class), isNull()))
|
||||
.willThrow(new RemoteSolrException("mock", 404, "", null));
|
||||
given(solrClient.ping()).willReturn(mockPingResponse(400));
|
||||
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
|
||||
assertHealth(healthIndicator, Status.DOWN, 400, "particular core");
|
||||
then(solrClient).should().request(any(CoreAdminRequest.class), isNull());
|
||||
then(solrClient).should().ping();
|
||||
then(solrClient).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
void healthWhenSolrConnectionFailsReturnsDown() throws Exception {
|
||||
SolrClient solrClient = mock(SolrClient.class);
|
||||
given(solrClient.request(any(CoreAdminRequest.class), isNull()))
|
||||
.willThrow(new IOException("Connection failed"));
|
||||
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
|
||||
Health health = healthIndicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||
assertThat((String) health.getDetails().get("error")).contains("Connection failed");
|
||||
then(solrClient).should().request(any(CoreAdminRequest.class), isNull());
|
||||
then(solrClient).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
@Test
|
||||
void healthWhenMakingMultipleCallsRemembersStatusStrategy() throws Exception {
|
||||
SolrClient solrClient = mock(SolrClient.class);
|
||||
given(solrClient.request(any(CoreAdminRequest.class), isNull()))
|
||||
.willThrow(new RemoteSolrException("mock", 404, "", null));
|
||||
given(solrClient.ping()).willReturn(mockPingResponse(0));
|
||||
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
|
||||
healthIndicator.health();
|
||||
then(solrClient).should().request(any(CoreAdminRequest.class), isNull());
|
||||
then(solrClient).should().ping();
|
||||
then(solrClient).shouldHaveNoMoreInteractions();
|
||||
healthIndicator.health();
|
||||
then(solrClient).should(times(2)).ping();
|
||||
then(solrClient).shouldHaveNoMoreInteractions();
|
||||
}
|
||||
|
||||
private void assertHealth(SolrHealthIndicator healthIndicator, Status expectedStatus, int expectedStatusCode,
|
||||
String expectedPathType) {
|
||||
Health health = healthIndicator.health();
|
||||
assertThat(health.getStatus()).isEqualTo(expectedStatus);
|
||||
assertThat(health.getDetails().get("status")).isEqualTo(expectedStatusCode);
|
||||
assertThat(health.getDetails().get("detectedPathType")).isEqualTo(expectedPathType);
|
||||
}
|
||||
|
||||
private NamedList<Object> mockResponse(int status) {
|
||||
NamedList<Object> response = new NamedList<>();
|
||||
NamedList<Object> headers = new NamedList<>();
|
||||
headers.add("status", status);
|
||||
response.add("responseHeader", headers);
|
||||
return response;
|
||||
}
|
||||
|
||||
private SolrPingResponse mockPingResponse(int status) {
|
||||
SolrPingResponse pingResponse = new SolrPingResponse();
|
||||
pingResponse.setResponse(mockResponse(status));
|
||||
return pingResponse;
|
||||
}
|
||||
|
||||
}
|
|
@ -58,9 +58,6 @@ dependencies {
|
|||
}
|
||||
optional("org.apache.httpcomponents.client5:httpclient5")
|
||||
optional("org.apache.kafka:kafka-streams")
|
||||
optional("org.apache.solr:solr-solrj") {
|
||||
exclude group: "org.slf4j", module: "jcl-over-slf4j"
|
||||
}
|
||||
optional("org.apache.tomcat.embed:tomcat-embed-core")
|
||||
optional("org.apache.tomcat.embed:tomcat-embed-el")
|
||||
optional("org.apache.tomcat.embed:tomcat-embed-websocket")
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.solr;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Solr.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@ConditionalOnClass({ HttpSolrClient.class, CloudSolrClient.class })
|
||||
@EnableConfigurationProperties(SolrProperties.class)
|
||||
public class SolrAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SolrClient solrClient(SolrProperties properties) {
|
||||
if (StringUtils.hasText(properties.getZkHost())) {
|
||||
return new CloudSolrClient.Builder(Arrays.asList(properties.getZkHost()), Optional.empty()).build();
|
||||
}
|
||||
return new HttpSolrClient.Builder(properties.getHost()).build();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.solr;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* {@link ConfigurationProperties @ConfigurationProperties} for Solr.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.data.solr")
|
||||
public class SolrProperties {
|
||||
|
||||
/**
|
||||
* Solr host. Ignored if "zk-host" is set.
|
||||
*/
|
||||
private String host = "http://127.0.0.1:8983/solr";
|
||||
|
||||
/**
|
||||
* ZooKeeper host address in the form HOST:PORT.
|
||||
*/
|
||||
private String zkHost;
|
||||
|
||||
public String getHost() {
|
||||
return this.host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getZkHost() {
|
||||
return this.zkHost;
|
||||
}
|
||||
|
||||
public void setZkHost(String zkHost) {
|
||||
this.zkHost = zkHost;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Auto-configuration for Solr.
|
||||
*/
|
||||
package org.springframework.boot.autoconfigure.solr;
|
|
@ -99,7 +99,6 @@ org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2Clie
|
|||
org.springframework.boot.autoconfigure.security.oauth2.client.reactive.ReactiveOAuth2ClientAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.security.oauth2.resource.servlet.OAuth2ResourceServerAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.security.oauth2.resource.reactive.ReactiveOAuth2ResourceServerAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration
|
||||
|
|
|
@ -1360,29 +1360,6 @@ bom {
|
|||
]
|
||||
}
|
||||
}
|
||||
library("Solr", "8.11.1") {
|
||||
group("org.apache.solr") {
|
||||
modules = [
|
||||
"solr-analysis-extras",
|
||||
"solr-analytics",
|
||||
"solr-cell",
|
||||
"solr-core",
|
||||
"solr-dataimporthandler",
|
||||
"solr-dataimporthandler-extras",
|
||||
"solr-gcs-repository",
|
||||
"solr-jaegertracer-configurator",
|
||||
"solr-langid",
|
||||
"solr-ltr",
|
||||
"solr-prometheus-exporter",
|
||||
"solr-s3-repository",
|
||||
"solr-solrj" {
|
||||
exclude group: "org.slf4j", module: "jcl-over-slf4j"
|
||||
},
|
||||
"solr-test-framework",
|
||||
"solr-velocity"
|
||||
]
|
||||
}
|
||||
}
|
||||
library("Spring AMQP", "3.0.0-M3") {
|
||||
group("org.springframework.amqp") {
|
||||
modules = [
|
||||
|
|
|
@ -95,10 +95,6 @@ dependencies {
|
|||
}
|
||||
implementation("org.apache.kafka:kafka-streams")
|
||||
implementation("org.apache.logging.log4j:log4j-to-slf4j")
|
||||
implementation("org.apache.solr:solr-solrj") {
|
||||
exclude group: "commons-logging", module: "commons-logging"
|
||||
exclude group: "org.slf4j", module: "jcl-over-slf4j"
|
||||
}
|
||||
implementation("org.apache.tomcat.embed:tomcat-embed-core")
|
||||
implementation("org.assertj:assertj-core")
|
||||
implementation("org.cache2k:cache2k-spring")
|
||||
|
|
|
@ -711,10 +711,6 @@ with the `key` listed in the following table:
|
|||
| `redis`
|
||||
| {spring-boot-actuator-module-code}/redis/RedisHealthIndicator.java[`RedisHealthIndicator`]
|
||||
| Checks that a Redis server is up.
|
||||
|
||||
| `solr`
|
||||
| {spring-boot-actuator-module-code}/solr/SolrHealthIndicator.java[`SolrHealthIndicator`]
|
||||
| Checks that a Solr server is up.
|
||||
|===
|
||||
|
||||
TIP: You can disable them all by setting the configprop:management.health.defaults.enabled[] property.
|
||||
|
|
|
@ -252,8 +252,6 @@ boot-features-spring-data-mongo-repositories=features.nosql.mongodb.repositories
|
|||
boot-features-neo4j=features.nosql.neo4j
|
||||
boot-features-connecting-to-neo4j=features.nosql.neo4j.connecting
|
||||
boot-features-spring-data-neo4j-repositories=features.nosql.neo4j.repositories
|
||||
boot-features-solr=features.nosql.solr
|
||||
boot-features-connecting-to-solr=features.nosql.solr.connecting
|
||||
boot-features-elasticsearch=features.nosql.elasticsearch
|
||||
boot-features-connecting-to-elasticsearch-rest=features.nosql.elasticsearch.connecting-using-rest
|
||||
boot-features-connecting-to-elasticsearch-reactive-rest=features.nosql.elasticsearch.connecting-using-reactive-rest
|
||||
|
@ -808,8 +806,6 @@ features.nosql.mongodb.repositories=data.nosql.mongodb.repositories
|
|||
features.nosql.neo4j=data.nosql.neo4j
|
||||
features.nosql.neo4j.connecting=data.nosql.neo4j.connecting
|
||||
features.nosql.neo4j.repositories=data.nosql.neo4j.repositories
|
||||
features.nosql.solr=data.nosql.solr
|
||||
features.nosql.solr.connecting=data.nosql.solr.connecting
|
||||
features.nosql.elasticsearch=data.nosql.elasticsearch
|
||||
features.nosql.elasticsearch.connecting-using-rest=data.nosql.elasticsearch.connecting-using-rest
|
||||
features.nosql.elasticsearch.connecting-using-reactive-rest=data.nosql.elasticsearch.connecting-using-reactive-rest
|
||||
|
|
|
@ -11,7 +11,7 @@ Spring Data provides additional projects that help you access a variety of NoSQL
|
|||
* {spring-data-couchbase}[Couchbase]
|
||||
* {spring-data-ldap}[LDAP]
|
||||
|
||||
Spring Boot provides auto-configuration for Redis, MongoDB, Neo4j, Solr, Elasticsearch, Cassandra, Couchbase, LDAP and InfluxDB.
|
||||
Spring Boot provides auto-configuration for Redis, MongoDB, Neo4j, Elasticsearch, Cassandra, Couchbase, LDAP and InfluxDB.
|
||||
Additionally, {spring-boot-for-apache-geode}[Spring Boot for Apache Geode] provides {spring-boot-for-apache-geode-docs}#geode-repositories[auto-configuration for Apache Geode].
|
||||
You can make use of the other projects, but you must configure them yourself.
|
||||
See the appropriate reference documentation at {spring-data}.
|
||||
|
@ -196,25 +196,6 @@ include::code:MyNeo4jConfiguration[]
|
|||
|
||||
|
||||
|
||||
[[data.nosql.solr]]
|
||||
=== Solr
|
||||
https://lucene.apache.org/solr/[Apache Solr] is a search engine.
|
||||
Spring Boot offers basic auto-configuration for the Solr 5 client library.
|
||||
|
||||
|
||||
|
||||
[[data.nosql.solr.connecting]]
|
||||
==== Connecting to Solr
|
||||
You can inject an auto-configured `SolrClient` instance as you would any other Spring bean.
|
||||
By default, the instance tries to connect to a server at `http://localhost:8983/solr`.
|
||||
The following example shows how to inject a Solr bean:
|
||||
|
||||
include::code:MyBean[]
|
||||
|
||||
If you add your own `@Bean` of type `SolrClient`, it replaces the default.
|
||||
|
||||
|
||||
|
||||
[[data.nosql.elasticsearch]]
|
||||
=== Elasticsearch
|
||||
https://www.elastic.co/products/elasticsearch[Elasticsearch] is an open source, distributed, RESTful search and analytics engine.
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.docs.data.nosql.solr.connecting;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.response.SolrPingResponse;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class MyBean {
|
||||
|
||||
private final SolrClient solr;
|
||||
|
||||
public MyBean(SolrClient solr) {
|
||||
this.solr = solr;
|
||||
}
|
||||
|
||||
// @fold:on // ...
|
||||
public SolrPingResponse someMethod() throws SolrServerException, IOException {
|
||||
return this.solr.ping("users");
|
||||
}
|
||||
// @fold:off
|
||||
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.docs.data.nosql.solr.connecting
|
||||
|
||||
import org.apache.solr.client.solrj.SolrClient
|
||||
import org.apache.solr.client.solrj.response.SolrPingResponse
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
class MyBean(private val solr: SolrClient) {
|
||||
|
||||
// @fold:on // ...
|
||||
fun someMethod(): SolrPingResponse {
|
||||
return solr.ping("users")
|
||||
}
|
||||
// @fold:off
|
||||
|
||||
}
|
Loading…
Reference in New Issue