Index Status: Add primary store size to include only primary shards store sizes, also move index store and translog into their own elements, closes #666.
This commit is contained in:
parent
13869239b0
commit
5fe2615ba7
|
@ -23,7 +23,7 @@ import org.elasticsearch.action.support.nodes.NodeOperationResponse;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.indices.IndicesStats;
|
import org.elasticsearch.indices.NodeIndicesStats;
|
||||||
import org.elasticsearch.monitor.jvm.JvmStats;
|
import org.elasticsearch.monitor.jvm.JvmStats;
|
||||||
import org.elasticsearch.monitor.network.NetworkStats;
|
import org.elasticsearch.monitor.network.NetworkStats;
|
||||||
import org.elasticsearch.monitor.os.OsStats;
|
import org.elasticsearch.monitor.os.OsStats;
|
||||||
|
@ -40,7 +40,7 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public class NodeStats extends NodeOperationResponse {
|
public class NodeStats extends NodeOperationResponse {
|
||||||
|
|
||||||
private IndicesStats indices;
|
private NodeIndicesStats indices;
|
||||||
|
|
||||||
private OsStats os;
|
private OsStats os;
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class NodeStats extends NodeOperationResponse {
|
||||||
NodeStats() {
|
NodeStats() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeStats(DiscoveryNode node, IndicesStats indices,
|
public NodeStats(DiscoveryNode node, NodeIndicesStats indices,
|
||||||
OsStats os, ProcessStats process, JvmStats jvm, NetworkStats network,
|
OsStats os, ProcessStats process, JvmStats jvm, NetworkStats network,
|
||||||
ThreadPoolStats threadPool, TransportStats transport) {
|
ThreadPoolStats threadPool, TransportStats transport) {
|
||||||
super(node);
|
super(node);
|
||||||
|
@ -73,14 +73,14 @@ public class NodeStats extends NodeOperationResponse {
|
||||||
/**
|
/**
|
||||||
* Indices level stats.
|
* Indices level stats.
|
||||||
*/
|
*/
|
||||||
public IndicesStats indices() {
|
public NodeIndicesStats indices() {
|
||||||
return this.indices;
|
return this.indices;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indices level stats.
|
* Indices level stats.
|
||||||
*/
|
*/
|
||||||
public IndicesStats getIndices() {
|
public NodeIndicesStats getIndices() {
|
||||||
return indices();
|
return indices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ public class NodeStats extends NodeOperationResponse {
|
||||||
@Override public void readFrom(StreamInput in) throws IOException {
|
@Override public void readFrom(StreamInput in) throws IOException {
|
||||||
super.readFrom(in);
|
super.readFrom(in);
|
||||||
if (in.readBoolean()) {
|
if (in.readBoolean()) {
|
||||||
indices = IndicesStats.readIndicesStats(in);
|
indices = NodeIndicesStats.readIndicesStats(in);
|
||||||
}
|
}
|
||||||
if (in.readBoolean()) {
|
if (in.readBoolean()) {
|
||||||
os = OsStats.readOsStats(in);
|
os = OsStats.readOsStats(in);
|
||||||
|
|
|
@ -59,6 +59,39 @@ public class IndexShardStatus implements Iterable<ShardStatus> {
|
||||||
return shards[position];
|
return shards[position];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns only the primary shards store size in bytes.
|
||||||
|
*/
|
||||||
|
public ByteSizeValue primaryStoreSize() {
|
||||||
|
long bytes = -1;
|
||||||
|
for (ShardStatus shard : shards()) {
|
||||||
|
if (!shard.shardRouting().primary()) {
|
||||||
|
// only sum docs for the primaries
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (shard.storeSize() != null) {
|
||||||
|
if (bytes == -1) {
|
||||||
|
bytes = 0;
|
||||||
|
}
|
||||||
|
bytes += shard.storeSize().bytes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bytes == -1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new ByteSizeValue(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns only the primary shards store size in bytes.
|
||||||
|
*/
|
||||||
|
public ByteSizeValue getPrimaryStoreSize() {
|
||||||
|
return primaryStoreSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the full store size in bytes, of both primaries and replicas.
|
||||||
|
*/
|
||||||
public ByteSizeValue storeSize() {
|
public ByteSizeValue storeSize() {
|
||||||
long bytes = -1;
|
long bytes = -1;
|
||||||
for (ShardStatus shard : shards()) {
|
for (ShardStatus shard : shards()) {
|
||||||
|
@ -75,6 +108,9 @@ public class IndexShardStatus implements Iterable<ShardStatus> {
|
||||||
return new ByteSizeValue(bytes);
|
return new ByteSizeValue(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the full store size in bytes, of both primaries and replicas.
|
||||||
|
*/
|
||||||
public ByteSizeValue getStoreSize() {
|
public ByteSizeValue getStoreSize() {
|
||||||
return storeSize();
|
return storeSize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,35 @@ public class IndexStatus implements Iterable<IndexShardStatus> {
|
||||||
return settings();
|
return settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns only the primary shards store size in bytes.
|
||||||
|
*/
|
||||||
|
public ByteSizeValue primaryStoreSize() {
|
||||||
|
long bytes = -1;
|
||||||
|
for (IndexShardStatus shard : this) {
|
||||||
|
if (shard.primaryStoreSize() != null) {
|
||||||
|
if (bytes == -1) {
|
||||||
|
bytes = 0;
|
||||||
|
}
|
||||||
|
bytes += shard.primaryStoreSize().bytes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bytes == -1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new ByteSizeValue(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns only the primary shards store size in bytes.
|
||||||
|
*/
|
||||||
|
public ByteSizeValue getPrimaryStoreSize() {
|
||||||
|
return primaryStoreSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the full store size in bytes, of both primaries and replicas.
|
||||||
|
*/
|
||||||
public ByteSizeValue storeSize() {
|
public ByteSizeValue storeSize() {
|
||||||
long bytes = -1;
|
long bytes = -1;
|
||||||
for (IndexShardStatus shard : this) {
|
for (IndexShardStatus shard : this) {
|
||||||
|
@ -103,6 +132,9 @@ public class IndexStatus implements Iterable<IndexShardStatus> {
|
||||||
return new ByteSizeValue(bytes);
|
return new ByteSizeValue(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the full store size in bytes, of both primaries and replicas.
|
||||||
|
*/
|
||||||
public ByteSizeValue getStoreSize() {
|
public ByteSizeValue getStoreSize() {
|
||||||
return storeSize();
|
return storeSize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public interface IndicesService extends Iterable<IndexService>, LifecycleCompone
|
||||||
*/
|
*/
|
||||||
public boolean changesAllowed();
|
public boolean changesAllowed();
|
||||||
|
|
||||||
IndicesStats stats();
|
NodeIndicesStats stats();
|
||||||
|
|
||||||
boolean hasIndex(String index);
|
boolean hasIndex(String index);
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ public class InternalIndicesService extends AbstractLifecycleComponent<IndicesSe
|
||||||
return this.indicesLifecycle;
|
return this.indicesLifecycle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public IndicesStats stats() {
|
@Override public NodeIndicesStats stats() {
|
||||||
long storeTotalSize = 0;
|
long storeTotalSize = 0;
|
||||||
long fieldCacheEvictions = 0;
|
long fieldCacheEvictions = 0;
|
||||||
long fieldCacheTotalSize = 0;
|
long fieldCacheTotalSize = 0;
|
||||||
|
@ -174,7 +174,7 @@ public class InternalIndicesService extends AbstractLifecycleComponent<IndicesSe
|
||||||
fieldCacheTotalSize += indexService.cache().fieldData().sizeInBytes();
|
fieldCacheTotalSize += indexService.cache().fieldData().sizeInBytes();
|
||||||
filterCacheTotalSize += indexService.cache().filter().sizeInBytes();
|
filterCacheTotalSize += indexService.cache().filter().sizeInBytes();
|
||||||
}
|
}
|
||||||
return new IndicesStats(new ByteSizeValue(storeTotalSize), new ByteSizeValue(fieldCacheTotalSize), new ByteSizeValue(filterCacheTotalSize), fieldCacheEvictions);
|
return new NodeIndicesStats(new ByteSizeValue(storeTotalSize), new ByteSizeValue(fieldCacheTotalSize), new ByteSizeValue(filterCacheTotalSize), fieldCacheEvictions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,7 +35,7 @@ import java.io.Serializable;
|
||||||
*
|
*
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class IndicesStats implements Streamable, Serializable, ToXContent {
|
public class NodeIndicesStats implements Streamable, Serializable, ToXContent {
|
||||||
|
|
||||||
private ByteSizeValue storeSize;
|
private ByteSizeValue storeSize;
|
||||||
|
|
||||||
|
@ -45,11 +45,11 @@ public class IndicesStats implements Streamable, Serializable, ToXContent {
|
||||||
|
|
||||||
private long fieldCacheEvictions;
|
private long fieldCacheEvictions;
|
||||||
|
|
||||||
IndicesStats() {
|
NodeIndicesStats() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndicesStats(ByteSizeValue storeSize, ByteSizeValue fieldCacheSize, ByteSizeValue filterCacheSize,
|
public NodeIndicesStats(ByteSizeValue storeSize, ByteSizeValue fieldCacheSize, ByteSizeValue filterCacheSize,
|
||||||
long fieldCacheEvictions) {
|
long fieldCacheEvictions) {
|
||||||
this.storeSize = storeSize;
|
this.storeSize = storeSize;
|
||||||
this.fieldCacheSize = fieldCacheSize;
|
this.fieldCacheSize = fieldCacheSize;
|
||||||
this.filterCacheSize = filterCacheSize;
|
this.filterCacheSize = filterCacheSize;
|
||||||
|
@ -94,8 +94,8 @@ public class IndicesStats implements Streamable, Serializable, ToXContent {
|
||||||
return fieldCacheEvictions();
|
return fieldCacheEvictions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IndicesStats readIndicesStats(StreamInput in) throws IOException {
|
public static NodeIndicesStats readIndicesStats(StreamInput in) throws IOException {
|
||||||
IndicesStats stats = new IndicesStats();
|
NodeIndicesStats stats = new NodeIndicesStats();
|
||||||
stats.readFrom(in);
|
stats.readFrom(in);
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
|
@ -85,12 +85,18 @@ public class RestIndicesStatusAction extends BaseRestHandler {
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
|
|
||||||
|
builder.startObject("index");
|
||||||
if (indexStatus.storeSize() != null) {
|
if (indexStatus.storeSize() != null) {
|
||||||
builder.field("store_size", indexStatus.storeSize().toString());
|
builder.field("primary_size", indexStatus.primaryStoreSize().toString());
|
||||||
builder.field("store_size_in_bytes", indexStatus.storeSize().bytes());
|
builder.field("primary_size_in_bytes", indexStatus.primaryStoreSize().bytes());
|
||||||
|
builder.field("size", indexStatus.storeSize().toString());
|
||||||
|
builder.field("size_in_bytes", indexStatus.storeSize().bytes());
|
||||||
}
|
}
|
||||||
|
builder.endObject();
|
||||||
if (indexStatus.translogOperations() != -1) {
|
if (indexStatus.translogOperations() != -1) {
|
||||||
builder.field("translog_operations", indexStatus.translogOperations());
|
builder.startObject("translog");
|
||||||
|
builder.field("operations", indexStatus.translogOperations());
|
||||||
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indexStatus.docs() != null) {
|
if (indexStatus.docs() != null) {
|
||||||
|
|
Loading…
Reference in New Issue