Skip to content

Commit

Permalink
add progress to indices status API
Browse files Browse the repository at this point in the history
  • Loading branch information
kimchy committed Aug 19, 2010
1 parent 8d0e5b2 commit 7437acf
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
Expand Up @@ -169,6 +169,17 @@ public ByteSizeValue getRecoveredIndexSize() {
return recoveredIndexSize();
}

public int indexRecoveryProgress() {
if (recoveredIndexSize == 0) {
return 0;
}
return (int) (((double) recoveredIndexSize) / expectedRecoveredIndexSize().bytes() * 100);
}

public int getIndexRecoveryProgress() {
return indexRecoveryProgress();
}

public long recoveredTranslogOperations() {
return recoveredTranslogOperations;
}
Expand Down
Expand Up @@ -158,6 +158,17 @@ public ByteSizeValue getRecoveredIndexSize() {
return recoveredIndexSize();
}

public int indexRecoveryProgress() {
if (recoveredIndexSize == 0) {
return 0;
}
return (int) (((double) recoveredIndexSize) / expectedRecoveredIndexSize().bytes() * 100);
}

public int getIndexRecoveryProgress() {
return indexRecoveryProgress();
}

public long recoveredTranslogOperations() {
return recoveredTranslogOperations;
}
Expand Down
Expand Up @@ -138,7 +138,7 @@ public class TransportIndicesStatusAction extends TransportBroadcastOperationAct

@Override protected ShardStatus shardOperation(IndexShardStatusRequest request) throws ElasticSearchException {
InternalIndexService indexService = (InternalIndexService) indicesService.indexServiceSafe(request.index());
InternalIndexShard indexShard = (InternalIndexShard) indexService.shard(request.shardId());
InternalIndexShard indexShard = (InternalIndexShard) indexService.shardSafe(request.shardId());
ShardStatus shardStatus = new ShardStatus(indexShard.routingEntry());
shardStatus.state = indexShard.state();
try {
Expand Down
Expand Up @@ -149,6 +149,7 @@ public class RestIndicesStatusAction extends BaseRestHandler {
builder.field("throttling_time_in_millis", peerRecoveryStatus.throttlingTime().millis());

builder.startObject("index");
builder.field("progress", peerRecoveryStatus.indexRecoveryProgress());
builder.field("size", peerRecoveryStatus.indexSize());
builder.field("size_in_bytes", peerRecoveryStatus.indexSize().bytes());
builder.field("reused_size", peerRecoveryStatus.reusedIndexSize());
Expand Down Expand Up @@ -177,6 +178,7 @@ public class RestIndicesStatusAction extends BaseRestHandler {
builder.field("throttling_time_in_millis", gatewayRecoveryStatus.throttlingTime().millis());

builder.startObject("index");
builder.field("progress", gatewayRecoveryStatus.indexRecoveryProgress());
builder.field("size", gatewayRecoveryStatus.indexSize());
builder.field("size_in_bytes", gatewayRecoveryStatus.indexSize().bytes());
builder.field("reused_size", gatewayRecoveryStatus.reusedIndexSize());
Expand Down

0 comments on commit 7437acf

Please sign in to comment.