use of org.neo4j.causalclustering.core.consensus.log.RaftLogEntry in project neo4j by neo4j.
the class CommandApplicationProcessTest method shouldIncreaseLastAppliedForOtherCommands.
@Test
public void shouldIncreaseLastAppliedForOtherCommands() throws Exception {
// given
applicationProcess.start();
// when
raftLog.append(new RaftLogEntry(0, new NewLeaderBarrier()));
raftLog.append(new RaftLogEntry(0, new NewLeaderBarrier()));
raftLog.append(new RaftLogEntry(0, new NewLeaderBarrier()));
applicationProcess.notifyCommitted(2);
applier.sync(false);
// then
assertEquals(2, applicationProcess.lastApplied());
}
use of org.neo4j.causalclustering.core.consensus.log.RaftLogEntry in project neo4j by neo4j.
the class CommandApplicationProcessTest method shouldPanicIfUnableToApply.
@Test
public void shouldPanicIfUnableToApply() throws Throwable {
// given
doThrow(IllegalStateException.class).when(commandDispatcher).dispatch(any(ReplicatedTransaction.class), anyLong(), anyCallback());
applicationProcess.start();
raftLog.append(new RaftLogEntry(0, operation(nullTx)));
// when
assertEquals(true, dbHealth.isHealthy());
applicationProcess.notifyCommitted(0);
applier.sync(false);
// then
assertEquals(false, dbHealth.isHealthy());
}
use of org.neo4j.causalclustering.core.consensus.log.RaftLogEntry in project neo4j by neo4j.
the class CommandApplicationProcessTest method entriesThatAreNotStateMachineCommandsShouldStillIncreaseCommandIndex.
@Test
public void entriesThatAreNotStateMachineCommandsShouldStillIncreaseCommandIndex() throws Throwable {
// given
applicationProcess.start();
// when
raftLog.append(new RaftLogEntry(0, new NewLeaderBarrier()));
raftLog.append(new RaftLogEntry(0, operation(nullTx)));
applicationProcess.notifyCommitted(1);
applier.sync(false);
InOrder inOrder = inOrder(coreStateMachines, commandDispatcher);
// then
inOrder.verify(coreStateMachines).commandDispatcher();
inOrder.verify(commandDispatcher).dispatch(eq(nullTx), eq(1L), anyCallback());
inOrder.verify(commandDispatcher).close();
}
use of org.neo4j.causalclustering.core.consensus.log.RaftLogEntry in project neo4j by neo4j.
the class CommandApplicationProcessTest method shouldApplyToLogFromCache.
@Test
public void shouldApplyToLogFromCache() throws Throwable {
//given n things to apply in the cache, check that they are actually applied.
// given
applicationProcess.start();
inFlightMap.put(0L, new RaftLogEntry(1, operation(nullTx)));
//when
applicationProcess.notifyCommitted(0);
applier.sync(false);
//then the cache should have had it's get method called.
verify(inFlightMap, times(1)).get(0L);
verifyZeroInteractions(raftLog);
}
use of org.neo4j.causalclustering.core.consensus.log.RaftLogEntry in project neo4j by neo4j.
the class CommandApplicationProcessTest method cacheEntryShouldBePurgedWhenApplied.
@Test
public void cacheEntryShouldBePurgedWhenApplied() throws Throwable {
//given a cache in submitApplyJob, the contents of the cache should only contain unapplied "things"
applicationProcess.start();
inFlightMap.put(0L, new RaftLogEntry(0, operation(nullTx)));
inFlightMap.put(1L, new RaftLogEntry(0, operation(nullTx)));
inFlightMap.put(2L, new RaftLogEntry(0, operation(nullTx)));
//when
applicationProcess.notifyCommitted(0);
applier.sync(false);
//then the cache should have had its get method called.
assertNull(inFlightMap.get(0L));
assertNotNull(inFlightMap.get(1L));
assertNotNull(inFlightMap.get(2L));
}
Aggregations