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;
11 import akka.actor.ActorRef;
12 import akka.actor.ActorSelection;
13 import akka.actor.ActorSystem;
14 import akka.actor.Props;
16 import java.util.concurrent.atomic.AtomicLong;
18 public class MockRaftActorContext implements RaftActorContext {
21 private ActorSystem system;
22 private ActorRef actor;
23 private AtomicLong index = new AtomicLong(0);
24 private AtomicLong lastApplied = new AtomicLong(0);
26 public MockRaftActorContext(){
30 public MockRaftActorContext(String id, ActorSystem system, ActorRef actor){
36 @Override public ActorRef actorOf(Props props) {
37 return system.actorOf(props);
40 @Override public ActorSelection actorSelection(String path) {
41 return system.actorSelection(path);
44 @Override public String getId() {
48 @Override public ActorRef getActor() {
52 @Override public ElectionTerm getTermInformation() {
53 return new ElectionTermImpl(this.id);
56 public void setIndex(AtomicLong index){
60 @Override public AtomicLong getCommitIndex() {
64 public void setLastApplied(AtomicLong lastApplied){
65 this.lastApplied = lastApplied;
68 @Override public AtomicLong getLastApplied() {
72 @Override public ReplicatedLog getReplicatedLog() {
73 return new ReplicatedLog(){
75 @Override public ReplicatedLogEntry getReplicatedLogEntry(
77 throw new UnsupportedOperationException(
78 "getReplicatedLogEntry");
81 @Override public ReplicatedLogEntry last() {
82 return new ReplicatedLogEntry() {
83 @Override public Object getData() {
87 @Override public long getTerm() {
91 @Override public long getIndex() {