Skip to content

Commit df499c1

Browse files
committed
Merge remote-tracking branch 'elastic/master' into execute-actions-under-permit-primary-mode-only
* elastic/master: Validate non-secure settings are not in keystore (elastic#42209) Cleanup Various Uses of ActionListener (elastic#40126) Update api links per context (elastic#42033)
2 parents bb46faa + da5abe2 commit df499c1

File tree

41 files changed

+137
-328
lines changed

Some content is hidden

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

41 files changed

+137
-328
lines changed

docs/painless/painless-contexts/painless-analysis-predicate-context.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ analysis chain matches a predicate.
4040

4141
*API*
4242

43-
The standard <<painless-api-reference, Painless API>> is available.
43+
The standard <<painless-api-reference-shared, Painless API>> is available.

docs/painless/painless-contexts/painless-bucket-script-agg-context.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ numeric::
1818

1919
==== API
2020

21-
The standard <<painless-api-reference, Painless API>> is available.
21+
The standard <<painless-api-reference-shared, Painless API>> is available.
2222

2323
==== Example
2424

docs/painless/painless-contexts/painless-bucket-selector-agg-context.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ boolean::
1919

2020
==== API
2121

22+
The standard <<painless-api-reference-shared, Painless API>> is available.
23+
24+
==== Example
25+
2226

2327
To run this example, first follow the steps in <<painless-context-examples, context examples>>.
2428

docs/painless/painless-contexts/painless-field-context.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ a customized value for each document in the results of a query.
2525

2626
*API*
2727

28-
The standard <<painless-api-reference, Painless API>> is available.
28+
Both the standard <<painless-api-reference-shared, Painless API>> and
29+
<<painless-api-reference-field, Specialized Field API>> are available.
2930

3031

3132
*Example*

docs/painless/painless-contexts/painless-filter-context.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ query to include and exclude documents.
2323

2424
*API*
2525

26-
The standard <<painless-api-reference, Painless API>> is available.
26+
The standard <<painless-api-reference-shared, Painless API>> is available.
2727

2828
*Example*
2929

docs/painless/painless-contexts/painless-ingest-processor-context.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ void::
3838

3939
*API*
4040

41-
The standard <<painless-api-reference, Painless API>> is available.
41+
Both the standard <<painless-api-reference-shared, Painless API>> and
42+
<<painless-api-reference-ingest, Specialized Ingest API>> are available.
4243

4344
*Example*
4445

docs/painless/painless-contexts/painless-metric-agg-combine-context.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ optional as part of a full metric aggregation.
2424

2525
*API*
2626

27-
The standard <<painless-api-reference, Painless API>> is available.
27+
The standard <<painless-api-reference-shared, Painless API>> is available.

docs/painless/painless-contexts/painless-metric-agg-init-context.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ full metric aggregation.
2929

3030
*API*
3131

32-
The standard <<painless-api-reference, Painless API>> is available.
32+
The standard <<painless-api-reference-shared, Painless API>> is available.

docs/painless/painless-contexts/painless-metric-agg-map-context.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ part of a full metric aggregation.
4444

4545
*API*
4646

47-
The standard <<painless-api-reference, Painless API>> is available.
47+
The standard <<painless-api-reference-shared, Painless API>> is available.

docs/painless/painless-contexts/painless-metric-agg-reduce-context.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ specified) and is optional as part of a full metric aggregation.
2525

2626
*API*
2727

28-
The standard <<painless-api-reference, Painless API>> is available.
28+
The standard <<painless-api-reference-shared, Painless API>> is available.

docs/painless/painless-contexts/painless-min-should-match-context.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ results.
2525

2626
*API*
2727

28-
The standard <<painless-api-reference, Painless API>> is available.
28+
The standard <<painless-api-reference-shared, Painless API>> is available.
2929

3030
*Example*
3131

docs/painless/painless-contexts/painless-reindex-context.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ reindexed into a target index.
6565

6666
*API*
6767

68-
The standard <<painless-api-reference, Painless API>> is available.
68+
The standard <<painless-api-reference-shared, Painless API>> is available.

