+
+ logName = String.format("%s (%s)", context.getId(), state);
+ }
+
+ public static RaftActorBehavior createBehavior(final RaftActorContext context, final RaftState state) {
+ switch (state) {
+ case Candidate:
+ return new Candidate(context);
+ case Follower:
+ return new Follower(context);
+ case IsolatedLeader:
+ return new IsolatedLeader(context);
+ case Leader:
+ return new Leader(context);
+ case PreLeader:
+ return new PreLeader(context);
+ default:
+ throw new IllegalArgumentException("Unhandled state " + state);
+ }
+ }
+
+ @Override
+ public final RaftState state() {
+ return state;
+ }
+
+ protected final String logName() {
+ return logName;
+ }
+
+ @Override
+ public void setReplicatedToAllIndex(long replicatedToAllIndex) {
+ this.replicatedToAllIndex = replicatedToAllIndex;
+ }
+
+ @Override
+ public long getReplicatedToAllIndex() {
+ return replicatedToAllIndex;