Skip to content

Commit aad650a

Browse files
committed
Merge remote-tracking branch 'elastic/master' into global-checkpoint-listeners
* elastic/master: Watcher: Remove unused hipchat render method (elastic#32211) Watcher: Remove extraneous auth classes (elastic#32300) Watcher: migrate PagerDuty v1 events API to v2 API (elastic#32285) [TEST] Select free port for Minio (elastic#32837) MINOR: Remove `IndexTemplateFilter` (elastic#32841) Core: Add java time version of rounding classes (elastic#32641) Aggregations/HL Rest client fix: missing scores (elastic#32774) HLRC: Add Delete License API (elastic#32586) INGEST: Create Index Before Pipeline Execute (elastic#32786) Fix NOOP bulk updates (elastic#32819) Remove client connections from TcpTransport (elastic#31886) Increase logging testRetentionPolicyChangeDuringRecovery AwaitsFix case-functions.sql-spec Mute security-cli tests in FIPS JVM (elastic#32812) SCRIPTING: Support BucketAggScript return null (elastic#32811) Unmute WildFly tests in FIPS JVM (elastic#32814) [TEST] Force a stop to save rollup state before continuing (elastic#32787) [test] disable packaging tests for suse boxes Mute IndicesRequestIT#testBulk [ML][DOCS] Refer to rules feature as custom rules (elastic#32785)
2 parents 88dee76 + 6fde9e5 commit aad650a

File tree

137 files changed

+3923
-1903
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+3923
-1903
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy

+10-2
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,11 @@ class VagrantTestPlugin implements Plugin<Project> {
526526
project.gradle.removeListener(batsPackagingReproListener)
527527
}
528528
if (project.extensions.esvagrant.boxes.contains(box)) {
529-
packagingTest.dependsOn(batsPackagingTest)
529+
// these tests are temporarily disabled for suse boxes while we debug an issue
530+
// https://github.com/elastic/elasticsearch/issues/30295
531+
if (box.equals("opensuse-42") == false && box.equals("sles-12") == false) {
532+
packagingTest.dependsOn(batsPackagingTest)
533+
}
530534
}
531535
}
532536

@@ -565,7 +569,11 @@ class VagrantTestPlugin implements Plugin<Project> {
565569
project.gradle.removeListener(javaPackagingReproListener)
566570
}
567571
if (project.extensions.esvagrant.boxes.contains(box)) {
568-
packagingTest.dependsOn(javaPackagingTest)
572+
// these tests are temporarily disabled for suse boxes while we debug an issue
573+
// https://github.com/elastic/elasticsearch/issues/30295
574+
if (box.equals("opensuse-42") == false && box.equals("sles-12") == false) {
575+
packagingTest.dependsOn(javaPackagingTest)
576+
}
569577
}
570578

