Skip to content

Commit

Permalink
wip: Add runHistory to RepairSchedule and fix missing fields in Build…
Browse files Browse the repository at this point in the history
…er's "copy constructor"
  • Loading branch information
Bj0rnen committed Feb 9, 2015
1 parent 4f30af2 commit 4081ecb
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/main/java/com/spotify/reaper/core/RepairSchedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@
*/
package com.spotify.reaper.core;

import com.google.common.collect.Lists;

import org.apache.cassandra.repair.RepairParallelism;
import org.joda.time.DateTime;

import java.util.List;

public class RepairSchedule {

private final long id;
Expand All @@ -24,6 +28,7 @@ public class RepairSchedule {
private final State state;
private final int daysBetween;
private final DateTime nextActivation;
private final List<Long> runHistory;
private final int segmentCount;
private final RepairParallelism repairParallelism;
private final String owner;
Expand All @@ -37,6 +42,7 @@ private RepairSchedule(Builder builder, long id) {
this.state = builder.state;
this.daysBetween = builder.daysBetween;
this.nextActivation = builder.nextActivation;
this.runHistory = builder.runHistory;
this.segmentCount = builder.segmentCount;
this.repairParallelism = builder.repairParallelism;
this.owner = builder.owner;
Expand Down Expand Up @@ -69,6 +75,10 @@ public DateTime getNextActivation() {
return nextActivation;
}

public List<Long> getRunHistory() {
return runHistory;
}

public int getSegmentCount() {
return segmentCount;
}
Expand Down Expand Up @@ -108,6 +118,7 @@ public static class Builder {
private State state;
private int daysBetween;
private DateTime nextActivation;
private List<Long> runHistory;
private int segmentCount;
private RepairParallelism repairParallelism;
private String owner;
Expand All @@ -119,20 +130,24 @@ public Builder(long repairUnitId, State initialState, DateTime creationTime,
int segmentCount, RepairParallelism repairParallelism) {
this.repairUnitId = repairUnitId;
this.state = initialState;
this.creationTime = creationTime;
this.runHistory = Lists.newArrayList();
this.segmentCount = segmentCount;
this.repairParallelism = repairParallelism;
this.creationTime = creationTime;
}

private Builder(RepairSchedule original) {
repairUnitId = original.repairUnitId;
state = original.state;
creationTime = original.creationTime;
daysBetween = original.daysBetween;
nextActivation = original.nextActivation;
runHistory = original.runHistory;
segmentCount = original.segmentCount;
repairParallelism = original.repairParallelism;
owner = original.owner;
creationTime = original.creationTime;
pauseTime = original.pauseTime;
lastEvent = original.lastEvent;
segmentCount = original.segmentCount;
repairParallelism = original.repairParallelism;
}

public Builder runState(State state) {
Expand All @@ -150,6 +165,11 @@ public Builder nextActivation(DateTime nextActivation) {
return this;
}

public Builder addRun(Long newRunId) {
runHistory.add(newRunId);
return this;
}

public Builder segmentCount(int segmentCount) {
this.segmentCount = segmentCount;
return this;
Expand Down

0 comments on commit 4081ecb

Please sign in to comment.