Skip to content

Commit a956a9b

Browse files
committed
Merge branch 'ccr' into ccr-stats
* ccr: (24 commits) Remove _xpack from CCR APIs (elastic#32563) TEST: Avoid merges in testRecoveryWithOutOfOrderDelete Logging: Make node name consistent in logger (elastic#31588) Mute SSLTrustRestrictionsTests on JDK 11 Increase max chunk size to 256Mb for repo-azure (elastic#32101) Docs: Fix README upgrade mention (elastic#32313) Changed ReindexRequest to use Writeable.Reader (elastic#32401) Mute KerberosAuthenticationIT Fix AutoIntervalDateHistogram.testReduce random failures (elastic#32301) fix no=>not typo (elastic#32463) Mute QueryProfilerIT#testProfileMatchesRegular() HLRC: Add delete watch action (elastic#32337) High-level client: fix clusterAlias parsing in SearchHit (elastic#32465) Fix calculation of orientation of polygons (elastic#27967) [Kerberos] Add missing javadocs (elastic#32469) [Kerberos] Remove Kerberos bootstrap checks (elastic#32451) Make get all app privs requires "*" permission (elastic#32460) Switch security to new style Requests (elastic#32290) Switch security spi example to new style Requests (elastic#32341) Painless: Add PainlessConstructor (elastic#32447) ...
2 parents 0de7ccb + 2387616 commit a956a9b

File tree

144 files changed

+2296
-856
lines changed

Some content is hidden

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

144 files changed

+2296
-856
lines changed

README.textile

+2-6
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,6 @@ The distribution for each project will be created under the @build/distributions
209209

210210
See the "TESTING":TESTING.asciidoc file for more information about running the Elasticsearch test suite.
211211

212-
h3. Upgrading from Elasticsearch 1.x?
212+
h3. Upgrading from older Elasticsearch versions
213213

214-
In order to ensure a smooth upgrade process from earlier versions of
215-
Elasticsearch (1.x), it is required to perform a full cluster restart. Please
216-
see the "setup reference":
217-
https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-upgrade.html
218-
for more details on the upgrade process.
214+
In order to ensure a smooth upgrade process from earlier versions of Elasticsearch, please see our "upgrade documentation":https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-upgrade.html for more details on the upgrade process.

benchmarks/src/main/resources/log4j2.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
appender.console.type = Console
22
appender.console.name = console
33
appender.console.layout.type = PatternLayout
4-
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%m%n
4+
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c] [%node_name]%marker %m%n
55

66
# Do not log at all if it is not really critical - we're in a benchmark
77
rootLogger.level = error
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
appender.console.type = Console
22
appender.console.name = console
33
appender.console.layout.type = PatternLayout
4-
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%m%n
4+
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c] [%node_name]%marker %m%n
55

66
rootLogger.level = info
77
rootLogger.appenderRef.console.ref = console

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

+13
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
import org.elasticsearch.index.VersionType;
108108
import org.elasticsearch.index.rankeval.RankEvalRequest;
109109
import org.elasticsearch.protocol.xpack.XPackInfoRequest;
110+
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
110111
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
111112
import org.elasticsearch.protocol.xpack.XPackUsageRequest;
112113
import org.elasticsearch.protocol.xpack.license.PutLicenseRequest;
@@ -1133,6 +1134,18 @@ static Request xPackWatcherPutWatch(PutWatchRequest putWatchRequest) {
11331134
return request;
11341135
}
11351136

