add peer recovery status to the indices status API exposing both on going and summary when recovering from a peer shard

This commit is contained in:
kimchy 2010-08-17 21:33:11 +03:00
parent 5fb80c391b
commit 311520d146
5 changed files with 24 additions and 18 deletions

View File

@ -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);

View File

@ -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());
}

View File

@ -43,7 +43,7 @@ public class PeerRecoveryStatus {
ConcurrentMap<String, IndexOutput> openIndexOutputs = ConcurrentCollections.newConcurrentMap();
final long startTime = System.currentTimeMillis();
long took;
long time;
volatile long retryTime = 0;
List<String> phase1FileNames;
List<Long> 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() {

View File

@ -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);
}

View File

@ -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());