This PR removes the expand_wildcards and forbid_closed_indices parameters from the Data Streams Stats REST endpoint. These options are required for broadcast requests, but are not needed for anything in terms of resolving data streams. Instead, we just set a default set of IndicesOptions on the transport request.
This commit is contained in:
parent
b302b09b85
commit
b3363cf8f9
|
@ -104,12 +104,7 @@ final class IndicesRequestConverters {
|
|||
.addCommaSeparatedPathParts(expressions)
|
||||
.addPathPartAsIs("_stats")
|
||||
.build();
|
||||
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
|
||||
RequestConverters.Params parameters = new RequestConverters.Params();
|
||||
parameters.withIndicesOptions(dataStreamsStatsRequest.indicesOptions());
|
||||
request.addParameters(parameters.asMap());
|
||||
return request;
|
||||
return new Request(HttpGet.METHOD_NAME, endpoint);
|
||||
}
|
||||
|
||||
static Request deleteIndex(DeleteIndexRequest deleteIndexRequest) {
|
||||
|
|
|
@ -19,13 +19,11 @@
|
|||
|
||||
package org.elasticsearch.client.indices;
|
||||
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.client.Validatable;
|
||||
|
||||
public class DataStreamsStatsRequest implements Validatable {
|
||||
|
||||
private final String[] indices;
|
||||
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false, true, true);
|
||||
|
||||
public DataStreamsStatsRequest(String... indices) {
|
||||
this.indices = indices;
|
||||
|
@ -34,13 +32,4 @@ public class DataStreamsStatsRequest implements Validatable {
|
|||
public String[] indices() {
|
||||
return indices;
|
||||
}
|
||||
|
||||
public IndicesOptions indicesOptions() {
|
||||
return indicesOptions;
|
||||
}
|
||||
|
||||
public DataStreamsStatsRequest indicesOptions(IndicesOptions indicesOptions) {
|
||||
this.indicesOptions = indicesOptions;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,25 +26,6 @@
|
|||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"params":{
|
||||
"expand_wildcards":{
|
||||
"type":"enum",
|
||||
"options":[
|
||||
"open",
|
||||
"closed",
|
||||
"hidden",
|
||||
"none",
|
||||
"all"
|
||||
],
|
||||
"default":"open",
|
||||
"description":"Whether to expand wildcard expression to concrete indices that are open, closed or both."
|
||||
},
|
||||
"forbid_closed_indices":{
|
||||
"type":"boolean",
|
||||
"description":"If set to false stats will also collected from closed indices if explicitly specified or if expand_wildcards expands to closed indices",
|
||||
"default":true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ package org.elasticsearch.xpack.core.action;
|
|||
|
||||
import org.elasticsearch.action.ActionType;
|
||||
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastRequest;
|
||||
import org.elasticsearch.action.support.broadcast.BroadcastResponse;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
|
@ -34,7 +35,9 @@ public class DataStreamsStatsAction extends ActionType<DataStreamsStatsAction.Re
|
|||
|
||||
public static class Request extends BroadcastRequest<Request> {
|
||||
public Request() {
|
||||
super((String[]) null);
|
||||
// this doesn't really matter since data stream name resolution isn't affected by IndicesOptions and
|
||||
// a data stream's backing indices are retrieved from its metadata
|
||||
super(null, IndicesOptions.fromOptions(false, true, true, true, true, false, true, false));
|
||||
}
|
||||
|
||||
public Request(StreamInput in) throws IOException {
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.datastreams.rest;
|
||||
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
|
@ -34,13 +33,6 @@ public class RestDataStreamsStatsAction extends BaseRestHandler {
|
|||
@Override
|
||||
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
|
||||
DataStreamsStatsAction.Request dataStreamsStatsRequest = new DataStreamsStatsAction.Request();
|
||||
boolean forbidClosedIndices = request.paramAsBoolean("forbid_closed_indices", true);
|
||||
IndicesOptions defaultIndicesOption = forbidClosedIndices
|
||||
? dataStreamsStatsRequest.indicesOptions()
|
||||
: IndicesOptions.strictExpandOpen();
|
||||
assert dataStreamsStatsRequest.indicesOptions() == IndicesOptions.strictExpandOpenAndForbidClosed() : "DataStreamStats default "
|
||||
+ "indices options changed";
|
||||
dataStreamsStatsRequest.indicesOptions(IndicesOptions.fromRequest(request, defaultIndicesOption));
|
||||
dataStreamsStatsRequest.indices(Strings.splitStringByCommaToArray(request.param("name")));
|
||||
return channel -> client.execute(DataStreamsStatsAction.INSTANCE, dataStreamsStatsRequest, new RestToXContentListener<>(channel));
|
||||
}
|
||||
|
|
|
@ -7,12 +7,15 @@
|
|||
package org.elasticsearch.xpack.datastreams;
|
||||
|
||||
import org.elasticsearch.action.DocWriteRequest;
|
||||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
|
||||
import org.elasticsearch.action.admin.indices.close.CloseIndexRequest;
|
||||
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
|
||||
import org.elasticsearch.action.admin.indices.rollover.RolloverRequest;
|
||||
import org.elasticsearch.action.admin.indices.template.delete.DeleteComposableIndexTemplateAction;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutComposableIndexTemplateAction;
|
||||
import org.elasticsearch.action.index.IndexRequest;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
|
||||
import org.elasticsearch.cluster.metadata.Template;
|
||||
import org.elasticsearch.common.compress.CompressedXContent;
|
||||
|
@ -78,6 +81,7 @@ public class DataStreamsStatsTests extends ESSingleNodeTestCase {
|
|||
assertNotEquals(0L, stats.getTotalStoreSize().getBytes());
|
||||
assertEquals(1, stats.getDataStreams().length);
|
||||
assertEquals(dataStreamName, stats.getDataStreams()[0].getDataStream());
|
||||
assertEquals(1, stats.getDataStreams()[0].getBackingIndices());
|
||||
assertEquals(0L, stats.getDataStreams()[0].getMaximumTimestamp());
|
||||
assertNotEquals(0L, stats.getDataStreams()[0].getStoreSize().getBytes());
|
||||
assertEquals(stats.getTotalStoreSize().getBytes(), stats.getDataStreams()[0].getStoreSize().getBytes());
|
||||
|
@ -95,6 +99,54 @@ public class DataStreamsStatsTests extends ESSingleNodeTestCase {
|
|||
assertNotEquals(0L, stats.getTotalStoreSize().getBytes());
|
||||
assertEquals(1, stats.getDataStreams().length);
|
||||
assertEquals(dataStreamName, stats.getDataStreams()[0].getDataStream());
|
||||
assertEquals(1, stats.getDataStreams()[0].getBackingIndices());
|
||||
assertEquals(timestamp, stats.getDataStreams()[0].getMaximumTimestamp());
|
||||
assertNotEquals(0L, stats.getDataStreams()[0].getStoreSize().getBytes());
|
||||
assertEquals(stats.getTotalStoreSize().getBytes(), stats.getDataStreams()[0].getStoreSize().getBytes());
|
||||
}
|
||||
|
||||
public void testStatsClosedBackingIndexDataStream() throws Exception {
|
||||
String dataStreamName = createDataStream();
|
||||
createDocument(dataStreamName);
|
||||
assertTrue(client().admin().indices().rolloverIndex(new RolloverRequest(dataStreamName, null)).get().isAcknowledged());
|
||||
assertTrue(
|
||||
client().admin().indices().close(new CloseIndexRequest(".ds-" + dataStreamName + "-000001")).actionGet().isAcknowledged()
|
||||
);
|
||||
|
||||
assertBusy(
|
||||
() -> {
|
||||
assertNotEquals(
|
||||
ClusterHealthStatus.RED,
|
||||
client().admin().cluster().health(new ClusterHealthRequest()).actionGet().getStatus()
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
DataStreamsStatsAction.Response stats = getDataStreamsStats();
|
||||
assertEquals(2, stats.getSuccessfulShards());
|
||||
assertEquals(0, stats.getFailedShards());
|
||||
assertEquals(1, stats.getDataStreamCount());
|
||||
assertEquals(2, stats.getBackingIndices());
|
||||
assertNotEquals(0L, stats.getTotalStoreSize().getBytes());
|
||||
assertEquals(1, stats.getDataStreams().length);
|
||||
assertEquals(dataStreamName, stats.getDataStreams()[0].getDataStream());
|
||||
assertEquals(2, stats.getDataStreams()[0].getBackingIndices());
|
||||
assertEquals(0L, stats.getDataStreams()[0].getMaximumTimestamp());
|
||||
assertNotEquals(0L, stats.getDataStreams()[0].getStoreSize().getBytes());
|
||||
assertEquals(stats.getTotalStoreSize().getBytes(), stats.getDataStreams()[0].getStoreSize().getBytes());
|
||||
|
||||
// Call stats again after writing a new event into the write index
|
||||
long timestamp = createDocument(dataStreamName);
|
||||
|
||||
stats = getDataStreamsStats();
|
||||
assertEquals(2, stats.getSuccessfulShards());
|
||||
assertEquals(0, stats.getFailedShards());
|
||||
assertEquals(1, stats.getDataStreamCount());
|
||||
assertEquals(2, stats.getBackingIndices());
|
||||
assertNotEquals(0L, stats.getTotalStoreSize().getBytes());
|
||||
assertEquals(1, stats.getDataStreams().length);
|
||||
assertEquals(dataStreamName, stats.getDataStreams()[0].getDataStream());
|
||||
assertEquals(2, stats.getDataStreams()[0].getBackingIndices());
|
||||
assertEquals(timestamp, stats.getDataStreams()[0].getMaximumTimestamp());
|
||||
assertNotEquals(0L, stats.getDataStreams()[0].getStoreSize().getBytes());
|
||||
assertEquals(stats.getTotalStoreSize().getBytes(), stats.getDataStreams()[0].getStoreSize().getBytes());
|
||||
|
@ -114,6 +166,7 @@ public class DataStreamsStatsTests extends ESSingleNodeTestCase {
|
|||
assertNotEquals(0L, stats.getTotalStoreSize().getBytes());
|
||||
assertEquals(1, stats.getDataStreams().length);
|
||||
assertEquals(dataStreamName, stats.getDataStreams()[0].getDataStream());
|
||||
assertEquals(2, stats.getDataStreams()[0].getBackingIndices());
|
||||
assertEquals(timestamp, stats.getDataStreams()[0].getMaximumTimestamp());
|
||||
assertNotEquals(0L, stats.getDataStreams()[0].getStoreSize().getBytes());
|
||||
assertEquals(stats.getTotalStoreSize().getBytes(), stats.getDataStreams()[0].getStoreSize().getBytes());
|
||||
|
|
Loading…
Reference in New Issue