Skip to content

Commit

Permalink
Increment RepairRun.completedSegments on finished segment
Browse files Browse the repository at this point in the history
  • Loading branch information
Bj0rnen committed Dec 12, 2014
1 parent be31956 commit 4eb44a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/main/java/com/spotify/reaper/core/RepairRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@ public int getCompletedSegments() {
}

public static RepairRun getCopy(RepairRun repairRun, RunState newState,
DateTime startTime, DateTime endTime,
int totalSegments, int completedSegments) {
DateTime startTime, DateTime endTime, int completedSegments) {
return new RepairRun.Builder(newState,
repairRun.getCreationTime(), repairRun.getIntensity(),
totalSegments, completedSegments)
repairRun.getTotalSegments(), completedSegments)
.cause(repairRun.getCause())
.owner(repairRun.getOwner())
.startTime(startTime)
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/spotify/reaper/service/RepairRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ private void changeCurrentRepairRunState(RepairRun.RunState newRunState) {
updatedRun =
RepairRun
.getCopy(repairRun, newRunState, newStartTime, newEndTime,
repairRun.getTotalSegments(), repairRun.getCompletedSegments());
repairRun.getCompletedSegments());
if (!storage.updateRepairRun(updatedRun)) {
LOG.error("failed updating repair run status: {}", repairRun.getId());
// TODO: what should we do if we fail to update storage?
Expand Down Expand Up @@ -308,6 +308,10 @@ public void handle(int repairNumber, ActiveRepairService.Status status, String m
currentSegment.getRepairCommandId(),
currentSegment.getStartTime(), DateTime.now());
storage.updateRepairSegment(currentSegment);
repairRun =
RepairRun.getCopy(repairRun, repairRun.getState(), repairRun.getStartTime(),
repairRun.getEndTime(), repairRun.getCompletedSegments() + 1);
storage.updateRepairRun(repairRun);
checkIfNeedToStartNextSegment();
break;
}
Expand Down

0 comments on commit 4eb44a6

Please sign in to comment.