Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove per-type indexing stats #47203

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public CommonStats(IndicesQueryCache indicesQueryCache, IndexShard indexShard, C
store = indexShard.storeStats();
break;
case Indexing:
indexing = indexShard.indexingStats(flags.types());
indexing = indexShard.indexingStats();
break;
case Get:
get = indexShard.getStats();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.elasticsearch.action.admin.indices.stats;

import org.elasticsearch.Version;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
Expand All @@ -34,7 +35,6 @@ public class CommonStatsFlags implements Writeable, Cloneable {
public static final CommonStatsFlags NONE = new CommonStatsFlags().clear();

private EnumSet<Flag> flags = EnumSet.allOf(Flag.class);
private String[] types = null;
private String[] groups = null;
private String[] fieldDataFields = null;
private String[] completionDataFields = null;
Expand All @@ -59,7 +59,9 @@ public CommonStatsFlags(StreamInput in) throws IOException {
flags.add(flag);
}
}
types = in.readStringArray();
if (in.getVersion().before(Version.V_8_0_0)) {
in.readStringArray();
}
groups = in.readStringArray();
fieldDataFields = in.readStringArray();
completionDataFields = in.readStringArray();
Expand All @@ -77,7 +79,9 @@ public void writeTo(StreamOutput out) throws IOException {
}
out.writeLong(longFlags);

out.writeStringArrayNullable(types);
if (out.getVersion().before(Version.V_8_0_0)) {
out.writeStringArrayNullable(Strings.EMPTY_ARRAY);
}
out.writeStringArrayNullable(groups);
out.writeStringArrayNullable(fieldDataFields);
out.writeStringArrayNullable(completionDataFields);
Expand All @@ -92,7 +96,6 @@ public void writeTo(StreamOutput out) throws IOException {
*/
public CommonStatsFlags all() {
flags = EnumSet.allOf(Flag.class);
types = null;
groups = null;
fieldDataFields = null;
completionDataFields = null;
Expand All @@ -106,7 +109,6 @@ public CommonStatsFlags all() {
*/
public CommonStatsFlags clear() {
flags = EnumSet.noneOf(Flag.class);
types = null;
groups = null;
fieldDataFields = null;
completionDataFields = null;
Expand All @@ -123,23 +125,6 @@ public Flag[] getFlags() {
return flags.toArray(new Flag[flags.size()]);
}

/**
* Document types to return stats for. Mainly affects {@link Flag#Indexing} when
* enabled, returning specific indexing stats for those types.
*/
public CommonStatsFlags types(String... types) {
this.types = types;
return this;
}

/**
* Document types to return stats for. Mainly affects {@link Flag#Indexing} when
* enabled, returning specific indexing stats for those types.
*/
public String[] types() {
return this.types;
}

/**
* Sets specific search group stats to retrieve the stats for. Mainly affects search
* when enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,6 @@ public IndicesStatsRequest flags(CommonStatsFlags flags) {
return this;
}

/**
* Document types to return stats for. Mainly affects {@link #indexing(boolean)} when
* enabled, returning specific indexing stats for those types.
*/
public IndicesStatsRequest types(String... types) {
flags.types(types);
return this;
}

/**
* Document types to return stats for. Mainly affects {@link #indexing(boolean)} when
* enabled, returning specific indexing stats for those types.
*/
public String[] types() {
return this.flags.types();
}

/**
* Sets specific search group stats to retrieve the stats for. Mainly affects search
* when enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,6 @@ public IndicesStatsRequestBuilder clear() {
return this;
}

/**
* Document types to return stats for. Mainly affects {@link #setIndexing(boolean)} when
* enabled, returning specific indexing stats for those types.
*/
public IndicesStatsRequestBuilder setTypes(String... types) {
request.types(types);
return this;
}

public IndicesStatsRequestBuilder setGroups(String... groups) {
request.groups(groups);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ protected void shardOperation(final UpdateRequest request, final ActionListener<
if (indexServiceOrNull != null) {
IndexShard shard = indexService.getShardOrNull(shardId.getId());
if (shard != null) {
shard.noopUpdate(request.type());
shard.noopUpdate();
}
}
listener.onResponse(update);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ public SeqNoStats seqNoStats() {
return getEngine().getSeqNoStats(replicationTracker.getGlobalCheckpoint());
}

public IndexingStats indexingStats(String... types) {
public IndexingStats indexingStats() {
Engine engine = getEngineOrNull();
final boolean throttled;
final long throttleTimeInMillis;
Expand All @@ -996,7 +996,7 @@ public IndexingStats indexingStats(String... types) {
throttled = engine.isThrottled();
throttleTimeInMillis = engine.getIndexThrottleTimeInMillis();
}
return internalIndexingStats.stats(throttled, throttleTimeInMillis, types);
return internalIndexingStats.stats(throttled, throttleTimeInMillis);
}

public SearchStats searchStats(String... groups) {
Expand Down Expand Up @@ -2387,11 +2387,9 @@ public boolean pendingInSync() {

/**
* Should be called for each no-op update operation to increment relevant statistics.
*
* @param type the doc type of the update
*/
public void noopUpdate(String type) {
internalIndexingStats.noopUpdate(type);
public void noopUpdate() {
internalIndexingStats.noopUpdate();
}

public void maybeCheckIndex() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@

package org.elasticsearch.index.shard;

import org.elasticsearch.common.Nullable;
import org.elasticsearch.Version;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.ToXContentFragment;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.mapper.MapperService;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

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

private final Stats totalStats;

@Nullable
private Map<String, Stats> typeStats;

public IndexingStats() {
totalStats = new Stats();
}

public IndexingStats(StreamInput in) throws IOException {
totalStats = new Stats(in);
if (in.readBoolean()) {
typeStats = in.readMap(StreamInput::readString, Stats::new);
if (in.getVersion().before(Version.V_8_0_0)) {
if (in.readBoolean()) {
Map<String, Stats> typeStats = in.readMap(StreamInput::readString, Stats::new);
assert typeStats.size() == 1;
assert typeStats.containsKey(MapperService.SINGLE_MAPPING_NAME);
}
}
}

public IndexingStats(Stats totalStats, @Nullable Map<String, Stats> typeStats) {
public IndexingStats(Stats totalStats) {
this.totalStats = totalStats;
this.typeStats = typeStats;
}

public void add(IndexingStats indexingStats) {
add(indexingStats, true);
}

public void add(IndexingStats indexingStats, boolean includeTypes) {
if (indexingStats == null) {
return;
}
addTotals(indexingStats);
if (includeTypes && indexingStats.typeStats != null && !indexingStats.typeStats.isEmpty()) {
if (typeStats == null) {
typeStats = new HashMap<>(indexingStats.typeStats.size());
}
for (Map.Entry<String, Stats> entry : indexingStats.typeStats.entrySet()) {
Stats stats = typeStats.get(entry.getKey());
if (stats == null) {
typeStats.put(entry.getKey(), entry.getValue());
} else {
stats.add(entry.getValue());
}
}
}
}

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

@Nullable
public Map<String, Stats> getTypeStats() {
return this.typeStats;
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
builder.startObject(Fields.INDEXING);
totalStats.toXContent(builder, params);
if (typeStats != null && !typeStats.isEmpty()) {
builder.startObject(Fields.TYPES);
for (Map.Entry<String, Stats> entry : typeStats.entrySet()) {
builder.startObject(entry.getKey());
entry.getValue().toXContent(builder, params);
builder.endObject();
}
builder.endObject();
}
builder.endObject();
return builder;
}

static final class Fields {
static final String INDEXING = "indexing";
static final String TYPES = "types";
static final String INDEX_TOTAL = "index_total";
static final String INDEX_TIME = "index_time";
static final String INDEX_TIME_IN_MILLIS = "index_time_in_millis";
Expand All @@ -279,11 +247,8 @@ static final class Fields {
@Override
public void writeTo(StreamOutput out) throws IOException {
totalStats.writeTo(out);
if (typeStats == null || typeStats.isEmpty()) {
if (out.getVersion().before(Version.V_8_0_0)) {
out.writeBoolean(false);
} else {
out.writeBoolean(true);
out.writeMap(typeStats, StreamOutput::writeString, (stream, stats) -> stats.writeTo(stream));
}
}
}
Loading