use of org.neo4j.causalclustering.core.state.snapshot.RaftCoreState in project neo4j by neo4j.
the class ElectionTest method candidateShouldVoteForTheSameCandidateInTheSameTerm.
@Test
public void candidateShouldVoteForTheSameCandidateInTheSameTerm() throws Exception {
// given
FakeClock fakeClock = Clocks.fakeClock();
ControlledRenewableTimeoutService timeouts = new ControlledRenewableTimeoutService(fakeClock);
RaftMachine raft = new RaftMachineBuilder(myself, 3, RaftTestMemberSetBuilder.INSTANCE).outbound(outbound).timeoutService(timeouts).clock(fakeClock).build();
raft.installCoreState(new RaftCoreState(new MembershipEntry(0, asSet(myself, member1, member2))));
// when
raft.handle(voteRequest().from(member1).candidate(member1).term(1).build());
raft.handle(voteRequest().from(member1).candidate(member1).term(1).build());
// then
verify(outbound, times(2)).send(member1, voteResponse().term(1).grant().build());
}
use of org.neo4j.causalclustering.core.state.snapshot.RaftCoreState in project neo4j by neo4j.
the class CoreBootstrapper method bootstrap.
public CoreSnapshot bootstrap(Set<MemberId> members) throws IOException {
StoreFactory factory = new StoreFactory(storeDir, config, new DefaultIdGeneratorFactory(fs), pageCache, fs, logProvider);
NeoStores neoStores = factory.openAllNeoStores(true);
neoStores.close();
CoreSnapshot coreSnapshot = new CoreSnapshot(FIRST_INDEX, FIRST_TERM);
coreSnapshot.add(CoreStateType.ID_ALLOCATION, deriveIdAllocationState(storeDir));
coreSnapshot.add(CoreStateType.LOCK_TOKEN, new ReplicatedLockTokenState());
coreSnapshot.add(CoreStateType.RAFT_CORE_STATE, new RaftCoreState(new MembershipEntry(FIRST_INDEX, members)));
coreSnapshot.add(CoreStateType.SESSION_TRACKER, new GlobalSessionTrackerState());
appendNullTransactionLogEntryToSetRaftIndexToMinusOne();
return coreSnapshot;
}
Aggregations