|
|
@@ -23,6 +23,7 @@ import org.elasticsearch.common.Nullable;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
|
import org.elasticsearch.common.io.stream.Streamable;
|
|
|
+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;
|
|
|
@@ -32,9 +33,9 @@ import java.io.IOException;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
-public class IndexingStats implements Streamable, ToXContentFragment {
|
|
|
+public class IndexingStats implements Streamable, Writeable, ToXContentFragment {
|
|
|
|
|
|
- public static class Stats implements Streamable, ToXContentFragment {
|
|
|
+ public static class Stats implements Streamable, Writeable, ToXContentFragment {
|
|
|
|
|
|
private long indexCount;
|
|
|
private long indexTimeInMillis;
|
|
|
@@ -49,6 +50,19 @@ public class IndexingStats implements Streamable, ToXContentFragment {
|
|
|
|
|
|
Stats() {}
|
|
|
|
|
|
+ public Stats(StreamInput in) throws IOException {
|
|
|
+ indexCount = in.readVLong();
|
|
|
+ indexTimeInMillis = in.readVLong();
|
|
|
+ indexCurrent = in.readVLong();
|
|
|
+ indexFailedCount = in.readVLong();
|
|
|
+ deleteCount = in.readVLong();
|
|
|
+ deleteTimeInMillis = in.readVLong();
|
|
|
+ deleteCurrent = in.readVLong();
|
|
|
+ noopUpdateCount = in.readVLong();
|
|
|
+ isThrottled = in.readBoolean();
|
|
|
+ throttleTimeInMillis = in.readLong();
|
|
|
+ }
|
|
|
+
|
|
|
public Stats(long indexCount, long indexTimeInMillis, long indexCurrent, long indexFailedCount, long deleteCount,
|
|
|
long deleteTimeInMillis, long deleteCurrent, long noopUpdateCount, boolean isThrottled, long throttleTimeInMillis) {
|
|
|
this.indexCount = indexCount;
|
|
|
@@ -133,24 +147,9 @@ public class IndexingStats implements Streamable, ToXContentFragment {
|
|
|
return noopUpdateCount;
|
|
|
}
|
|
|
|
|
|
- public static Stats readStats(StreamInput in) throws IOException {
|
|
|
- Stats stats = new Stats();
|
|
|
- stats.readFrom(in);
|
|
|
- return stats;
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public void readFrom(StreamInput in) throws IOException {
|
|
|
- indexCount = in.readVLong();
|
|
|
- indexTimeInMillis = in.readVLong();
|
|
|
- indexCurrent = in.readVLong();
|
|
|
- indexFailedCount = in.readVLong();
|
|
|
- deleteCount = in.readVLong();
|
|
|
- deleteTimeInMillis = in.readVLong();
|
|
|
- deleteCurrent = in.readVLong();
|
|
|
- noopUpdateCount = in.readVLong();
|
|
|
- isThrottled = in.readBoolean();
|
|
|
- throttleTimeInMillis = in.readLong();
|
|
|
+ throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -187,7 +186,7 @@ public class IndexingStats implements Streamable, ToXContentFragment {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private Stats totalStats;
|
|
|
+ private final Stats totalStats;
|
|
|
|
|
|
@Nullable
|
|
|
private Map<String, Stats> typeStats;
|
|
|
@@ -196,6 +195,13 @@ public class IndexingStats implements Streamable, ToXContentFragment {
|
|
|
totalStats = new Stats();
|
|
|
}
|
|
|
|
|
|
+ public IndexingStats(StreamInput in) throws IOException {
|
|
|
+ totalStats = new Stats(in);
|
|
|
+ if (in.readBoolean()) {
|
|
|
+ typeStats = in.readMap(StreamInput::readString, Stats::new);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public IndexingStats(Stats totalStats, @Nullable Map<String, Stats> typeStats) {
|
|
|
this.totalStats = totalStats;
|
|
|
this.typeStats = typeStats;
|
|
|
@@ -278,10 +284,7 @@ public class IndexingStats implements Streamable, ToXContentFragment {
|
|
|
|
|
|
@Override
|
|
|
public void readFrom(StreamInput in) throws IOException {
|
|
|
- totalStats = Stats.readStats(in);
|
|
|
- if (in.readBoolean()) {
|
|
|
- typeStats = in.readMap(StreamInput::readString, Stats::readStats);
|
|
|
- }
|
|
|
+ throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
|
|
}
|
|
|
|
|
|
@Override
|