docs/painless/painless-contexts/painless-score-context.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ score to documents returned from a query.
2626

2727
*API*
2828

29-
The standard <<painless-api-reference, Painless API>> is available.
29+
Both the standard <<painless-api-reference-shared, Painless API>> and
30+
<<painless-api-reference-score, Specialized Score API>> are available.
3031

3132
*Example*
3233

docs/painless/painless-contexts/painless-similarity-context.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ uses synonyms.
5656

5757
*API*
5858

59-
The standard <<painless-api-reference, Painless API>> is available.
59+
The standard <<painless-api-reference-shared, Painless API>> is available.

docs/painless/painless-contexts/painless-sort-context.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Use a Painless script to
2525

2626
*API*
2727

28-
The standard <<painless-api-reference, Painless API>> is available.
28+
The standard <<painless-api-reference-shared, Painless API>> is available.
2929

3030
*Example*
3131

docs/painless/painless-contexts/painless-update-by-query-context.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ result of query.
5151

5252
*API*
5353

54-
The standard <<painless-api-reference, Painless API>> is available.
54+
The standard <<painless-api-reference-shared, Painless API>> is available.
5555

5656
*Example*
5757

docs/painless/painless-contexts/painless-update-context.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ add, modify, or delete fields within a single document.
5252

5353
*API*
5454

55-
The standard <<painless-api-reference, Painless API>> is available.
55+
The standard <<painless-api-reference-shared, Painless API>> is available.
5656

5757
*Example*
5858

docs/painless/painless-contexts/painless-watcher-condition-context.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ include::painless-watcher-context-variables.asciidoc[]
1414

1515
*API*
1616

17-
The standard <<painless-api-reference, Painless API>> is available.
17+
The standard <<painless-api-reference-shared, Painless API>> is available.
1818

1919
*Example*
2020

docs/painless/painless-contexts/painless-watcher-context-variables.asciidoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ The following variables are available in all watcher contexts.
3333

3434
*API*
3535

36-
37-
The standard <<painless-api-reference, Painless API>> is available.
36+
The standard <<painless-api-reference-shared, Painless API>> is available.
3837

3938
To run this example, first follow the steps in
4039
<<painless-context-examples, context examples>>.

docs/painless/painless-contexts/painless-watcher-transform-context.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ include::painless-watcher-context-variables.asciidoc[]
1414

1515
*API*
1616

17-
The standard <<painless-api-reference, Painless API>> is available.
17+
The standard <<painless-api-reference-shared, Painless API>> is available.
1818

1919
*Example*
2020

docs/painless/painless-contexts/painless-weight-context.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ Queries that contain multiple terms calculate a separate weight for each term.
3939

4040
*API*
4141

42-
The standard <<painless-api-reference, Painless API>> is available.
42+
The standard <<painless-api-reference-shared, Painless API>> is available.

server/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/get/TransportGetTaskAction.java

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -203,27 +203,15 @@ void getFinishedTaskFromIndex(Task thisTask, GetTaskRequest request, ActionListe
203203
request.getTaskId().toString());
204204
get.setParentTask(clusterService.localNode().getId(), thisTask.getId());
205205

206-
client.get(get, new ActionListener<GetResponse>() {
207-
@Override
208-
public void onResponse(GetResponse getResponse) {
209-
try {
210-
onGetFinishedTaskFromIndex(getResponse, listener);
211-
} catch (Exception e) {
212-
listener.onFailure(e);
213-
}
214-
}
215-
216-
@Override
217-
public void onFailure(Exception e) {
218-
if (ExceptionsHelper.unwrap(e, IndexNotFoundException.class) != null) {
219-
// We haven't yet created the index for the task results so it can't be found.
220-
listener.onFailure(new ResourceNotFoundException("task [{}] isn't running and hasn't stored its results", e,
221-
request.getTaskId()));
222-
} else {
223-
listener.onFailure(e);
224-
}
206+
client.get(get, ActionListener.wrap(r -> onGetFinishedTaskFromIndex(r, listener), e -> {
207+
if (ExceptionsHelper.unwrap(e, IndexNotFoundException.class) != null) {
208+
// We haven't yet created the index for the task results so it can't be found.
209+
listener.onFailure(new ResourceNotFoundException("task [{}] isn't running and hasn't stored its results", e,
210+
request.getTaskId()));
211+
} else {
212+
listener.onFailure(e);
225213
}
226-
});
214+
}));
227215
}
228216

