Remove RaftReplicator and move hearbeat logic to the leader
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / RaftActorContextImpl.java
1 /*
2  * Copyright (c) 2014 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 akka.actor.ActorRef;
12 import akka.actor.ActorSelection;
13 import akka.actor.ActorSystem;
14 import akka.actor.Props;
15 import akka.actor.UntypedActorContext;
16
17 import java.util.concurrent.atomic.AtomicLong;
18
19 public class RaftActorContextImpl implements RaftActorContext{
20
21     private final ActorRef actor;
22
23     private final UntypedActorContext context;
24
25     private final String id;
26
27     private final ElectionTerm termInformation;
28
29     private final AtomicLong commitIndex;
30
31     private final AtomicLong lastApplied;
32
33     private final ReplicatedLog replicatedLog;
34
35     public RaftActorContextImpl(ActorRef actor, UntypedActorContext context,
36         String id,
37         ElectionTerm termInformation, AtomicLong commitIndex,
38         AtomicLong lastApplied, ReplicatedLog replicatedLog) {
39         this.actor = actor;
40         this.context = context;
41         this.id = id;
42         this.termInformation = termInformation;
43         this.commitIndex = commitIndex;
44         this.lastApplied = lastApplied;
45         this.replicatedLog = replicatedLog;
46     }
47
48     public ActorRef actorOf(Props props){
49         return context.actorOf(props);
50     }
51
52     public ActorSelection actorSelection(String path){
53         return context.actorSelection(path);
54     }
55
56     public String getId() {
57         return id;
58     }
59
60     public ActorRef getActor() {
61         return actor;
62     }
63
64     public ElectionTerm getTermInformation() {
65         return termInformation;
66     }
67
68     public AtomicLong getCommitIndex() {
69         return commitIndex;
70     }
71
72     public AtomicLong getLastApplied() {
73         return lastApplied;
74     }
75
76     @Override public ReplicatedLog getReplicatedLog() {
77         return replicatedLog;
78     }
79
80     @Override public ActorSystem getActorSystem() {
81         return context.system();
82     }
83 }