import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
-public class FollowerLogInformationImpl implements FollowerLogInformation{
+public class FollowerLogInformationImpl implements FollowerLogInformation {
private final String id;
private final long followerTimeoutMillis;
- public FollowerLogInformationImpl(String id, AtomicLong nextIndex,
- AtomicLong matchIndex, FiniteDuration followerTimeoutDuration) {
+ public FollowerLogInformationImpl(String id, long nextIndex,
+ long matchIndex, FiniteDuration followerTimeoutDuration) {
this.id = id;
- this.nextIndex = nextIndex;
- this.matchIndex = matchIndex;
+ this.nextIndex = new AtomicLong(nextIndex);
+ this.matchIndex = new AtomicLong(matchIndex);
this.stopwatch = new Stopwatch();
this.followerTimeoutMillis = followerTimeoutDuration.toMillis();
}
return nextIndex.incrementAndGet();
}
- @Override public long decrNextIndex() {
+ @Override
+ public long decrNextIndex() {
return nextIndex.decrementAndGet();
}
- @Override public void setNextIndex(long nextIndex) {
+ @Override
+ public void setNextIndex(long nextIndex) {
this.nextIndex.set(nextIndex);
}
return matchIndex.incrementAndGet();
}
- @Override public void setMatchIndex(long matchIndex) {
+ @Override
+ public void setMatchIndex(long matchIndex) {
this.matchIndex.set(matchIndex);
}