diff --git a/src/main/java/org/elasticsearch/action/admin/indices/recovery/TransportRecoveryAction.java b/src/main/java/org/elasticsearch/action/admin/indices/recovery/TransportRecoveryAction.java index 7a79b5ebfc3..8be0ee8d1cd 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/recovery/TransportRecoveryAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/recovery/TransportRecoveryAction.java @@ -157,7 +157,7 @@ public class TransportRecoveryAction extends RecoveryStatus recoveryStatus = indexShard.recoveryStatus(); if (recoveryStatus == null) { - recoveryStatus = recoveryTarget.recoveryStatus(indexShard.shardId()); + recoveryStatus = recoveryTarget.recoveryStatus(indexShard); } if (recoveryStatus != null) { diff --git a/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java b/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java index f7f4816ad42..59739fb9dee 100644 --- a/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java +++ b/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java @@ -544,7 +544,7 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent 0 && peerRecoveryStatus.stage() != RecoveryState.Stage.DONE) { - peerRecoveryStatus.recoveryState().getTimer().time(System.currentTimeMillis() - peerRecoveryStatus.recoveryState().getTimer().startTime()); + if (recoveryStatus.recoveryState().getTimer().startTime() > 0 && recoveryStatus.stage() != RecoveryState.Stage.DONE) { + recoveryStatus.recoveryState().getTimer().time(System.currentTimeMillis() - recoveryStatus.recoveryState().getTimer().startTime()); } - return peerRecoveryStatus; + return recoveryStatus; } public void cancelRecovery(IndexShard indexShard) { @@ -179,7 +178,7 @@ public class RecoveryTarget extends AbstractComponent { } public void retryRecovery(final StartRecoveryRequest request, TimeValue retryAfter, final RecoveryStatus status, final RecoveryListener listener) { - threadPool.schedule(retryAfter, ThreadPool.Names.GENERIC ,new Runnable() { + threadPool.schedule(retryAfter, ThreadPool.Names.GENERIC, new Runnable() { @Override public void run() { doRecovery(request, status, listener); @@ -319,16 +318,6 @@ public class RecoveryTarget extends AbstractComponent { void onRecoveryFailure(RecoveryFailedException e, boolean sendShardFailure); } - @Nullable - private RecoveryStatus findRecoveryByShardId(ShardId shardId) { - for (RecoveryStatus recoveryStatus : onGoingRecoveries.values()) { - if (recoveryStatus.shardId.equals(shardId)) { - return recoveryStatus; - } - } - return null; - } - @Nullable private RecoveryStatus findRecoveryByShard(IndexShard indexShard) { for (RecoveryStatus recoveryStatus : onGoingRecoveries.values()) {