RaftActor extends AbstractUntypedPersistentActor { @VisibleForTesting protected final RaftState getRaftState() { return getCurrentBehavior().state(); } protected  RaftActor(final String id, final Map<String, String> peerAddresses,
         final Optional<ConfigParams> configParams, final short payloadVersion); @Override void preStart(); @Override void postStop(); @Override long snapshotSequenceNr(); ActorSelection getLeader(); final DataPersistenceProvider persistence(); void setPersistence(final DataPersistenceProvider provider);  }
@Test public void testRaftActorRecoveryWithPersistenceDisabled() { String persistenceId = factory.generateActorId("follower-"); DefaultConfigParamsImpl config = new DefaultConfigParamsImpl(); config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS)); TestActorRef<MockRaftActor> ref = factory.createTestActor(MockRaftActor.props(persistenceId, ImmutableMap.<String, String>builder().put("member1", "address").build(), config, createProvider()), persistenceId); MockRaftActor mockRaftActor = ref.underlyingActor(); mockRaftActor.waitForRecoveryComplete(); mockRaftActor.waitForInitializeBehaviorComplete(); assertEquals("getRaftState", RaftState.Follower, mockRaftActor.getRaftState()); }
@Test public void testNonVotingOnRecovery() { TEST_LOG.info("testNonVotingOnRecovery starting"); DefaultConfigParamsImpl config = new DefaultConfigParamsImpl(); config.setElectionTimeoutFactor(1); config.setHeartBeatInterval(FiniteDuration.create(1, TimeUnit.MILLISECONDS)); String persistenceId = factory.generateActorId("test-actor-"); InMemoryJournal.addEntry(persistenceId, 1, new SimpleReplicatedLogEntry(0, 1, new ServerConfigurationPayload(Arrays.asList(new ServerInfo(persistenceId, false))))); TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(persistenceId) .config(config).props().withDispatcher(Dispatchers.DefaultDispatcherId()), persistenceId); MockRaftActor mockRaftActor = raftActorRef.underlyingActor(); mockRaftActor.waitForInitializeBehaviorComplete(); Uninterruptibles.sleepUninterruptibly(400, TimeUnit.MILLISECONDS); assertEquals("getRaftState", RaftState.Follower, mockRaftActor.getRaftState()); TEST_LOG.info("testNonVotingOnRecovery ending"); }