diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java index 64a4526cc2b..acf7e7c40a8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/robin/RobinEngine.java @@ -579,7 +579,7 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine, rwl.readLock().lock(); try { long bytes = IndexWriters.estimateRamSize(indexWriter); - bytes += translog.estimateMemorySize().bytes(); + bytes += translog.memorySizeInBytes(); return new ByteSizeValue(bytes); } catch (Exception e) { return null; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/IndexShardManagement.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/IndexShardManagement.java index 79f6be367e6..eb528e28f4b 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/IndexShardManagement.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/IndexShardManagement.java @@ -22,6 +22,7 @@ package org.elasticsearch.index.shard; import org.elasticsearch.common.component.CloseableComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.shard.service.IndexShard; @@ -97,7 +98,7 @@ public class IndexShardManagement extends AbstractIndexShardComponent implements @ManagedAttribute(description = "Estimated size in memory the transaction log takes") public String getTranslogSize() { - return translog.estimateMemorySize().toString(); + return new ByteSizeValue(translog.memorySizeInBytes()).toString(); } @ManagedAttribute(description = "The state of the shard") diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/translog/Translog.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/translog/Translog.java index 0540e16d5db..98d0a218eb1 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/translog/Translog.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/translog/Translog.java @@ -26,7 +26,6 @@ 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.lease.Releasable; -import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.util.concurrent.NotThreadSafe; import org.elasticsearch.common.util.concurrent.ThreadSafe; import org.elasticsearch.index.engine.Engine; @@ -54,7 +53,9 @@ public interface Translog extends IndexShardComponent { /** * The estimated memory size this translog is taking. */ - ByteSizeValue estimateMemorySize(); + long memorySizeInBytes(); + + long translogSizeInBytes(); /** * Creates a new transaction log internally. Note, users of this class should make diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/translog/fs/FsTranslog.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/translog/fs/FsTranslog.java index 4edd4ef7a67..7634e091c06 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/translog/fs/FsTranslog.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/translog/fs/FsTranslog.java @@ -23,8 +23,6 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.CachedStreamOutput; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.unit.ByteSizeUnit; -import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.shard.AbstractIndexShardComponent; @@ -91,8 +89,12 @@ public class FsTranslog extends AbstractIndexShardComponent implements Translog return operationCounter.get(); } - @Override public ByteSizeValue estimateMemorySize() { - return new ByteSizeValue(0, ByteSizeUnit.BYTES); + @Override public long memorySizeInBytes() { + return 0; + } + + @Override public long translogSizeInBytes() { + return lastWrittenPosition.get(); } @Override public void clearUnreferenced() {