1
0
mirror of synced 2026-07-07 18:50:00 +00:00

Compare commits

...

8 Commits

Author SHA1 Message Date
Jens Schauder 060cab76d5 DATAES-692 - Release version 3.2.3 (Moore SR3). 2019-12-04 14:12:24 +01:00
Jens Schauder afb8a35eac DATAES-692 - Prepare 3.2.3 (Moore SR3). 2019-12-04 14:11:44 +01:00
Jens Schauder 1c0dd71020 DATAES-692 - Updated changelog. 2019-12-04 14:11:42 +01:00
Jens Schauder 1633668d7f DATAES-691 - Updated changelog. 2019-12-04 12:09:51 +01:00
Peter-Josef Meisch 6756f792c8 DATAES-699 - Fix count implementation.
Original PR: #349
2019-12-01 10:03:56 +01:00
Peter-Josef Meisch bae4db8a7f DATAES-700 - Enable proxy support for RestClient. 2019-11-30 23:30:59 +01:00
Mark Paluch c47fd2cfce DATAES-685 - After release cleanups. 2019-11-18 12:42:05 +01:00
Mark Paluch cb08bb7196 DATAES-685 - Prepare next development iteration. 2019-11-18 12:42:04 +01:00
11 changed files with 135 additions and 13 deletions
+23 -5
View File
@@ -5,12 +5,12 @@
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>3.2.2.RELEASE</version>
<version>3.2.3.RELEASE</version>
<parent>
<groupId>org.springframework.data.build</groupId>
<artifactId>spring-data-parent</artifactId>
<version>2.2.2.RELEASE</version>
<version>2.2.3.RELEASE</version>
</parent>
<name>Spring Data Elasticsearch</name>
@@ -21,7 +21,7 @@
<commonslang>2.6</commonslang>
<elasticsearch>6.8.4</elasticsearch>
<log4j>2.9.1</log4j>
<springdata.commons>2.2.2.RELEASE</springdata.commons>
<springdata.commons>2.2.3.RELEASE</springdata.commons>
<netty>4.1.39.Final</netty>
<java-module-name>spring.data.elasticsearch</java-module-name>
</properties>
@@ -248,6 +248,24 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<version>2.25.1</version>
<scope>test</scope>
<exclusions>
<!-- these exclusions are needed because of Elasticsearch JarHell-->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Upgrade xbean to 4.5 to prevent incompatibilities due to ASM versions -->
<dependency>
<groupId>org.apache.xbean</groupId>
@@ -258,8 +276,8 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>test</scope>
</dependency>
@@ -144,6 +144,14 @@ public interface ClientConfiguration {
*/
Duration getSocketTimeout();
/**
* returns an optionally set proxy in the form host:port
*
* @return the optional proxy
* @since 4.0
*/
Optional<String> getProxy();
/**
* @author Christoph Strobl
*/
@@ -212,8 +220,8 @@ public interface ClientConfiguration {
TerminalClientConfigurationBuilder usingSsl(SSLContext sslContext);
/**
* Connect via {@literal https} using the givens {@link SSLContext} and HostnameVerifier {@link HostnameVerifier} .<br />
*
* Connect via {@literal https} using the givens {@link SSLContext} and HostnameVerifier {@link HostnameVerifier}
* .<br />
* <strong>NOTE</strong> You need to leave out the protocol in
* {@link ClientConfigurationBuilderWithRequiredEndpoint#connectedTo(String)}.
*
@@ -286,6 +294,12 @@ public interface ClientConfiguration {
*/
TerminalClientConfigurationBuilder withBasicAuth(String username, String password);
/**
* @param proxy a proxy formatted as String {@literal host:port}.
* @return the {@link MaybeSecureClientConfigurationBuilder}.
*/
MaybeSecureClientConfigurationBuilder withProxy(String proxy);
/**
* Build the {@link ClientConfiguration} object.
*
@@ -53,6 +53,7 @@ class ClientConfigurationBuilder
private Duration soTimeout = Duration.ofSeconds(5);
private String username;
private String password;
private String proxy;
/*
* (non-Javadoc)
@@ -81,6 +82,13 @@ class ClientConfigurationBuilder
return this;
}
@Override
public MaybeSecureClientConfigurationBuilder withProxy(String proxy) {
Assert.hasLength(proxy, "proxy must not be null or empty");
this.proxy = proxy;
return this;
}
/*
* (non-Javadoc)
* @see org.springframework.data.elasticsearch.client.ClientConfiguration.MaybeSecureClientConfigurationBuilder#usingSsl()
@@ -189,8 +197,8 @@ class ClientConfigurationBuilder
headers.setBasicAuth(username, password);
}
return new DefaultClientConfiguration(this.hosts, this.headers, this.useSsl, this.sslContext, this.soTimeout,
this.connectTimeout, this.hostnameVerifier);
return new DefaultClientConfiguration(hosts, headers, useSsl, sslContext, soTimeout, connectTimeout,
hostnameVerifier, proxy);
}
private static InetSocketAddress parse(String hostAndPort) {
@@ -44,9 +44,11 @@ class DefaultClientConfiguration implements ClientConfiguration {
private final Duration soTimeout;
private final Duration connectTimeout;
private final @Nullable HostnameVerifier hostnameVerifier;
private final String proxy;
DefaultClientConfiguration(List<InetSocketAddress> hosts, HttpHeaders headers, boolean useSsl,
@Nullable SSLContext sslContext, Duration soTimeout, Duration connectTimeout, @Nullable HostnameVerifier hostnameVerifier) {
@Nullable SSLContext sslContext, Duration soTimeout, Duration connectTimeout,
@Nullable HostnameVerifier hostnameVerifier, String proxy) {
this.hosts = Collections.unmodifiableList(new ArrayList<>(hosts));
this.headers = new HttpHeaders(headers);
@@ -55,6 +57,7 @@ class DefaultClientConfiguration implements ClientConfiguration {
this.soTimeout = soTimeout;
this.connectTimeout = connectTimeout;
this.hostnameVerifier = hostnameVerifier;
this.proxy = proxy;
}
/*
@@ -120,4 +123,12 @@ class DefaultClientConfiguration implements ClientConfiguration {
return this.soTimeout;
}
/*
* (non-Javadoc)
* @see org.springframework.data.elasticsearch.client.ClientConfiguration#getProxy()
*/
@Override
public Optional<String> getProxy() {
return Optional.ofNullable(proxy);
}
}
@@ -118,6 +118,8 @@ public final class RestClients {
clientBuilder.setDefaultRequestConfig(requestConfigBuilder.build());
clientConfiguration.getProxy().map(HttpHost::create).ifPresent(clientBuilder::setProxy);
return clientBuilder;
});
@@ -598,6 +598,7 @@ public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate
if (elasticsearchQuery != null) {
sourceBuilder.query(elasticsearchQuery);
}
sourceBuilder.size(0);
countRequest.source(sourceBuilder);
try {
@@ -616,6 +617,7 @@ public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate
if (elasticsearchFilter != null) {
searchRequest.source().postFilter(elasticsearchFilter);
}
searchRequest.source().size(0);
SearchResponse response;
try {
response = client.search(searchRequest, RequestOptions.DEFAULT);
@@ -508,6 +508,7 @@ public class ElasticsearchTemplate extends AbstractElasticsearchTemplate
if (elasticsearchQuery != null) {
countRequestBuilder.setQuery(elasticsearchQuery);
}
countRequestBuilder.setSize(0);
return countRequestBuilder.execute().actionGet().getHits().getTotalHits();
}
@@ -521,6 +522,7 @@ public class ElasticsearchTemplate extends AbstractElasticsearchTemplate
if (elasticsearchFilter != null) {
searchRequestBuilder.setPostFilter(elasticsearchFilter);
}
searchRequestBuilder.setSize(0);
return searchRequestBuilder.execute().actionGet().getHits().getTotalHits();
}
+14
View File
@@ -1,6 +1,18 @@
Spring Data Elasticsearch Changelog
===================================
Changes in version 3.2.3.RELEASE (2019-12-04)
---------------------------------------------
* DATAES-700 - Enable proxy support for RestClient.
* DATAES-699 - ElasticsearchRestTemplate.count(..) returns all documents instead of just total hits number.
* DATAES-692 - Release 3.2.3 (Moore SR3).
Changes in version 3.1.14.RELEASE (2019-12-04)
----------------------------------------------
* DATAES-691 - Release 3.1.14 (Lovelace SR14).
Changes in version 3.2.2.RELEASE (2019-11-18)
---------------------------------------------
* DATAES-685 - Release 3.2.2 (Moore SR2).
@@ -910,3 +922,5 @@ Release Notes - Spring Data Elasticsearch - Version 1.0 M1 (2014-02-07)
* #8 - java.lang.NoSuchMethodError: org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty.isVersionProperty()Z
* #7 - Missing core types in org.springframework.data.elasticsearch.annotations.FieldType
* #6 - spirng-data-elasticsearch with elasticsearch-river-mongodb
+2 -1
View File
@@ -1,4 +1,4 @@
Spring Data Elasticsearch 3.2.2
Spring Data Elasticsearch 3.2.3
Copyright (c) [2013-2019] Pivotal Software, Inc.
This product is licensed to you under the Apache License, Version 2.0 (the "License").
@@ -8,3 +8,4 @@ This product may include a number of subcomponents with
separate copyright notices and license terms. Your use of the source
code for the these subcomponents is subject to the terms and
conditions of the subcomponent's license, as noted in the LICENSE file.
@@ -44,7 +44,7 @@ public class ClientConfigurationUnitTests {
assertThat(clientConfiguration.getEndpoints()).containsOnly(InetSocketAddress.createUnresolved("localhost", 9200));
}
@Test // DATAES-488, DATAES-504
@Test // DATAES-488, DATAES-504, DATAES-650, DATAES-700
public void shouldCreateCustomizedConfiguration() {
HttpHeaders headers = new HttpHeaders();
@@ -54,7 +54,8 @@ public class ClientConfigurationUnitTests {
.connectedTo("foo", "bar") //
.usingSsl() //
.withDefaultHeaders(headers) //
.withConnectTimeout(Duration.ofDays(1)).withSocketTimeout(Duration.ofDays(2)).build();
.withConnectTimeout(Duration.ofDays(1)).withSocketTimeout(Duration.ofDays(2)) //
.withProxy("localhost:8080").build();
assertThat(clientConfiguration.getEndpoints()).containsOnly(InetSocketAddress.createUnresolved("foo", 9200),
InetSocketAddress.createUnresolved("bar", 9200));
@@ -62,6 +63,7 @@ public class ClientConfigurationUnitTests {
assertThat(clientConfiguration.getDefaultHeaders().get("foo")).containsOnly("bar");
assertThat(clientConfiguration.getConnectTimeout()).isEqualTo(Duration.ofDays(1));
assertThat(clientConfiguration.getSocketTimeout()).isEqualTo(Duration.ofDays(2));
assertThat(clientConfiguration.getProxy()).contains("localhost:8080");
}
@Test // DATAES-488, DATAES-504
@@ -0,0 +1,48 @@
package org.springframework.data.elasticsearch.client;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
import java.io.IOException;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.client.WireMock;
import org.junit.Test;
/**
* @author Peter-Josef Meisch
*/
public class RestClientsTest {
@Test
// DATAES-700
public void shouldUseConfiguredProxy() throws IOException {
WireMockServer wireMockServer = new WireMockServer(options() //
.dynamicPort() //
.usingFilesUnderDirectory("src/test/resources/wiremock-mappings")); // needed, otherwise Wiremock goes to
// test/resources/mappings
wireMockServer.start();
try {
WireMock.configureFor(wireMockServer.port());
ClientConfigurationBuilder configurationBuilder = new ClientConfigurationBuilder();
ClientConfiguration clientConfiguration = configurationBuilder //
.connectedTo("localhost:9200")//
.withProxy("localhost:" + wireMockServer.port()) //
.build();
RestHighLevelClient restClient = RestClients.create(clientConfiguration).rest();
restClient.ping(RequestOptions.DEFAULT);
verify(headRequestedFor(urlEqualTo("/")));
} finally {
wireMockServer.shutdown();
}
}
}