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);
}
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.controller.cluster.raft.ClientRequestTracker;
import org.opendaylight.controller.cluster.raft.ClientRequestTrackerImpl;
import org.opendaylight.controller.cluster.raft.FollowerLogInformation;
for (String followerId : followers) {
FollowerLogInformation followerLogInformation =
new FollowerLogInformationImpl(followerId,
- new AtomicLong(context.getCommitIndex()),
- new AtomicLong(-1),
+ context.getCommitIndex(), -1,
context.getConfigParams().getElectionTimeOutInterval());
followerToLog.put(followerId, followerLogInformation);
*/
package org.opendaylight.controller.cluster.raft;
-
import com.google.common.base.Stopwatch;
import com.google.common.util.concurrent.Uninterruptibles;
import org.junit.Test;
import scala.concurrent.duration.FiniteDuration;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
FollowerLogInformation followerLogInformation =
new FollowerLogInformationImpl(
- "follower1", new AtomicLong(10), new AtomicLong(9), timeoutDuration);
+ "follower1", 10, 9, timeoutDuration);