1137+
static Request xPackWatcherDeleteWatch(DeleteWatchRequest deleteWatchRequest) {
1138+
String endpoint = new EndpointBuilder()
1139+
.addPathPartAsIs("_xpack")
1140+
.addPathPartAsIs("watcher")
1141+
.addPathPartAsIs("watch")
1142+
.addPathPart(deleteWatchRequest.getId())
1143+
.build();
1144+
1145+
Request request = new Request(HttpDelete.METHOD_NAME, endpoint);
1146+
return request;
1147+
}
1148+
11361149
static Request xpackUsage(XPackUsageRequest usageRequest) {
11371150
Request request = new Request(HttpGet.METHOD_NAME, "/_xpack/usage");
11381151
Params parameters = new Params(request);

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

+30
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
package org.elasticsearch.client;
2020

2121
import org.elasticsearch.action.ActionListener;
22+
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
23+
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchResponse;
2224
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
2325
import org.elasticsearch.protocol.xpack.watcher.PutWatchResponse;
2426

2527
import java.io.IOException;
2628

2729
import static java.util.Collections.emptySet;
30+
import static java.util.Collections.singleton;
2831

2932
public final class WatcherClient {
3033

@@ -61,4 +64,31 @@ public void putWatchAsync(PutWatchRequest request, RequestOptions options,
6164
restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::xPackWatcherPutWatch, options,
6265
PutWatchResponse::fromXContent, listener, emptySet());
6366
}
67+
68+
/**
69+
* Deletes a watch from the cluster
70+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-delete-watch.html">
71+
* the docs</a> for more.
72+
* @param request the request
73+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
74+
* @return the response
75+
* @throws IOException in case there is a problem sending the request or parsing back the response
76+
*/
77+
public DeleteWatchResponse deleteWatch(DeleteWatchRequest request, RequestOptions options) throws IOException {
78+
return restHighLevelClient.performRequestAndParseEntity(request, RequestConverters::xPackWatcherDeleteWatch, options,
79+
DeleteWatchResponse::fromXContent, singleton(404));
80+
}
81+
82+
/**
83+
* Asynchronously deletes a watch from the cluster
84+
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-delete-watch.html">
85+
* the docs</a> for more.
86+
* @param request the request
87+
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
88+
* @param listener the listener to be notified upon request completion
89+
*/
90+
public void deleteWatchAsync(DeleteWatchRequest request, RequestOptions options, ActionListener<DeleteWatchResponse> listener) {
91+
restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::xPackWatcherDeleteWatch, options,
92+
DeleteWatchResponse::fromXContent, listener, singleton(404));
93+
}
6494
}

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

+12
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
import org.elasticsearch.index.rankeval.RatedRequest;
127127
import org.elasticsearch.index.rankeval.RestRankEvalAction;
128128
import org.elasticsearch.protocol.xpack.XPackInfoRequest;
129+
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
129130
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
130131
import org.elasticsearch.repositories.fs.FsRepository;
131132
import org.elasticsearch.rest.action.search.RestSearchAction;
@@ -2580,6 +2581,17 @@ public void testXPackPutWatch() throws Exception {
25802581
assertThat(bos.toString("UTF-8"), is(body));
25812582
}
25822583

2584+
public void testXPackDeleteWatch() {
2585+
DeleteWatchRequest deleteWatchRequest = new DeleteWatchRequest();
2586+
String watchId = randomAlphaOfLength(10);
2587+
deleteWatchRequest.setId(watchId);
2588+
2589+
Request request = RequestConverters.xPackWatcherDeleteWatch(deleteWatchRequest);
2590+
assertEquals(HttpDelete.METHOD_NAME, request.getMethod());
2591+
assertEquals("/_xpack/watcher/watch/" + watchId, request.getEndpoint());
2592+
assertThat(request.getEntity(), nullValue());
2593+
}
2594+
25832595
/**
25842596
* Randomize the {@link FetchSourceContext} request parameters.
25852597
*/

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

+33-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import org.elasticsearch.common.bytes.BytesArray;
2222
import org.elasticsearch.common.bytes.BytesReference;
2323
import org.elasticsearch.common.xcontent.XContentType;
24+
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
25+
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchResponse;
2426
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
2527
import org.elasticsearch.protocol.xpack.watcher.PutWatchResponse;
2628

@@ -30,17 +32,44 @@ public class WatcherIT extends ESRestHighLevelClientTestCase {
3032

3133
public void testPutWatch() throws Exception {
3234
String watchId = randomAlphaOfLength(10);
35+
PutWatchResponse putWatchResponse = createWatch(watchId);
36+
assertThat(putWatchResponse.isCreated(), is(true));
37+
assertThat(putWatchResponse.getId(), is(watchId));
38+
assertThat(putWatchResponse.getVersion(), is(1L));
39+
}
40+
41+
private PutWatchResponse createWatch(String watchId) throws Exception {
3342
String json = "{ \n" +
3443
" \"trigger\": { \"schedule\": { \"interval\": \"10h\" } },\n" +
3544
" \"input\": { \"none\": {} },\n" +
3645
" \"actions\": { \"logme\": { \"logging\": { \"text\": \"{{ctx.payload}}\" } } }\n" +
3746
"}";
3847
BytesReference bytesReference = new BytesArray(json);
3948
PutWatchRequest putWatchRequest = new PutWatchRequest(watchId, bytesReference, XContentType.JSON);
40-
PutWatchResponse putWatchResponse = highLevelClient().xpack().watcher().putWatch(putWatchRequest, RequestOptions.DEFAULT);
41-
assertThat(putWatchResponse.isCreated(), is(true));
42-
assertThat(putWatchResponse.getId(), is(watchId));
43-
assertThat(putWatchResponse.getVersion(), is(1L));
49+
return highLevelClient().xpack().watcher().putWatch(putWatchRequest, RequestOptions.DEFAULT);
50+
}
51+
52+
public void testDeleteWatch() throws Exception {
53+
// delete watch that exists
54+
{
55+
String watchId = randomAlphaOfLength(10);
56+
createWatch(watchId);
57+
DeleteWatchResponse deleteWatchResponse = highLevelClient().xpack().watcher().deleteWatch(new DeleteWatchRequest(watchId),
58+
RequestOptions.DEFAULT);
59+
assertThat(deleteWatchResponse.getId(), is(watchId));
60+
assertThat(deleteWatchResponse.getVersion(), is(2L));
61+
assertThat(deleteWatchResponse.isFound(), is(true));
62+
}
63+
64+
// delete watch that does not exist
65+
{
66+
String watchId = randomAlphaOfLength(10);
67+
DeleteWatchResponse deleteWatchResponse = highLevelClient().xpack().watcher().deleteWatch(new DeleteWatchRequest(watchId),
68+
RequestOptions.DEFAULT);
69+
assertThat(deleteWatchResponse.getId(), is(watchId));
70+
assertThat(deleteWatchResponse.getVersion(), is(1L));
71+
assertThat(deleteWatchResponse.isFound(), is(false));
72+
}
4473
}
4574

4675
}

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

