Handle exceptions when building _cat/indices response
This commit is contained in:
parent
dde75b0f64
commit
c5f61fe24c
|
@ -273,3 +273,19 @@
|
||||||
open \s+ foo\n
|
open \s+ foo\n
|
||||||
open \s+ baz\n
|
open \s+ baz\n
|
||||||
$/
|
$/
|
||||||
|
|
||||||
|
---
|
||||||
|
"Test cat indices with invalid health parameter":
|
||||||
|
|
||||||
|
- do:
|
||||||
|
indices.create:
|
||||||
|
index: foo
|
||||||
|
body:
|
||||||
|
settings:
|
||||||
|
number_of_shards: "1"
|
||||||
|
number_of_replicas: "0"
|
||||||
|
|
||||||
|
- do:
|
||||||
|
catch: bad_request
|
||||||
|
cat.indices:
|
||||||
|
health: "invalid-health-value"
|
||||||
|
|
|
@ -216,21 +216,27 @@ public class RestIndicesAction extends AbstractCatAction {
|
||||||
return new GroupedActionListener<>(new ActionListener<Collection<ActionResponse>>() {
|
return new GroupedActionListener<>(new ActionListener<Collection<ActionResponse>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(final Collection<ActionResponse> responses) {
|
public void onResponse(final Collection<ActionResponse> responses) {
|
||||||
GetSettingsResponse settingsResponse = extractResponse(responses, GetSettingsResponse.class);
|
try {
|
||||||
Map<String, Settings> indicesSettings = StreamSupport.stream(settingsResponse.getIndexToSettings().spliterator(), false)
|
GetSettingsResponse settingsResponse = extractResponse(responses, GetSettingsResponse.class);
|
||||||
.collect(Collectors.toMap(cursor -> cursor.key, cursor -> cursor.value));
|
Map<String, Settings> indicesSettings = StreamSupport.stream(settingsResponse.getIndexToSettings().spliterator(), false)
|
||||||
|
.collect(Collectors.toMap(cursor -> cursor.key, cursor -> cursor.value));
|
||||||
|
|
||||||
ClusterStateResponse stateResponse = extractResponse(responses, ClusterStateResponse.class);
|
ClusterStateResponse stateResponse = extractResponse(responses, ClusterStateResponse.class);
|
||||||
Map<String, IndexMetadata> indicesStates = StreamSupport.stream(stateResponse.getState().getMetadata().spliterator(), false)
|
Map<String, IndexMetadata> indicesStates =
|
||||||
.collect(Collectors.toMap(indexMetadata -> indexMetadata.getIndex().getName(), Function.identity()));
|
StreamSupport.stream(stateResponse.getState().getMetadata().spliterator(), false)
|
||||||
|
.collect(Collectors.toMap(indexMetadata -> indexMetadata.getIndex().getName(), Function.identity()));
|
||||||
|
|
||||||
ClusterHealthResponse healthResponse = extractResponse(responses, ClusterHealthResponse.class);
|
ClusterHealthResponse healthResponse = extractResponse(responses, ClusterHealthResponse.class);
|
||||||
Map<String, ClusterIndexHealth> indicesHealths = healthResponse.getIndices();
|
Map<String, ClusterIndexHealth> indicesHealths = healthResponse.getIndices();
|
||||||
|
|
||||||
IndicesStatsResponse statsResponse = extractResponse(responses, IndicesStatsResponse.class);
|
IndicesStatsResponse statsResponse = extractResponse(responses, IndicesStatsResponse.class);
|
||||||
Map<String, IndexStats> indicesStats = statsResponse.getIndices();
|
Map<String, IndexStats> indicesStats = statsResponse.getIndices();
|
||||||
|
|
||||||
listener.onResponse(buildTable(request, indicesSettings, indicesHealths, indicesStats, indicesStates));
|
Table responseTable = buildTable(request, indicesSettings, indicesHealths, indicesStats, indicesStates);
|
||||||
|
listener.onResponse(responseTable);
|
||||||
|
} catch (Exception e) {
|
||||||
|
onFailure(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue