2 * Copyright (c) 2015 Brocade Communications 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
8 package org.opendaylight.controller.cluster.raft;
10 import org.opendaylight.controller.cluster.raft.behaviors.Leader;
11 import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior;
14 * A helper class that participates in raft actor leadership transfer. An instance is created upon
15 * initialization of leadership transfer.
17 * NOTE: All methods on this class must be called on the actor's thread dispatcher as they modify internal state.
19 * @author Thomas Pantelis
21 public abstract class RaftActorLeadershipTransferCohort {
22 private final RaftActor raftActor;
24 protected RaftActorLeadershipTransferCohort(RaftActor raftActor) {
25 this.raftActor = raftActor;
29 * This method is invoked to start leadership transfer.
31 public void startTransfer() {
32 RaftActorBehavior behavior = raftActor.getCurrentBehavior();
33 if(behavior instanceof Leader) {
34 ((Leader)behavior).transferLeadership(this);
39 * This method is invoked to abort leadership transfer.
41 public void abortTransfer() {
46 * This method is invoked when leadership transfer is complete.
48 public abstract void transferComplete();