+44-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import org.elasticsearch.common.bytes.BytesArray;
2727
import org.elasticsearch.common.bytes.BytesReference;
2828
import org.elasticsearch.common.xcontent.XContentType;
29+
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
30+
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchResponse;
2931
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
3032
import org.elasticsearch.protocol.xpack.watcher.PutWatchResponse;
3133

@@ -34,7 +36,7 @@
3436

3537
public class WatcherDocumentationIT extends ESRestHighLevelClientTestCase {
3638

37-
public void testPutWatch() throws Exception {
39+
public void testWatcher() throws Exception {
3840
RestHighLevelClient client = highLevelClient();
3941

4042
{
@@ -88,5 +90,46 @@ public void onFailure(Exception e) {
8890

8991
assertTrue(latch.await(30L, TimeUnit.SECONDS));
9092
}
93+
94+
{
95+
//tag::x-pack-delete-watch-execute
96+
DeleteWatchRequest request = new DeleteWatchRequest("my_watch_id");
97+
DeleteWatchResponse response = client.xpack().watcher().deleteWatch(request, RequestOptions.DEFAULT);
98+
//end::x-pack-delete-watch-execute
99+
100+
//tag::x-pack-delete-watch-response
101+
String watchId = response.getId(); // <1>
102+
boolean found = response.isFound(); // <2>
103+
long version = response.getVersion(); // <3>
104+
//end::x-pack-delete-watch-response
105+
}
106+
107+
{
108+
DeleteWatchRequest request = new DeleteWatchRequest("my_other_watch_id");
109+
// tag::x-pack-delete-watch-execute-listener
110+
ActionListener<DeleteWatchResponse> listener = new ActionListener<DeleteWatchResponse>() {
111+
@Override
112+
public void onResponse(DeleteWatchResponse response) {
113+
// <1>
114+
}
115+
116+
@Override
117+
public void onFailure(Exception e) {
118+
// <2>
119+
}
120+
};
121+
// end::x-pack-delete-watch-execute-listener
122+
123+
// Replace the empty listener by a blocking listener in test
124+
final CountDownLatch latch = new CountDownLatch(1);
125+
listener = new LatchedActionListener<>(listener, latch);
126+
127+
// tag::x-pack-delete-watch-execute-async
128+
client.xpack().watcher().deleteWatchAsync(request, RequestOptions.DEFAULT, listener); // <1>
129+
// end::x-pack-delete-watch-execute-async
130+
131+
assertTrue(latch.await(30L, TimeUnit.SECONDS));
132+
}
91133
}
134+
92135
}

distribution/src/config/log4j2.properties

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ logger.action.level = debug
77
appender.console.type = Console
88
appender.console.name = console
99
appender.console.layout.type = PatternLayout
10-
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n
10+
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker %m%n
1111

1212
appender.rolling.type = RollingFile
1313
appender.rolling.name = rolling
1414
appender.rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}.log
1515
appender.rolling.layout.type = PatternLayout
16-
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n
16+
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker %.-10000m%n
1717
appender.rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}-%d{yyyy-MM-dd}-%i.log.gz
1818
appender.rolling.policies.type = Policies
1919
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
@@ -38,7 +38,7 @@ appender.deprecation_rolling.type = RollingFile
3838
appender.deprecation_rolling.name = deprecation_rolling
3939
appender.deprecation_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_deprecation.log
4040
appender.deprecation_rolling.layout.type = PatternLayout
41-
appender.deprecation_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n
41+
appender.deprecation_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker %.-10000m%n
4242
appender.deprecation_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_deprecation-%i.log.gz
4343
appender.deprecation_rolling.policies.type = Policies
4444
appender.deprecation_rolling.policies.size.type = SizeBasedTriggeringPolicy
@@ -55,7 +55,7 @@ appender.index_search_slowlog_rolling.type = RollingFile
5555
appender.index_search_slowlog_rolling.name = index_search_slowlog_rolling
5656
appender.index_search_slowlog_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_search_slowlog.log
5757
appender.index_search_slowlog_rolling.layout.type = PatternLayout
58-
appender.index_search_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.-10000m%n
58+
appender.index_search_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] [%node_name]%marker %.-10000m%n
5959
appender.index_search_slowlog_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_search_slowlog-%i.log.gz
6060
appender.index_search_slowlog_rolling.policies.type = Policies
6161
appender.index_search_slowlog_rolling.policies.size.type = SizeBasedTriggeringPolicy
@@ -72,7 +72,7 @@ appender.index_indexing_slowlog_rolling.type = RollingFile
7272
appender.index_indexing_slowlog_rolling.name = index_indexing_slowlog_rolling
7373
appender.index_indexing_slowlog_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_indexing_slowlog.log
7474
appender.index_indexing_slowlog_rolling.layout.type = PatternLayout
75-
appender.index_indexing_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.-10000m%n
75+
appender.index_indexing_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] [%node_name]%marker %.-10000m%n
7676
appender.index_indexing_slowlog_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_indexing_slowlog-%i.log.gz
7777
appender.index_indexing_slowlog_rolling.policies.type = Policies
7878
appender.index_indexing_slowlog_rolling.policies.size.type = SizeBasedTriggeringPolicy

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

