Skip to content

Commit

Permalink
add peer recovery status to the indices status API exposing both on g…
Browse files Browse the repository at this point in the history
…oing and summary when recovering from a peer shard
  • Loading branch information
kimchy committed Aug 17, 2010
1 parent 5fb80c3 commit 311520d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
Expand Up @@ -112,7 +112,7 @@ public static Stage fromValue(byte value) {

final long startTime;

final long took;
final long time;

final long retryTime;

Expand All @@ -124,11 +124,11 @@ public static Stage fromValue(byte value) {

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;
Expand All @@ -148,12 +148,12 @@ public long getStartTime() {
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() {
Expand Down Expand Up @@ -321,7 +321,7 @@ public static ShardStatus readIndexShardStatus(StreamInput in) throws IOExceptio
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);
Expand Down
Expand Up @@ -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());
}
Expand Down
Expand Up @@ -43,7 +43,7 @@ public static enum Stage {
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;
Expand All @@ -60,8 +60,8 @@ public long startTime() {
return startTime;
}

public long took() {
return this.took;
public long time() {
return this.time;
}

public long retryTime() {
Expand Down
Expand Up @@ -103,7 +103,15 @@ public static class Actions {
}

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) {
Expand Down Expand Up @@ -313,7 +321,7 @@ class FinalizeRecoveryRequestHandler extends BaseTransportRequestHandler<Recover
}
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);
}
Expand Down
Expand Up @@ -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());

Expand Down

0 comments on commit 311520d

Please sign in to comment.