4c40ab61547b934f25ff793bbf12de47ec6155d2
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / RaftState.java
1 /*
2  * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.cluster.raft;
10
11 import org.opendaylight.controller.cluster.raft.behaviors.Candidate;
12 import org.opendaylight.controller.cluster.raft.behaviors.Follower;
13 import org.opendaylight.controller.cluster.raft.behaviors.IsolatedLeader;
14 import org.opendaylight.controller.cluster.raft.behaviors.Leader;
15 import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior;
16
17 public enum RaftState {
18     Candidate {
19         @Override
20         public RaftActorBehavior createBehavior(RaftActorContext context) {
21             return new Candidate(context);
22         }
23     },
24     Follower {
25         @Override
26         public RaftActorBehavior createBehavior(RaftActorContext context) {
27             return new Follower(context);
28         }
29     },
30     Leader {
31         @Override
32         public RaftActorBehavior createBehavior(RaftActorContext context) {
33             return new Leader(context);
34         }
35     },
36     IsolatedLeader {
37         @Override
38         public RaftActorBehavior createBehavior(RaftActorContext context) {
39             return new IsolatedLeader(context);
40         }
41     };
42
43     public abstract RaftActorBehavior createBehavior(RaftActorContext context);
44 }