use of org.neo4j.test.OnDemandJobScheduler in project neo4j by neo4j.
the class SegmentedRaftLogRotationTest method createRaftLog.
private SegmentedRaftLog createRaftLog(long rotateAtSize) throws IOException {
LogProvider logProvider = getInstance();
CoreLogPruningStrategy pruningStrategy = new CoreLogPruningStrategyFactory(raft_log_pruning_strategy.getDefaultValue(), logProvider).newInstance();
return new SegmentedRaftLog(fileSystemRule.get(), testDirectory.directory(), rotateAtSize, new DummyRaftableContentSerializer(), logProvider, 0, Clocks.fakeClock(), new OnDemandJobScheduler(), pruningStrategy);
}
use of org.neo4j.test.OnDemandJobScheduler in project neo4j by neo4j.
the class SegmentedRaftLogRotationTruncationPruneTest method createRaftLog.
private RaftLog createRaftLog() throws Exception {
File directory = new File(RAFT_LOG_DIRECTORY_NAME);
FileSystemAbstraction fileSystem = new EphemeralFileSystemAbstraction();
fileSystem.mkdir(directory);
LogProvider logProvider = getInstance();
CoreLogPruningStrategy pruningStrategy = new CoreLogPruningStrategyFactory("1 entries", logProvider).newInstance();
SegmentedRaftLog newRaftLog = new SegmentedRaftLog(fileSystem, directory, 1, new DummyRaftableContentSerializer(), logProvider, 8, Clocks.fakeClock(), new OnDemandJobScheduler(), pruningStrategy);
newRaftLog.start();
return newRaftLog;
}
use of org.neo4j.test.OnDemandJobScheduler in project neo4j by neo4j.
the class MembershipWaiterTest method shouldReturnImmediatelyIfMemberAndCaughtUp.
@Test
public void shouldReturnImmediatelyIfMemberAndCaughtUp() throws Exception {
OnDemandJobScheduler jobScheduler = new OnDemandJobScheduler();
MembershipWaiter waiter = new MembershipWaiter(member(0), jobScheduler, () -> dbHealth, 500, NullLogProvider.getInstance());
InMemoryRaftLog raftLog = new InMemoryRaftLog();
raftLog.append(new RaftLogEntry(0, valueOf(0)));
ExposedRaftState raftState = RaftStateBuilder.raftState().votingMembers(member(0)).leaderCommit(0).entryLog(raftLog).commitIndex(0L).build().copy();
RaftMachine raft = mock(RaftMachine.class);
when(raft.state()).thenReturn(raftState);
CompletableFuture<Boolean> future = waiter.waitUntilCaughtUpMember(raft);
jobScheduler.runJob();
jobScheduler.runJob();
future.get(0, NANOSECONDS);
}
use of org.neo4j.test.OnDemandJobScheduler in project neo4j by neo4j.
the class MembershipWaiterTest method shouldTimeoutIfCaughtUpButNotMember.
@Test
public void shouldTimeoutIfCaughtUpButNotMember() throws Exception {
OnDemandJobScheduler jobScheduler = new OnDemandJobScheduler();
MembershipWaiter waiter = new MembershipWaiter(member(0), jobScheduler, () -> dbHealth, 1, NullLogProvider.getInstance());
ExposedRaftState raftState = RaftStateBuilder.raftState().votingMembers(member(1)).leaderCommit(0).build().copy();
RaftMachine raft = mock(RaftMachine.class);
when(raft.state()).thenReturn(raftState);
CompletableFuture<Boolean> future = waiter.waitUntilCaughtUpMember(raft);
jobScheduler.runJob();
jobScheduler.runJob();
try {
future.get(10, MILLISECONDS);
fail("Should have timed out.");
} catch (TimeoutException e) {
// expected
}
}
use of org.neo4j.test.OnDemandJobScheduler in project neo4j by neo4j.
the class MembershipWaiterTest method shouldTimeoutIfLeaderCommitIsNeverKnown.
@Test
public void shouldTimeoutIfLeaderCommitIsNeverKnown() throws Exception {
OnDemandJobScheduler jobScheduler = new OnDemandJobScheduler();
MembershipWaiter waiter = new MembershipWaiter(member(0), jobScheduler, () -> dbHealth, 1, NullLogProvider.getInstance());
ExposedRaftState raftState = RaftStateBuilder.raftState().leaderCommit(-1).build().copy();
RaftMachine raft = mock(RaftMachine.class);
when(raft.state()).thenReturn(raftState);
CompletableFuture<Boolean> future = waiter.waitUntilCaughtUpMember(raft);
jobScheduler.runJob();
try {
future.get(10, MILLISECONDS);
fail("Should have timed out.");
} catch (TimeoutException e) {
// expected
}
}
Aggregations