Skip to content

Commit ff99bc1

Browse files
authored
Remove per-type indexing stats (#47203)
With only a single type, the per-type filters for indexing stats are no longer useful. Relates to #41059
1 parent 2b8c7c5 commit ff99bc1

File tree

15 files changed

+30
-278
lines changed

15 files changed

+30
-278
lines changed

rest-api-spec/src/main/resources/rest-api-spec/test/indices.stats/15_types.yml

Lines changed: 0 additions & 81 deletions
This file was deleted.

server/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStats.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public CommonStats(IndicesQueryCache indicesQueryCache, IndexShard indexShard, C
177177
store = indexShard.storeStats();
178178
break;
179179
case Indexing:
180-
indexing = indexShard.indexingStats(flags.types());
180+
indexing = indexShard.indexingStats();
181181
break;
182182
case Get:
183183
get = indexShard.getStats();

server/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStatsFlags.java

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.elasticsearch.action.admin.indices.stats;
2121

2222
import org.elasticsearch.Version;
23+
import org.elasticsearch.common.Strings;
2324
import org.elasticsearch.common.io.stream.StreamInput;
2425
import org.elasticsearch.common.io.stream.StreamOutput;
2526
import org.elasticsearch.common.io.stream.Writeable;
@@ -34,7 +35,6 @@ public class CommonStatsFlags implements Writeable, Cloneable {
3435
public static final CommonStatsFlags NONE = new CommonStatsFlags().clear();
3536

3637
private EnumSet<Flag> flags = EnumSet.allOf(Flag.class);
37-
private String[] types = null;
3838
private String[] groups = null;
3939
private String[] fieldDataFields = null;
4040
private String[] completionDataFields = null;
@@ -59,7 +59,9 @@ public CommonStatsFlags(StreamInput in) throws IOException {
5959
flags.add(flag);
6060
}
6161
}
62-
types = in.readStringArray();
62+
if (in.getVersion().before(Version.V_8_0_0)) {
63+
in.readStringArray();
64+
}
6365
groups = in.readStringArray();
6466
fieldDataFields = in.readStringArray();
6567
completionDataFields = in.readStringArray();
@@ -77,7 +79,9 @@ public void writeTo(StreamOutput out) throws IOException {
7779
}
7880
out.writeLong(longFlags);
7981

80-
out.writeStringArrayNullable(types);
82+
if (out.getVersion().before(Version.V_8_0_0)) {
83+
out.writeStringArrayNullable(Strings.EMPTY_ARRAY);
84+
}
8185
out.writeStringArrayNullable(groups);
8286
out.writeStringArrayNullable(fieldDataFields);
8387
out.writeStringArrayNullable(completionDataFields);
@@ -92,7 +96,6 @@ public void writeTo(StreamOutput out) throws IOException {
9296
*/
9397
public CommonStatsFlags all() {
9498
flags = EnumSet.allOf(Flag.class);
95-
types = null;
9699
groups = null;
97100
fieldDataFields = null;
98101
completionDataFields = null;
@@ -106,7 +109,6 @@ public CommonStatsFlags all() {
106109
*/
107110
public CommonStatsFlags clear() {
108111
flags = EnumSet.noneOf(Flag.class);
109-
types = null;
110112
groups = null;
111113
fieldDataFields = null;
112114
completionDataFields = null;
@@ -123,23 +125,6 @@ public Flag[] getFlags() {
123125
return flags.toArray(new Flag[flags.size()]);
124126
}
125127

126-
/**
127-
* Document types to return stats for. Mainly affects {@link Flag#Indexing} when
128-
* enabled, returning specific indexing stats for those types.
129-
*/
130-
public CommonStatsFlags types(String... types) {
131-
this.types = types;
132-
return this;
133-
}
134-
135-
/**
136-
* Document types to return stats for. Mainly affects {@link Flag#Indexing} when
137-
* enabled, returning specific indexing stats for those types.
138-
*/
139-
public String[] types() {
140-
return this.types;
141-
}
142-
143128
/**
144129
* Sets specific search group stats to retrieve the stats for. Mainly affects search
145130
* when enabled.

server/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsRequest.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,23 +78,6 @@ public IndicesStatsRequest flags(CommonStatsFlags flags) {
7878
return this;
7979
}
8080

81-
/**
82-
* Document types to return stats for. Mainly affects {@link #indexing(boolean)} when
83-
* enabled, returning specific indexing stats for those types.
84-
*/
85-
public IndicesStatsRequest types(String... types) {
86-
flags.types(types);
87-
return this;
88-
}
89-
90-
/**
91-
* Document types to return stats for. Mainly affects {@link #indexing(boolean)} when
92-
* enabled, returning specific indexing stats for those types.
93-
*/
94-
public String[] types() {
95-
return this.flags.types();
96-
}
97-
9881
/**
9982
* Sets specific search group stats to retrieve the stats for. Mainly affects search
10083
* when enabled.

server/src/main/java/org/elasticsearch/action/admin/indices/stats/IndicesStatsRequestBuilder.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,6 @@ public IndicesStatsRequestBuilder clear() {
5454
return this;
5555
}
5656

57-
/**
58-
* Document types to return stats for. Mainly affects {@link #setIndexing(boolean)} when
59-
* enabled, returning specific indexing stats for those types.
60-
*/
61-
public IndicesStatsRequestBuilder setTypes(String... types) {
62-
request.types(types);
63-
return this;
64-
}
65-
6657
public IndicesStatsRequestBuilder setGroups(String... groups) {
6758
request.groups(groups);
6859
return this;

server/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ protected void shardOperation(final UpdateRequest request, final ActionListener<
237237
if (indexServiceOrNull != null) {
238238
IndexShard shard = indexService.getShardOrNull(shardId.getId());
239239
if (shard != null) {
240-
shard.noopUpdate(request.type());
240+
shard.noopUpdate();
241241
}
242242
}
243243
listener.onResponse(update);

server/src/main/java/org/elasticsearch/index/shard/IndexShard.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ public SeqNoStats seqNoStats() {
985985
return getEngine().getSeqNoStats(replicationTracker.getGlobalCheckpoint());
986986
}
987987

988-
public IndexingStats indexingStats(String... types) {
988+
public IndexingStats indexingStats() {
989989
Engine engine = getEngineOrNull();
990990
final boolean throttled;
991991
final long throttleTimeInMillis;
@@ -996,7 +996,7 @@ public IndexingStats indexingStats(String... types) {
996996
throttled = engine.isThrottled();
997997
throttleTimeInMillis = engine.getIndexThrottleTimeInMillis();
998998
}
999-
return internalIndexingStats.stats(throttled, throttleTimeInMillis, types);
999+
return internalIndexingStats.stats(throttled, throttleTimeInMillis);
10001000
}
10011001

10021002
public SearchStats searchStats(String... groups) {
@@ -2387,11 +2387,9 @@ public boolean pendingInSync() {
23872387

23882388
/**
23892389
* Should be called for each no-op update operation to increment relevant statistics.
2390-
*
2391-
* @param type the doc type of the update
23922390
*/
2393-
public void noopUpdate(String type) {
2394-
internalIndexingStats.noopUpdate(type);
2391+
public void noopUpdate() {
2392+
internalIndexingStats.noopUpdate();
23952393
}
23962394

23972395
public void maybeCheckIndex() {

server/src/main/java/org/elasticsearch/index/shard/IndexingStats.java

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919

2020
package org.elasticsearch.index.shard;
2121

22-
import org.elasticsearch.common.Nullable;
22+
import org.elasticsearch.Version;
2323
import org.elasticsearch.common.io.stream.StreamInput;
2424
import org.elasticsearch.common.io.stream.StreamOutput;
2525
import org.elasticsearch.common.io.stream.Writeable;
2626
import org.elasticsearch.common.unit.TimeValue;
2727
import org.elasticsearch.common.xcontent.ToXContent;
2828
import org.elasticsearch.common.xcontent.ToXContentFragment;
2929
import org.elasticsearch.common.xcontent.XContentBuilder;
30+
import org.elasticsearch.index.mapper.MapperService;
3031

3132
import java.io.IOException;
32-
import java.util.HashMap;
3333
import java.util.Map;
3434

3535
public class IndexingStats implements Writeable, ToXContentFragment {
@@ -182,47 +182,30 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
182182

183183
private final Stats totalStats;
184184

185-
@Nullable
186-
private Map<String, Stats> typeStats;
187-
188185
public IndexingStats() {
189186
totalStats = new Stats();
190187
}
191188

192189
public IndexingStats(StreamInput in) throws IOException {
193190
totalStats = new Stats(in);
194-
if (in.readBoolean()) {
195-
typeStats = in.readMap(StreamInput::readString, Stats::new);
191+
if (in.getVersion().before(Version.V_8_0_0)) {
192+
if (in.readBoolean()) {
193+
Map<String, Stats> typeStats = in.readMap(StreamInput::readString, Stats::new);
194+
assert typeStats.size() == 1;
195+
assert typeStats.containsKey(MapperService.SINGLE_MAPPING_NAME);
196+
}
196197
}
197198
}
198199

199-
public IndexingStats(Stats totalStats, @Nullable Map<String, Stats> typeStats) {
200+
public IndexingStats(Stats totalStats) {
200201
this.totalStats = totalStats;
201-
this.typeStats = typeStats;
202202
}
203203

204204
public void add(IndexingStats indexingStats) {
205-
add(indexingStats, true);
206-
}
207-
208-
public void add(IndexingStats indexingStats, boolean includeTypes) {
209205
if (indexingStats == null) {
210206
return;
211207
}
212208
addTotals(indexingStats);
213-
if (includeTypes && indexingStats.typeStats != null && !indexingStats.typeStats.isEmpty()) {
214-
if (typeStats == null) {
215-
typeStats = new HashMap<>(indexingStats.typeStats.size());
216-
}
217-
for (Map.Entry<String, Stats> entry : indexingStats.typeStats.entrySet()) {
218-
Stats stats = typeStats.get(entry.getKey());
219-
if (stats == null) {
220-
typeStats.put(entry.getKey(), entry.getValue());
221-
} else {
222-
stats.add(entry.getValue());
223-
}
224-
}
225-
}
226209
}
227210

228211
public void addTotals(IndexingStats indexingStats) {
@@ -236,31 +219,16 @@ public Stats getTotal() {
236219
return this.totalStats;
237220
}
238221

239-
@Nullable
240-
public Map<String, Stats> getTypeStats() {
241-
return this.typeStats;
242-
}
243-
244222
@Override
245223
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
246224
builder.startObject(Fields.INDEXING);
247225
totalStats.toXContent(builder, params);
248-
if (typeStats != null && !typeStats.isEmpty()) {
249-
builder.startObject(Fields.TYPES);
250-
for (Map.Entry<String, Stats> entry : typeStats.entrySet()) {
251-
builder.startObject(entry.getKey());
252-
entry.getValue().toXContent(builder, params);
253-
builder.endObject();
254-
}
255-
builder.endObject();
256-
}
257226
builder.endObject();
258227
return builder;
259228
}
260229

261230
static final class Fields {
262231
static final String INDEXING = "indexing";
263-
static final String TYPES = "types";
264232
static final String INDEX_TOTAL = "index_total";
265233
static final String INDEX_TIME = "index_time";
266234
static final String INDEX_TIME_IN_MILLIS = "index_time_in_millis";
@@ -279,11 +247,8 @@ static final class Fields {
279247
@Override
280248
public void writeTo(StreamOutput out) throws IOException {
281249
totalStats.writeTo(out);
282-
if (typeStats == null || typeStats.isEmpty()) {
250+
if (out.getVersion().before(Version.V_8_0_0)) {
283251
out.writeBoolean(false);
284-
} else {
285-
out.writeBoolean(true);
286-
out.writeMap(typeStats, StreamOutput::writeString, (stream, stats) -> stats.writeTo(stream));
287252
}
288253
}
289254
}

0 commit comments

Comments
 (0)