229217
/**

server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/TransportSnapshotsStatusAction.java

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,11 @@ protected void masterOperation(final SnapshotsStatusRequest request,
119119
TransportNodesSnapshotsStatus.Request nodesRequest =
120120
new TransportNodesSnapshotsStatus.Request(nodesIds.toArray(new String[nodesIds.size()]))
121121
.snapshots(snapshots).timeout(request.masterNodeTimeout());
122-
transportNodesSnapshotsStatus.execute(nodesRequest, new ActionListener<TransportNodesSnapshotsStatus.NodesSnapshotStatus>() {
123-
@Override
124-
public void onResponse(TransportNodesSnapshotsStatus.NodesSnapshotStatus nodeSnapshotStatuses) {
125-
try {
126-
List<SnapshotsInProgress.Entry> currentSnapshots =
127-
snapshotsService.currentSnapshots(request.repository(), Arrays.asList(request.snapshots()));
128-
listener.onResponse(buildResponse(request, currentSnapshots, nodeSnapshotStatuses));
129-
} catch (Exception e) {
130-
listener.onFailure(e);
131-
}
132-
}
133-
134-
@Override
135-
public void onFailure(Exception e) {
136-
listener.onFailure(e);
137-
}
138-
});
122+
transportNodesSnapshotsStatus.execute(nodesRequest,
123+
ActionListener.map(
124+
listener, nodeSnapshotStatuses ->
125+
buildResponse(request, snapshotsService.currentSnapshots(request.repository(), Arrays.asList(request.snapshots())),
126+
nodeSnapshotStatuses)));
139127
} else {
140128
// We don't have any in-progress shards, just return current stats
141129
listener.onResponse(buildResponse(request, currentSnapshots, null));

server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeAction.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -184,26 +184,13 @@ protected ClusterBlockException checkRequestBlock(ClusterState state, UpgradeReq
184184

185185
@Override
186186
protected void doExecute(Task task, UpgradeRequest request, final ActionListener<UpgradeResponse> listener) {
187-
ActionListener<UpgradeResponse> settingsUpdateListener = new ActionListener<UpgradeResponse>() {
188-
@Override
189-
public void onResponse(UpgradeResponse upgradeResponse) {
190-
try {
191-
if (upgradeResponse.versions().isEmpty()) {
192-
listener.onResponse(upgradeResponse);
193-
} else {
194-
updateSettings(upgradeResponse, listener);
195-
}
196-
} catch (Exception e) {
197-
listener.onFailure(e);
198-
}
199-
}
200-
201-
@Override
202-
public void onFailure(Exception e) {
203-
listener.onFailure(e);
187+
super.doExecute(task, request, ActionListener.wrap(upgradeResponse -> {
188+
if (upgradeResponse.versions().isEmpty()) {
189+
listener.onResponse(upgradeResponse);
190+
} else {
191+
updateSettings(upgradeResponse, listener);
204192
}
205-
};
206-
super.doExecute(task, request, settingsUpdateListener);
193+
}, listener::onFailure));
207194
}
208195

209196
private void updateSettings(final UpgradeResponse upgradeResponse, final ActionListener<UpgradeResponse> listener) {

server/src/main/java/org/elasticsearch/action/bulk/BulkRequestHandler.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,20 @@ public void execute(BulkRequest bulkRequest, long executionId) {
5959
semaphore.acquire();
6060
toRelease = semaphore::release;
6161
CountDownLatch latch = new CountDownLatch(1);
62-
retry.withBackoff(consumer, bulkRequest, new ActionListener<BulkResponse>() {
62+
retry.withBackoff(consumer, bulkRequest, ActionListener.runAfter(new ActionListener<BulkResponse>() {
6363
@Override
6464
public void onResponse(BulkResponse response) {
65-
try {
66-
listener.afterBulk(executionId, bulkRequest, response);
67-
} finally {
68-
semaphore.release();
69-
latch.countDown();
70-
}
65+
listener.afterBulk(executionId, bulkRequest, response);
7166
}
7267

7368
@Override
7469
public void onFailure(Exception e) {
75-
try {
76-
listener.afterBulk(executionId, bulkRequest, e);
77-
} finally {
78-
semaphore.release();
79-
latch.countDown();
80-
}
70+
listener.afterBulk(executionId, bulkRequest, e);
8171
}
82-
});
72+
}, () -> {
73+
semaphore.release();
74+
latch.countDown();
75+
}));
8376
bulkRequestSetupSuccessful = true;
8477
if (concurrentRequests == 0) {
8578
latch.await();

server/src/main/java/org/elasticsearch/action/ingest/PutPipelineTransportAction.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.elasticsearch.action.ActionListener;
2323
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
2424
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest;
25-
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
2625
import org.elasticsearch.action.support.ActionFilters;
2726
import org.elasticsearch.action.support.master.AcknowledgedResponse;
2827
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
@@ -74,25 +73,13 @@ protected void masterOperation(PutPipelineRequest request, ClusterState state, A
7473
NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
7574
nodesInfoRequest.clear();
7675
nodesInfoRequest.ingest(true);
77-
client.admin().cluster().nodesInfo(nodesInfoRequest, new ActionListener<NodesInfoResponse>() {
78-
@Override
79-
public void onResponse(NodesInfoResponse nodeInfos) {
80-
try {
81-
Map<DiscoveryNode, IngestInfo> ingestInfos = new HashMap<>();
82-
for (NodeInfo nodeInfo : nodeInfos.getNodes()) {
83-
ingestInfos.put(nodeInfo.getNode(), nodeInfo.getIngest());
84-
}
85-
ingestService.putPipeline(ingestInfos, request, listener);
86-
} catch (Exception e) {
87-
onFailure(e);
88-
}
76+
client.admin().cluster().nodesInfo(nodesInfoRequest, ActionListener.wrap(nodeInfos -> {
77+
Map<DiscoveryNode, IngestInfo> ingestInfos = new HashMap<>();
78+
for (NodeInfo nodeInfo : nodeInfos.getNodes()) {
79+
ingestInfos.put(nodeInfo.getNode(), nodeInfo.getIngest());
8980
}
90-
91-
@Override
92-
public void onFailure(Exception e) {
93-
listener.onFailure(e);
94-
}
95-
});
81+
ingestService.putPipeline(ingestInfos, request, listener);
82+
}, listener::onFailure));
9683
}
9784

9885
@Override

server/src/main/java/org/elasticsearch/action/support/ThreadedActionListener.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.logging.log4j.Logger;
2323
import org.apache.logging.log4j.message.ParameterizedMessage;
2424
import org.elasticsearch.action.ActionListener;
25+
import org.elasticsearch.action.ActionRunnable;
2526
import org.elasticsearch.client.Client;
2627
import org.elasticsearch.client.transport.TransportClient;
2728
import org.elasticsearch.common.settings.Settings;
@@ -86,21 +87,16 @@ public ThreadedActionListener(Logger logger, ThreadPool threadPool, String execu
8687

8788
@Override
8889
public void onResponse(final Response response) {
89-
threadPool.executor(executor).execute(new AbstractRunnable() {
90+
threadPool.executor(executor).execute(new ActionRunnable<>(listener) {
9091
@Override
9192
public boolean isForceExecution() {
9293
return forceExecution;
9394
}
9495

9596
@Override
96-
protected void doRun() throws Exception {
97+
protected void doRun() {
9798
listener.onResponse(response);
9899
}
99-
100-
@Override
101-
public void onFailure(Exception e) {
102-
listener.onFailure(e);
103-
}
104100
});
105101
}
106102

0 commit comments

Comments
 (0)