571579
/*

client/rest-high-level/src/main/java/org/elasticsearch/client/LicenseClient.java

+23
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import org.elasticsearch.common.xcontent.XContentFactory;
3030
import org.elasticsearch.common.xcontent.XContentParser;
3131
import org.elasticsearch.common.xcontent.XContentType;
32+
import org.elasticsearch.protocol.xpack.license.DeleteLicenseRequest;
33+
import org.elasticsearch.protocol.xpack.license.DeleteLicenseResponse;
3234
import org.elasticsearch.protocol.xpack.license.GetLicenseRequest;
3335
import org.elasticsearch.protocol.xpack.license.GetLicenseResponse;
3436
import org.elasticsearch.protocol.xpack.license.PutLicenseRequest;
@@ -98,6 +100,27 @@ public void getLicenseAsync(GetLicenseRequest request, RequestOptions options, A
98100
response -> new GetLicenseResponse(convertResponseToJson(response)), listener, emptySet());
99101
}
100102

103+
/**
104+
* Deletes license from the cluster.
105+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
106+
* @return the response
107+
* @throws IOException in case there is a problem sending the request or parsing back the response
108+
*/
109+
public DeleteLicenseResponse deleteLicense(DeleteLicenseRequest request, RequestOptions options) throws IOException {
110+
return restHighLevelClient.performRequestAndParseEntity(request, RequestConverters::deleteLicense, options,
111+
DeleteLicenseResponse::fromXContent, emptySet());
112+
}
113+
114+
/**
115+
* Asynchronously deletes license from the cluster.
116+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
117+
* @param listener the listener to be notified upon request completion
118+
*/
119+
public void deleteLicenseAsync(DeleteLicenseRequest request, RequestOptions options, ActionListener<DeleteLicenseResponse> listener) {
120+
restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::deleteLicense, options,
121+
DeleteLicenseResponse::fromXContent, listener, emptySet());
122+
}
123+
101124
/**
102125
* Converts an entire response into a json string
103126
*

client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
import org.elasticsearch.index.rankeval.RankEvalRequest;
109109
import org.elasticsearch.protocol.xpack.XPackInfoRequest;
110110
import org.elasticsearch.protocol.xpack.XPackUsageRequest;
111+
import org.elasticsearch.protocol.xpack.license.DeleteLicenseRequest;
111112
import org.elasticsearch.protocol.xpack.license.GetLicenseRequest;
112113
import org.elasticsearch.protocol.xpack.license.PutLicenseRequest;
113114
import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoRequest;
@@ -1178,7 +1179,6 @@ static Request putLicense(PutLicenseRequest putLicenseRequest) {
11781179
return request;
11791180
}
11801181

1181-
11821182
static Request getLicense(GetLicenseRequest getLicenseRequest) {
11831183
String endpoint = new EndpointBuilder()
11841184
.addPathPartAsIs("_xpack")
@@ -1190,6 +1190,14 @@ static Request getLicense(GetLicenseRequest getLicenseRequest) {
11901190
return request;
11911191
}
11921192

1193+
static Request deleteLicense(DeleteLicenseRequest deleteLicenseRequest) {
1194+
Request request = new Request(HttpDelete.METHOD_NAME, "/_xpack/license");
1195+
Params parameters = new Params(request);
1196+
parameters.withTimeout(deleteLicenseRequest.timeout());
1197+
parameters.withMasterTimeout(deleteLicenseRequest.masterNodeTimeout());
1198+
return request;
1199+
}
1200+
11931201
static Request putMachineLearningJob(PutJobRequest putJobRequest) throws IOException {
11941202
String endpoint = new EndpointBuilder()
11951203
.addPathPartAsIs("_xpack")

client/rest-high-level/src/test/java/org/elasticsearch/client/SearchIT.java

+30
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
import org.elasticsearch.search.aggregations.BucketOrder;
6060
import org.elasticsearch.search.aggregations.bucket.range.Range;
6161
import org.elasticsearch.search.aggregations.bucket.range.RangeAggregationBuilder;
62+
import org.elasticsearch.search.aggregations.bucket.significant.SignificantTerms;
63+
import org.elasticsearch.search.aggregations.bucket.significant.SignificantTermsAggregationBuilder;
64+
import org.elasticsearch.search.aggregations.bucket.significant.heuristics.PercentageScore;
6265
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
6366
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
6467
import org.elasticsearch.search.aggregations.matrix.stats.MatrixStats;
@@ -267,6 +270,33 @@ public void testSearchWithTermsAgg() throws IOException {
267270
assertEquals(2, type2.getDocCount());
268271
assertEquals(0, type2.getAggregations().asList().size());
269272
}
273+
274+
public void testSearchWithSignificantTermsAgg() throws IOException {
275+
SearchRequest searchRequest = new SearchRequest();
276+
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
277+
searchSourceBuilder.query(new MatchQueryBuilder("num","50"));
278+
searchSourceBuilder.aggregation(new SignificantTermsAggregationBuilder("agg1", ValueType.STRING)
279+
.field("type.keyword")
280+
.minDocCount(1)
281+
.significanceHeuristic(new PercentageScore()));
282+
searchSourceBuilder.size(0);
283+
searchRequest.source(searchSourceBuilder);
284+
SearchResponse searchResponse = execute(searchRequest, highLevelClient()::search, highLevelClient()::searchAsync);
285+
assertSearchHeader(searchResponse);
286+
assertNull(searchResponse.getSuggest());
287+
assertEquals(Collections.emptyMap(), searchResponse.getProfileResults());
288+
assertEquals(0, searchResponse.getHits().getHits().length);
289+
assertEquals(0f, searchResponse.getHits().getMaxScore(), 0f);
290+
SignificantTerms significantTermsAgg = searchResponse.getAggregations().get("agg1");
291+
assertEquals("agg1", significantTermsAgg.getName());
292+
assertEquals(1, significantTermsAgg.getBuckets().size());
293+
SignificantTerms.Bucket type1 = significantTermsAgg.getBucketByKey("type1");
294+
assertEquals(1, type1.getDocCount());
295+
assertEquals(1, type1.getSubsetDf());
296+
assertEquals(1, type1.getSubsetSize());
297+
assertEquals(3, type1.getSupersetDf());
298+
assertEquals(1d/3d, type1.getSignificanceScore(), 0d);
299+
}
270300

271301
public void testSearchWithRangeAgg() throws IOException {
272302
{

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/LicensingDocumentationIT.java

+50-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
import org.elasticsearch.client.ESRestHighLevelClientTestCase;
2626
import org.elasticsearch.client.RequestOptions;
2727
import org.elasticsearch.client.RestHighLevelClient;
28+
import org.elasticsearch.common.Booleans;
29+
import org.elasticsearch.protocol.xpack.license.DeleteLicenseRequest;
30+
import org.elasticsearch.protocol.xpack.license.DeleteLicenseResponse;
2831
import org.elasticsearch.protocol.xpack.license.GetLicenseRequest;
2932
import org.elasticsearch.protocol.xpack.license.GetLicenseResponse;
3033
import org.elasticsearch.protocol.xpack.license.LicensesStatus;
@@ -47,7 +50,7 @@
4750
*/
4851
public class LicensingDocumentationIT extends ESRestHighLevelClientTestCase {
4952

50-
public void testPutLicense() throws Exception {
53+
public void testLicense() throws Exception {
5154
assumeTrue("License is only valid when tested against snapshot/test builds", Build.CURRENT.isSnapshot());
5255
RestHighLevelClient client = highLevelClient();
5356
String license = "{\"license\": {\"uid\":\"893361dc-9749-4997-93cb-802e3d7fa4a8\",\"type\":\"gold\"," +
@@ -86,7 +89,7 @@ public void testPutLicense() throws Exception {
8689
// tag::put-license-execute-listener
8790
ActionListener<PutLicenseResponse> listener = new ActionListener<PutLicenseResponse>() {
8891
@Override
89-
public void onResponse(PutLicenseResponse indexResponse) {
92+
public void onResponse(PutLicenseResponse putLicenseResponse) {
9093
// <1>
9194
}
9295

@@ -108,6 +111,51 @@ public void onFailure(Exception e) {
108111

109112
assertTrue(latch.await(30L, TimeUnit.SECONDS));
110113
}
114+
115+
// we cannot actually delete the license, otherwise the remaining tests won't work
116+
if (Booleans.isTrue("true")) {
117+
return;
118+
}
119+
{
120+
//tag::delete-license-execute
121+
DeleteLicenseRequest request = new DeleteLicenseRequest();
122+
123+
DeleteLicenseResponse response = client.license().deleteLicense(request, RequestOptions.DEFAULT);
124+
//end::delete-license-execute
125+
126+
//tag::delete-license-response
127+
boolean acknowledged = response.isAcknowledged(); // <1>
128+
//end::delete-license-response
129+
130+
assertTrue(acknowledged);
131+
}
132+
{
133+
DeleteLicenseRequest request = new DeleteLicenseRequest();
134+
// tag::delete-license-execute-listener
135+
ActionListener<DeleteLicenseResponse> listener = new ActionListener<DeleteLicenseResponse>() {
136+
@Override
137+
public void onResponse(DeleteLicenseResponse deleteLicenseResponse) {
138+
// <1>
139+
}
140+
141+
@Override
142+
public void onFailure(Exception e) {
143+
// <2>
144+
}
145+
};
146+
// end::delete-license-execute-listener
147+
148+
// Replace the empty listener by a blocking listener in test
149+
final CountDownLatch latch = new CountDownLatch(1);
150+
listener = new LatchedActionListener<>(listener, latch);
151+
152+
// tag::delete-license-execute-async
153+
client.license().deleteLicenseAsync(
154+
request, RequestOptions.DEFAULT, listener); // <1>
155+
// end::delete-license-execute-async
156+
157+
assertTrue(latch.await(30L, TimeUnit.SECONDS));
158+
}
111159
}
112160

113161
public void testGetLicense() throws Exception {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[[java-rest-high-delete-license]]
2+
=== Delete License
3+
4+
[[java-rest-high-delete-license-execution]]
5+
==== Execution
6+
7+
The license can be deleted using the `deleteLicense()` method:
8+
9+
["source","java",subs="attributes,callouts,macros"]
10+
--------------------------------------------------
11+
include-tagged::{doc-tests}/LicensingDocumentationIT.java[delete-license-execute]
12+
--------------------------------------------------
13+
14+
[[java-rest-high-delete-license-response]]
15+
==== Response
16+
17+
The returned `DeleteLicenseResponse` contains the `acknowledged` flag, which
18+
returns true if the request was processed by all nodes.
19+
20+
["source","java",subs="attributes,callouts,macros"]
21+
--------------------------------------------------
22+
include-tagged::{doc-tests}/LicensingDocumentationIT.java[delete-license-response]
23+
--------------------------------------------------
24+
<1> Check the acknowledge flag. It should be true if license deletion is acknowledged.
25+
26+
[[java-rest-high-delete-license-async]]
27+
==== Asynchronous Execution
28+
29+
This request can be executed asynchronously:
30+
31+
["source","java",subs="attributes,callouts,macros"]
32+
--------------------------------------------------
33+
include-tagged::{doc-tests}/LicensingDocumentationIT.java[delete-license-execute-async]
34+
--------------------------------------------------
35+
<1> The `DeleteLicenseRequest` to execute and the `ActionListener` to use when
36+
the execution completes
37+
38+
The asynchronous method does not block and returns immediately. Once it is
39+
completed the `ActionListener` is called back using the `onResponse` method
40+
if the execution successfully completed or using the `onFailure` method if
41+
it failed.
42+
43+
A typical listener for `DeleteLicenseResponse` looks like:
44+
45+
["source","java",subs="attributes,callouts,macros"]
46+
--------------------------------------------------
47+
include-tagged::{doc-tests}/LicensingDocumentationIT.java[delete-license-execute-listener]
48+
--------------------------------------------------
49+
<1> Called when the execution is successfully completed. The response is
50+
provided as an argument
51+
<2> Called in case of failure. The raised exception is provided as an argument

docs/java-rest/high-level/supported-apis.asciidoc

+2
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,11 @@ The Java High Level REST Client supports the following Licensing APIs:
194194

195195
* <<java-rest-high-put-license>>
196196
* <<java-rest-high-get-license>>
197+
* <<java-rest-high-delete-license>>
197198

198199
include::licensing/put-license.asciidoc[]
199200
include::licensing/get-license.asciidoc[]
201+
include::licensing/delete-license.asciidoc[]
200202

201203
== Migration APIs
202204

modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionScriptEngine.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private static BucketAggregationScript.Factory newBucketAggregationScriptFactory
147147
}
148148
return new BucketAggregationScript(parameters) {
149149
@Override
150-
public double execute() {
150+
public Double execute() {
151151
getParams().forEach((name, value) -> {
152152
ReplaceableConstDoubleValues placeholder = functionValuesMap.get(name);
153153
if (placeholder == null) {

modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4Transport.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,12 @@ protected Netty4TcpServerChannel bind(String name, InetSocketAddress address) {
267267
return esChannel;
268268
}
269269

270-
ScheduledPing getPing() {
271-
return scheduledPing;
270+
long successfulPingCount() {
271+
return successfulPings.count();
272+
}
273+
274+
long failedPingCount() {
275+
return failedPings.count();
272276
}
273277

274278
@Override

modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4ScheduledPingTests.java

+14-20
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,13 @@
2626
import org.elasticsearch.common.util.BigArrays;
2727
import org.elasticsearch.indices.breaker.CircuitBreakerService;
2828
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
29-
import org.elasticsearch.tasks.Task;
3029
import org.elasticsearch.test.ESTestCase;
3130
import org.elasticsearch.test.transport.MockTransportService;
3231
import org.elasticsearch.threadpool.TestThreadPool;
3332
import org.elasticsearch.threadpool.ThreadPool;
3433
import org.elasticsearch.transport.TcpTransport;
35-
import org.elasticsearch.transport.TransportChannel;
3634
import org.elasticsearch.transport.TransportException;
3735
import org.elasticsearch.transport.TransportRequest;
38-
import org.elasticsearch.transport.TransportRequestHandler;
3936
import org.elasticsearch.transport.TransportRequestOptions;
4037
import org.elasticsearch.transport.TransportResponse;
4138
import org.elasticsearch.transport.TransportResponseHandler;
@@ -83,22 +80,19 @@ public void testScheduledPing() throws Exception {
8380
serviceB.connectToNode(nodeA);
8481

8582
assertBusy(() -> {
86-
assertThat(nettyA.getPing().getSuccessfulPings(), greaterThan(100L));
87-
assertThat(nettyB.getPing().getSuccessfulPings(), greaterThan(100L));
83+
assertThat(nettyA.successfulPingCount(), greaterThan(100L));
84+
assertThat(nettyB.successfulPingCount(), greaterThan(100L));
8885
});
89-
assertThat(nettyA.getPing().getFailedPings(), equalTo(0L));
90-
assertThat(nettyB.getPing().getFailedPings(), equalTo(0L));
86+
assertThat(nettyA.failedPingCount(), equalTo(0L));
87+
assertThat(nettyB.failedPingCount(), equalTo(0L));
9188

9289
serviceA.registerRequestHandler("internal:sayHello", TransportRequest.Empty::new, ThreadPool.Names.GENERIC,
93-
new TransportRequestHandler<TransportRequest.Empty>() {
94-
@Override
95-
public void messageReceived(TransportRequest.Empty request, TransportChannel channel, Task task) {
96-
try {
97-
channel.sendResponse(TransportResponse.Empty.INSTANCE, TransportResponseOptions.EMPTY);
98-
} catch (IOException e) {
99-
logger.error("Unexpected failure", e);
100-
fail(e.getMessage());
101-
}
90+
(request, channel, task) -> {
91+
try {
92+
channel.sendResponse(TransportResponse.Empty.INSTANCE, TransportResponseOptions.EMPTY);
93+
} catch (IOException e) {
94+
logger.error("Unexpected failure", e);
95+
fail(e.getMessage());
10296
}
10397
});
10498

@@ -130,11 +124,11 @@ public void handleException(TransportException exp) {
130124
}
131125

132126
assertBusy(() -> {
133-
assertThat(nettyA.getPing().getSuccessfulPings(), greaterThan(200L));
134-
assertThat(nettyB.getPing().getSuccessfulPings(), greaterThan(200L));
127+
assertThat(nettyA.successfulPingCount(), greaterThan(200L));
128+
assertThat(nettyB.successfulPingCount(), greaterThan(200L));
135129
});
136-
assertThat(nettyA.getPing().getFailedPings(), equalTo(0L));
137-
assertThat(nettyB.getPing().getFailedPings(), equalTo(0L));
130+
assertThat(nettyA.failedPingCount(), equalTo(0L));
131+
assertThat(nettyB.failedPingCount(), equalTo(0L));
138132

139133
Releasables.close(serviceA, serviceB);
140134
terminate(threadPool);

0 commit comments

Comments
 (0)