|
@@ -8,6 +8,7 @@
|
|
|
|
|
|
package org.elasticsearch.index.flush;
|
|
|
|
|
|
+import org.elasticsearch.TransportVersions;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
|
import org.elasticsearch.common.io.stream.Writeable;
|
|
@@ -23,6 +24,7 @@ public class FlushStats implements Writeable, ToXContentFragment {
|
|
|
private long total;
|
|
|
private long periodic;
|
|
|
private long totalTimeInMillis;
|
|
|
+ private long totalTimeExcludingWaitingOnLockInMillis;
|
|
|
|
|
|
public FlushStats() {
|
|
|
|
|
@@ -32,18 +34,22 @@ public class FlushStats implements Writeable, ToXContentFragment {
|
|
|
total = in.readVLong();
|
|
|
totalTimeInMillis = in.readVLong();
|
|
|
periodic = in.readVLong();
|
|
|
+ totalTimeExcludingWaitingOnLockInMillis = in.getTransportVersion()
|
|
|
+ .onOrAfter(TransportVersions.TRACK_FLUSH_TIME_EXCLUDING_WAITING_ON_LOCKS) ? in.readVLong() : 0L;
|
|
|
}
|
|
|
|
|
|
- public FlushStats(long total, long periodic, long totalTimeInMillis) {
|
|
|
+ public FlushStats(long total, long periodic, long totalTimeInMillis, long totalTimeExcludingWaitingOnLockInMillis) {
|
|
|
this.total = total;
|
|
|
this.periodic = periodic;
|
|
|
this.totalTimeInMillis = totalTimeInMillis;
|
|
|
+ this.totalTimeExcludingWaitingOnLockInMillis = totalTimeExcludingWaitingOnLockInMillis;
|
|
|
}
|
|
|
|
|
|
- public void add(long total, long periodic, long totalTimeInMillis) {
|
|
|
+ public void add(long total, long periodic, long totalTimeInMillis, long totalTimeWithoutWaitingInMillis) {
|
|
|
this.total += total;
|
|
|
this.periodic += periodic;
|
|
|
this.totalTimeInMillis += totalTimeInMillis;
|
|
|
+ this.totalTimeExcludingWaitingOnLockInMillis += totalTimeWithoutWaitingInMillis;
|
|
|
}
|
|
|
|
|
|
public void add(FlushStats flushStats) {
|
|
@@ -57,6 +63,7 @@ public class FlushStats implements Writeable, ToXContentFragment {
|
|
|
this.total += flushStats.total;
|
|
|
this.periodic += flushStats.periodic;
|
|
|
this.totalTimeInMillis += flushStats.totalTimeInMillis;
|
|
|
+ this.totalTimeExcludingWaitingOnLockInMillis += flushStats.totalTimeExcludingWaitingOnLockInMillis;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -81,18 +88,30 @@ public class FlushStats implements Writeable, ToXContentFragment {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * The total time merges have been executed.
|
|
|
+ * The total time flushes have been executed.
|
|
|
*/
|
|
|
public TimeValue getTotalTime() {
|
|
|
return new TimeValue(totalTimeInMillis);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * The total time flushes have been executed excluding waiting time on locks (in milliseconds).
|
|
|
+ */
|
|
|
+ public long getTotalTimeExcludingWaitingOnLockMillis() {
|
|
|
+ return totalTimeExcludingWaitingOnLockInMillis;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
|
builder.startObject(Fields.FLUSH);
|
|
|
builder.field(Fields.TOTAL, total);
|
|
|
builder.field(Fields.PERIODIC, periodic);
|
|
|
builder.humanReadableField(Fields.TOTAL_TIME_IN_MILLIS, Fields.TOTAL_TIME, getTotalTime());
|
|
|
+ builder.humanReadableField(
|
|
|
+ Fields.TOTAL_TIME_EXCLUDING_WAITING_ON_LOCK_IN_MILLIS,
|
|
|
+ Fields.TOTAL_TIME_EXCLUDING_WAITING,
|
|
|
+ new TimeValue(getTotalTimeExcludingWaitingOnLockMillis())
|
|
|
+ );
|
|
|
builder.endObject();
|
|
|
return builder;
|
|
|
}
|
|
@@ -103,6 +122,8 @@ public class FlushStats implements Writeable, ToXContentFragment {
|
|
|
static final String PERIODIC = "periodic";
|
|
|
static final String TOTAL_TIME = "total_time";
|
|
|
static final String TOTAL_TIME_IN_MILLIS = "total_time_in_millis";
|
|
|
+ static final String TOTAL_TIME_EXCLUDING_WAITING = "total_time_excluding_waiting";
|
|
|
+ static final String TOTAL_TIME_EXCLUDING_WAITING_ON_LOCK_IN_MILLIS = "total_time_excluding_waiting_on_lock_in_millis";
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -110,6 +131,9 @@ public class FlushStats implements Writeable, ToXContentFragment {
|
|
|
out.writeVLong(total);
|
|
|
out.writeVLong(totalTimeInMillis);
|
|
|
out.writeVLong(periodic);
|
|
|
+ if (out.getTransportVersion().onOrAfter(TransportVersions.TRACK_FLUSH_TIME_EXCLUDING_WAITING_ON_LOCKS)) {
|
|
|
+ out.writeVLong(totalTimeExcludingWaitingOnLockInMillis);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -117,11 +141,14 @@ public class FlushStats implements Writeable, ToXContentFragment {
|
|
|
if (this == o) return true;
|
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
|
FlushStats that = (FlushStats) o;
|
|
|
- return total == that.total && totalTimeInMillis == that.totalTimeInMillis && periodic == that.periodic;
|
|
|
+ return total == that.total
|
|
|
+ && totalTimeInMillis == that.totalTimeInMillis
|
|
|
+ && periodic == that.periodic
|
|
|
+ && totalTimeExcludingWaitingOnLockInMillis == that.totalTimeExcludingWaitingOnLockInMillis;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int hashCode() {
|
|
|
- return Objects.hash(total, totalTimeInMillis, periodic);
|
|
|
+ return Objects.hash(total, totalTimeInMillis, periodic, totalTimeExcludingWaitingOnLockInMillis);
|
|
|
}
|
|
|
}
|