X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fraft%2FRaftActorContext.java;h=e971ed4f6de95d5d53d02e7eeb9d3d6c89628db6;hb=d0f46920468c8e4b67c68bd9058572b2d10d75f1;hp=aed050c3c04ee4e15afa9bb907d9887d556bb33f;hpb=8d90cf04be86f872f7eeb892d37517d5ee087157;p=controller.git diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContext.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContext.java index aed050c3c0..e971ed4f6d 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContext.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContext.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.raft; import akka.actor.ActorRef; @@ -16,10 +15,11 @@ import akka.cluster.Cluster; import com.google.common.annotations.VisibleForTesting; import java.util.Collection; import java.util.Optional; +import java.util.concurrent.Executor; import java.util.function.Consumer; import java.util.function.LongSupplier; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.controller.cluster.DataPersistenceProvider; import org.opendaylight.controller.cluster.io.FileBackedOutputStreamFactory; import org.opendaylight.controller.cluster.raft.base.messages.ApplyState; @@ -65,6 +65,13 @@ public interface RaftActorContext { */ ActorRef getActor(); + /** + * Return an Executor which is guaranteed to run tasks in the context of {@link #getActor()}. + * + * @return An executor. + */ + @NonNull Executor getExecutor(); + /** * The akka Cluster singleton for the actor system if one is configured. * @@ -77,8 +84,7 @@ public interface RaftActorContext { * * @return the ElectionTerm. */ - @Nonnull - ElectionTerm getTermInformation(); + @NonNull ElectionTerm getTermInformation(); /** * Returns the index of highest log entry known to be committed. @@ -114,31 +120,28 @@ public interface RaftActorContext { * * @param replicatedLog the ReplicatedLog instance. */ - void setReplicatedLog(@Nonnull ReplicatedLog replicatedLog); + void setReplicatedLog(@NonNull ReplicatedLog replicatedLog); /** * Returns the ReplicatedLog instance. * * @return the ReplicatedLog instance. */ - @Nonnull - ReplicatedLog getReplicatedLog(); + @NonNull ReplicatedLog getReplicatedLog(); /** * Returns the The ActorSystem associated with this context. * * @return the ActorSystem. */ - @Nonnull - ActorSystem getActorSystem(); + @NonNull ActorSystem getActorSystem(); /** * Returns the logger to be used for logging messages. * * @return the logger. */ - @Nonnull - Logger getLogger(); + @NonNull Logger getLogger(); /** * Gets the address of a peer as a String. This is the same format in which a consumer would provide the address. @@ -146,8 +149,7 @@ public interface RaftActorContext { * @param peerId the id of the peer. * @return the address of the peer or null if the address has not yet been resolved. */ - @Nullable - String getPeerAddress(String peerId); + @Nullable String getPeerAddress(String peerId); /** * Updates the peers and information to match the given ServerConfigurationPayload. @@ -161,16 +163,14 @@ public interface RaftActorContext { * * @return list of PeerInfo */ - @Nonnull - Collection getPeers(); + @NonNull Collection getPeers(); /** * Returns the id's for each peer. * * @return the list of peer id's. */ - @Nonnull - Collection getPeerIds(); + @NonNull Collection getPeerIds(); /** * Returns the PeerInfo for the given peer. @@ -178,8 +178,7 @@ public interface RaftActorContext { * @param peerId the id of the peer * @return the PeerInfo or null if not found */ - @Nullable - PeerInfo getPeerInfo(String peerId); + @Nullable PeerInfo getPeerInfo(String peerId); /** * Adds a new peer. @@ -203,8 +202,7 @@ public interface RaftActorContext { * @param peerId the id of the peer. * @return the actorSelection corresponding to the peer or null if the address has not yet been resolved. */ - @Nullable - ActorSelection getPeerActorSelection(String peerId); + @Nullable ActorSelection getPeerActorSelection(String peerId); /** * Sets the address of a peer. @@ -219,24 +217,21 @@ public interface RaftActorContext { * * @return the ConfigParams instance. */ - @Nonnull - ConfigParams getConfigParams(); + @NonNull ConfigParams getConfigParams(); /** * Returns the SnapshotManager instance. * * @return the SnapshotManager instance. */ - @Nonnull - SnapshotManager getSnapshotManager(); + @NonNull SnapshotManager getSnapshotManager(); /** * Returns the DataPersistenceProvider instance. * * @return the DataPersistenceProvider instance. */ - @Nonnull - DataPersistenceProvider getPersistenceProvider(); + @NonNull DataPersistenceProvider getPersistenceProvider(); /** * Determines if there are any peer followers. @@ -273,8 +268,7 @@ public interface RaftActorContext { * * @return the RaftPolicy instance. */ - @Nonnull - RaftPolicy getRaftPolicy(); + @NonNull RaftPolicy getRaftPolicy(); /** * Determines if there have been any dynamic server configuration changes applied. @@ -296,8 +290,7 @@ public interface RaftActorContext { * @return the peer information as a ServerConfigurationPayload or null if no dynamic server configurations have * been applied. */ - @Nullable - ServerConfigurationPayload getPeerServerInfo(boolean includeSelf); + @Nullable ServerConfigurationPayload getPeerServerInfo(boolean includeSelf); /** * Determines if this peer is a voting member of the cluster. @@ -333,16 +326,14 @@ public interface RaftActorContext { * * @return the {@link FileBackedOutputStreamFactory}; */ - @Nonnull - FileBackedOutputStreamFactory getFileBackedOutputStreamFactory(); + @NonNull FileBackedOutputStreamFactory getFileBackedOutputStreamFactory(); /** * Returns the RaftActorLeadershipTransferCohort if leadership transfer is in progress. * * @return the RaftActorLeadershipTransferCohort if leadership transfer is in progress, null otherwise */ - @Nullable - RaftActorLeadershipTransferCohort getRaftActorLeadershipTransferCohort(); + @Nullable RaftActorLeadershipTransferCohort getRaftActorLeadershipTransferCohort(); /** * Sets the RaftActorLeadershipTransferCohort for transferring leadership.