add progress to indices status API
This commit is contained in:
parent
8d0e5b239c
commit
7437acfcea
|
@ -169,6 +169,17 @@ public class GatewayRecoveryStatus {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -158,6 +158,17 @@ public class PeerRecoveryStatus {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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());
|
||||
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue