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;
12 * ElectionTerm contains information about a RaftActors election term.
14 * This information includes the last known current term of the RaftActor
15 * and which peer was voted for by the RaftActor in that term
17 * This class ensures that election term information is persisted
19 public interface ElectionTerm {
21 * latest term server has seen (initialized to 0
22 * on first boot, increases monotonically)
24 long getCurrentTerm();
27 * candidateId that received vote in current
28 * term (or null if none)
33 * To be called mainly when we are recovering in-memory election state from
39 void update(long currentTerm, String votedFor);
42 * To be called when we need to update the current term either because we
43 * received a message from someone with a more up-to-date term or because we
44 * just voted for someone
46 * This information needs to be persisted so that on recovery the replica
47 * can start itself in the right term and know if it has already voted in
53 void updateAndPersist(long currentTerm, String votedFor);