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.RaftActorContext;
13 import org.opendaylight.controller.cluster.raft.RaftState;
15 import java.util.List;
18 * The behavior of a RaftActor when it is in the CandidateState
22 * <li> On conversion to candidate, start election:
24 * <li> Increment currentTerm
26 * <li> Reset election timer
27 * <li> Send RequestVote RPCs to all other servers
29 * <li> If votes received from majority of servers: become leader
30 * <li> If AppendEntries RPC received from new leader: convert to
32 * <li> If election timeout elapses: start new election
35 public class Candidate extends AbstractRaftActorBehavior {
36 private final List<String> peers;
38 public Candidate(RaftActorContext context, List<String> peers) {
44 public RaftState handleMessage(ActorRef sender, Object message) {
45 return RaftState.Candidate;