|
@@ -19,6 +19,7 @@
|
|
|
|
|
|
package org.elasticsearch.index.engine;
|
|
|
|
|
|
+import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
|
import org.elasticsearch.common.io.stream.Streamable;
|
|
@@ -36,6 +37,8 @@ public class SegmentsStats implements Streamable, ToXContent {
|
|
|
|
|
|
private long count;
|
|
|
private long memoryInBytes;
|
|
|
+ private long indexWriterMemoryInBytes;
|
|
|
+ private long versionMapMemoryInBytes;
|
|
|
|
|
|
public SegmentsStats() {
|
|
|
|
|
@@ -46,11 +49,21 @@ public class SegmentsStats implements Streamable, ToXContent {
|
|
|
this.memoryInBytes += memoryInBytes;
|
|
|
}
|
|
|
|
|
|
+ public void addIndexWriterMemoryInBytes(long indexWriterMemoryInBytes) {
|
|
|
+ this.indexWriterMemoryInBytes += indexWriterMemoryInBytes;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void addVersionMapMemoryInBytes(long versionMapMemoryInBytes) {
|
|
|
+ this.versionMapMemoryInBytes += versionMapMemoryInBytes;
|
|
|
+ }
|
|
|
+
|
|
|
public void add(SegmentsStats mergeStats) {
|
|
|
if (mergeStats == null) {
|
|
|
return;
|
|
|
}
|
|
|
add(mergeStats.count, mergeStats.memoryInBytes);
|
|
|
+ addIndexWriterMemoryInBytes(mergeStats.indexWriterMemoryInBytes);
|
|
|
+ addVersionMapMemoryInBytes(mergeStats.versionMapMemoryInBytes);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -71,6 +84,28 @@ public class SegmentsStats implements Streamable, ToXContent {
|
|
|
return new ByteSizeValue(memoryInBytes);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Estimation of the memory usage by index writer
|
|
|
+ */
|
|
|
+ public long getIndexWriterMemoryInBytes() {
|
|
|
+ return this.indexWriterMemoryInBytes;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ByteSizeValue getIndexWriterMemory() {
|
|
|
+ return new ByteSizeValue(indexWriterMemoryInBytes);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Estimation of the memory usage by version map
|
|
|
+ */
|
|
|
+ public long getVersionMapMemoryInBytes() {
|
|
|
+ return this.versionMapMemoryInBytes;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ByteSizeValue getVersionMapMemory() {
|
|
|
+ return new ByteSizeValue(versionMapMemoryInBytes);
|
|
|
+ }
|
|
|
+
|
|
|
public static SegmentsStats readSegmentsStats(StreamInput in) throws IOException {
|
|
|
SegmentsStats stats = new SegmentsStats();
|
|
|
stats.readFrom(in);
|
|
@@ -82,6 +117,8 @@ public class SegmentsStats implements Streamable, ToXContent {
|
|
|
builder.startObject(Fields.SEGMENTS);
|
|
|
builder.field(Fields.COUNT, count);
|
|
|
builder.byteSizeField(Fields.MEMORY_IN_BYTES, Fields.MEMORY, memoryInBytes);
|
|
|
+ builder.byteSizeField(Fields.INDEX_WRITER_MEMORY_IN_BYTES, Fields.INDEX_WRITER_MEMORY, indexWriterMemoryInBytes);
|
|
|
+ builder.byteSizeField(Fields.VERSION_MAP_MEMORY_IN_BYTES, Fields.VERSION_MAP_MEMORY, versionMapMemoryInBytes);
|
|
|
builder.endObject();
|
|
|
return builder;
|
|
|
}
|
|
@@ -91,17 +128,29 @@ public class SegmentsStats implements Streamable, ToXContent {
|
|
|
static final XContentBuilderString COUNT = new XContentBuilderString("count");
|
|
|
static final XContentBuilderString MEMORY = new XContentBuilderString("memory");
|
|
|
static final XContentBuilderString MEMORY_IN_BYTES = new XContentBuilderString("memory_in_bytes");
|
|
|
+ static final XContentBuilderString INDEX_WRITER_MEMORY = new XContentBuilderString("index_writer_memory");
|
|
|
+ static final XContentBuilderString INDEX_WRITER_MEMORY_IN_BYTES = new XContentBuilderString("index_writer_memory_in_bytes");
|
|
|
+ static final XContentBuilderString VERSION_MAP_MEMORY = new XContentBuilderString("version_map_memory");
|
|
|
+ static final XContentBuilderString VERSION_MAP_MEMORY_IN_BYTES = new XContentBuilderString("version_map_memory_in_bytes");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void readFrom(StreamInput in) throws IOException {
|
|
|
count = in.readVLong();
|
|
|
memoryInBytes = in.readLong();
|
|
|
+ if (in.getVersion().onOrAfter(Version.V_1_3_0)) {
|
|
|
+ indexWriterMemoryInBytes = in.readLong();
|
|
|
+ versionMapMemoryInBytes = in.readLong();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void writeTo(StreamOutput out) throws IOException {
|
|
|
out.writeVLong(count);
|
|
|
out.writeLong(memoryInBytes);
|
|
|
+ if (out.getVersion().onOrAfter(Version.V_1_3_0)) {
|
|
|
+ out.writeLong(indexWriterMemoryInBytes);
|
|
|
+ out.writeLong(versionMapMemoryInBytes);
|
|
|
+ }
|
|
|
}
|
|
|
}
|