moe internal stats on translog

This commit is contained in:
kimchy 2011-01-29 04:04:58 +02:00
parent 332c4cfa53
commit 4a27671d0c
4 changed files with 12 additions and 8 deletions

View File

@ -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;

View File

@ -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")

View File

@ -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

View File

@ -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() {