diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/status/ShardStatus.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/status/ShardStatus.java index 882b74d25b4..be39f8bd430 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/status/ShardStatus.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/status/ShardStatus.java @@ -112,7 +112,7 @@ public class ShardStatus extends BroadcastShardOperationResponse { final long startTime; - final long took; + final long time; final long retryTime; @@ -124,11 +124,11 @@ public class ShardStatus extends BroadcastShardOperationResponse { final long recoveredTranslogOperations; - public PeerRecoveryStatus(Stage stage, long startTime, long took, long retryTime, long indexSize, long reusedIndexSize, + public PeerRecoveryStatus(Stage stage, long startTime, long time, long retryTime, long indexSize, long reusedIndexSize, long recoveredIndexSize, long recoveredTranslogOperations) { this.stage = stage; this.startTime = startTime; - this.took = took; + this.time = time; this.retryTime = retryTime; this.indexSize = indexSize; this.reusedIndexSize = reusedIndexSize; @@ -148,12 +148,12 @@ public class ShardStatus extends BroadcastShardOperationResponse { return this.startTime; } - public TimeValue took() { - return TimeValue.timeValueMillis(took); + public TimeValue time() { + return TimeValue.timeValueMillis(time); } - public TimeValue getTook() { - return took(); + public TimeValue getTime() { + return time(); } public TimeValue retryTime() { @@ -321,7 +321,7 @@ public class ShardStatus extends BroadcastShardOperationResponse { out.writeBoolean(true); out.writeByte(peerRecoveryStatus.stage.value); out.writeVLong(peerRecoveryStatus.startTime); - out.writeVLong(peerRecoveryStatus.took); + out.writeVLong(peerRecoveryStatus.time); out.writeVLong(peerRecoveryStatus.retryTime); out.writeVLong(peerRecoveryStatus.indexSize); out.writeVLong(peerRecoveryStatus.reusedIndexSize); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java index 466e4c9b356..e5db74b8c13 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java @@ -172,7 +172,7 @@ public class TransportIndicesStatusAction extends TransportBroadcastOperationAct default: stage = ShardStatus.PeerRecoveryStatus.Stage.INIT; } - shardStatus.peerRecoveryStatus = new ShardStatus.PeerRecoveryStatus(stage, peerRecoveryStatus.startTime(), peerRecoveryStatus.took(), + shardStatus.peerRecoveryStatus = new ShardStatus.PeerRecoveryStatus(stage, peerRecoveryStatus.startTime(), peerRecoveryStatus.time(), peerRecoveryStatus.retryTime(), peerRecoveryStatus.phase1TotalSize(), peerRecoveryStatus.phase1ExistingTotalSize(), peerRecoveryStatus.currentFilesSize(), peerRecoveryStatus.currentTranslogOperations()); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/PeerRecoveryStatus.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/PeerRecoveryStatus.java index e64b99c4c56..1a5251badf3 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/PeerRecoveryStatus.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/PeerRecoveryStatus.java @@ -43,7 +43,7 @@ public class PeerRecoveryStatus { ConcurrentMap openIndexOutputs = ConcurrentCollections.newConcurrentMap(); final long startTime = System.currentTimeMillis(); - long took; + long time; volatile long retryTime = 0; List phase1FileNames; List phase1FileSizes; @@ -60,8 +60,8 @@ public class PeerRecoveryStatus { return startTime; } - public long took() { - return this.took; + public long time() { + return this.time; } public long retryTime() { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java index b62574be15e..291e9d6ef71 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java @@ -103,7 +103,15 @@ public class RecoveryTarget extends AbstractComponent { } public PeerRecoveryStatus peerRecoveryStatus(ShardId shardId) { - return onGoingRecoveries.get(shardId); + PeerRecoveryStatus peerRecoveryStatus = onGoingRecoveries.get(shardId); + if (peerRecoveryStatus == null) { + return null; + } + // update how long it takes if we are still recovering... + if (peerRecoveryStatus.startTime > 0 && peerRecoveryStatus.stage != PeerRecoveryStatus.Stage.DONE) { + peerRecoveryStatus.time = System.currentTimeMillis() - peerRecoveryStatus.startTime; + } + return peerRecoveryStatus; } public void startRecovery(final StartRecoveryRequest request, final boolean fromRetry, final RecoveryListener listener) { @@ -313,7 +321,7 @@ public class RecoveryTarget extends AbstractComponent { } peerRecoveryStatus.stage = PeerRecoveryStatus.Stage.FINALIZE; shard.performRecoveryFinalization(false, peerRecoveryStatus); - peerRecoveryStatus.took = System.currentTimeMillis() - peerRecoveryStatus.startTime; + peerRecoveryStatus.time = System.currentTimeMillis() - peerRecoveryStatus.startTime; peerRecoveryStatus.stage = PeerRecoveryStatus.Stage.DONE; channel.sendResponse(VoidStreamable.INSTANCE); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/indices/status/RestIndicesStatusAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/indices/status/RestIndicesStatusAction.java index 7756ff2b4d1..7808bb50ca5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/indices/status/RestIndicesStatusAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/indices/status/RestIndicesStatusAction.java @@ -143,10 +143,8 @@ public class RestIndicesStatusAction extends BaseRestHandler { builder.startObject("peer_recovery"); builder.field("stage", peerRecoveryStatus.stage()); builder.field("start_time_in_millis", peerRecoveryStatus.startTime()); - if (peerRecoveryStatus.took().millis() > 0) { - builder.field("took", peerRecoveryStatus.took()); - builder.field("took_in_millis", peerRecoveryStatus.took().millis()); - } + builder.field("time", peerRecoveryStatus.time()); + builder.field("took_in_millis", peerRecoveryStatus.time().millis()); builder.field("retry_time", peerRecoveryStatus.retryTime()); builder.field("retry_time_in_millis", peerRecoveryStatus.retryTime().millis());