2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.cluster.raft.behaviors;
11 import akka.actor.ActorRef;
12 import org.opendaylight.controller.cluster.raft.RaftState;
15 * A RaftActorBehavior represents the specific behavior of a RaftActor
17 * A RaftActor can behave as one of the following,
20 * <li> Candidate </li>
24 * In each of these behaviors the Raft Actor handles the same Raft messages
27 public interface RaftActorBehavior extends AutoCloseable{
30 * Handle a message. If the processing of the message warrants a state
31 * change then a new behavior should be returned otherwise this method should
32 * return the current behavior.
34 * @param sender The sender of the message
35 * @param message A message that needs to be processed
37 * @return The new behavior or current behavior
39 RaftActorBehavior handleMessage(ActorRef sender, Object message);
43 * @return The state associated with a given behavior
49 * @return The Id of the Leader if known else null
54 * setting the index of the log entry which is replicated to all nodes
55 * @param replicatedToAllIndex
57 void setReplicatedToAllIndex(long replicatedToAllIndex);
60 * @return the index of the log entry which is replicated to all nodes
62 long getReplicatedToAllIndex();
65 * @return the leader's payload data version.
67 short getLeaderPayloadVersion();