+3
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,14 @@ The Java High Level REST Client supports the following Miscellaneous APIs:
5454
* <<java-rest-high-main>>
5555
* <<java-rest-high-ping>>
5656
* <<java-rest-high-x-pack-info>>
57+
* <<java-rest-high-x-pack-watcher-put-watch>>
58+
* <<java-rest-high-x-pack-watcher-delete-watch>>
5759

5860
include::miscellaneous/main.asciidoc[]
5961
include::miscellaneous/ping.asciidoc[]
6062
include::x-pack/x-pack-info.asciidoc[]
6163
include::x-pack/watcher/put-watch.asciidoc[]
64+
include::x-pack/watcher/delete-watch.asciidoc[]
6265

6366
== Indices APIs
6467

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[[java-rest-high-x-pack-watcher-delete-watch]]
2+
=== X-Pack Delete Watch API
3+
4+
[[java-rest-high-x-pack-watcher-delete-watch-execution]]
5+
==== Execution
6+
7+
A watch can be deleted as follows:
8+
9+
["source","java",subs="attributes,callouts,macros"]
10+
--------------------------------------------------
11+
include-tagged::{doc-tests}/WatcherDocumentationIT.java[x-pack-delete-watch-execute]
12+
--------------------------------------------------
13+
14+
[[java-rest-high-x-pack-watcher-delete-watch-response]]
15+
==== Response
16+
17+
The returned `DeleteWatchResponse` contains `found`, `id`,
18+
and `version` information.
19+
20+
["source","java",subs="attributes,callouts,macros"]
21+
--------------------------------------------------
22+
include-tagged::{doc-tests}/WatcherDocumentationIT.java[x-pack-put-watch-response]
23+
--------------------------------------------------
24+
<1> `_id` contains id of the watch
25+
<2> `found` is a boolean indicating whether the watch was found
26+
<3> `_version` returns the version of the deleted watch
27+
28+
[[java-rest-high-x-pack-watcher-delete-watch-async]]
29+
==== Asynchronous Execution
30+
31+
This request can be executed asynchronously:
32+
33+
["source","java",subs="attributes,callouts,macros"]
34+
--------------------------------------------------
35+
include-tagged::{doc-tests}/WatcherDocumentationIT.java[x-pack-delete-watch-execute-async]
36+
--------------------------------------------------
37+
<1> The `DeleteWatchRequest` to execute and the `ActionListener` to use when
38+
the execution completes
39+
40+
The asynchronous method does not block and returns immediately. Once it is
41+
completed the `ActionListener` is called back using the `onResponse` method
42+
if the execution successfully completed or using the `onFailure` method if
43+
it failed.
44+
45+
A typical listener for `DeleteWatchResponse` looks like:
46+
47+
["source","java",subs="attributes,callouts,macros"]
48+
--------------------------------------------------
49+
include-tagged::{doc-tests}/WatcherDocumentationIT.java[x-pack-delete-watch-execute-listener]
50+
--------------------------------------------------
51+
<1> Called when the execution is successfully completed. The response is
52+
provided as an argument
53+
<2> Called in case of failure. The raised exception is provided as an argument

0 commit comments

Comments
 (0)