X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fraft%2FRaftActorContextImpl.java;h=4644a2d79807bf36d069fa010ce561e0232cbcf9;hp=b307195a7ae038a976beae15997376a30a4f590f;hb=866cdf141262dd7b57e95b3e3aa75709b7d0c586;hpb=d796a8de8b208ca24bb57aebfc689f8be8bc2c7b diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java index b307195a7a..4644a2d798 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java @@ -27,8 +27,9 @@ import java.util.Set; import java.util.function.Consumer; import java.util.function.LongSupplier; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import org.opendaylight.controller.cluster.DataPersistenceProvider; -import org.opendaylight.controller.cluster.io.FileBackedOutputStream; +import org.opendaylight.controller.cluster.io.FileBackedOutputStreamFactory; import org.opendaylight.controller.cluster.raft.base.messages.ApplyState; import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior; import org.opendaylight.controller.cluster.raft.persisted.ServerConfigurationPayload; @@ -88,6 +89,10 @@ public class RaftActorContextImpl implements RaftActorContext { private final Consumer applyStateConsumer; + private final FileBackedOutputStreamFactory fileBackedOutputStreamFactory; + + private RaftActorLeadershipTransferCohort leadershipTransferCohort; + public RaftActorContextImpl(ActorRef actor, ActorContext context, String id, @Nonnull ElectionTerm termInformation, long commitIndex, long lastApplied, @Nonnull Map peerAddresses, @@ -104,6 +109,9 @@ public class RaftActorContextImpl implements RaftActorContext { this.log = Preconditions.checkNotNull(logger); this.applyStateConsumer = Preconditions.checkNotNull(applyStateConsumer); + fileBackedOutputStreamFactory = new FileBackedOutputStreamFactory( + configParams.getFileBackedStreamingThreshold(), configParams.getTempFileDirectory()); + for (Map.Entry e: Preconditions.checkNotNull(peerAddresses).entrySet()) { peerInfoMap.put(e.getKey(), new PeerInfo(e.getKey(), e.getValue(), VotingState.VOTING)); } @@ -180,6 +188,7 @@ public class RaftActorContextImpl implements RaftActorContext { @Override public void setLastApplied(long lastApplied) { + log.debug("{}: Moving last applied index from {} to {}", id, this.lastApplied, lastApplied); this.lastApplied = lastApplied; } @@ -401,9 +410,8 @@ public class RaftActorContextImpl implements RaftActorContext { } @Override - public FileBackedOutputStream newFileBackedOutputStream() { - return new FileBackedOutputStream(configParams.getFileBackedStreamingThreshold(), - configParams.getTempFileDirectory()); + public FileBackedOutputStreamFactory getFileBackedOutputStreamFactory() { + return fileBackedOutputStreamFactory; } @SuppressWarnings("checkstyle:IllegalCatch") @@ -416,4 +424,16 @@ public class RaftActorContextImpl implements RaftActorContext { } } } + + @Override + @Nullable + public RaftActorLeadershipTransferCohort getRaftActorLeadershipTransferCohort() { + return leadershipTransferCohort; + } + + @Override + public void setRaftActorLeadershipTransferCohort( + @Nullable RaftActorLeadershipTransferCohort leadershipTransferCohort) { + this.leadershipTransferCohort = leadershipTransferCohort; + } }