Search in sources :

Example 6 with NewLeaderBarrier

use of org.neo4j.causalclustering.core.consensus.NewLeaderBarrier 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());
}
Also used : NewLeaderBarrier(org.neo4j.causalclustering.core.consensus.NewLeaderBarrier) RaftLogEntry(org.neo4j.causalclustering.core.consensus.log.RaftLogEntry) Test(org.junit.Test)

Example 7 with NewLeaderBarrier

use of org.neo4j.causalclustering.core.consensus.NewLeaderBarrier 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();
}
Also used : InOrder(org.mockito.InOrder) NewLeaderBarrier(org.neo4j.causalclustering.core.consensus.NewLeaderBarrier) RaftLogEntry(org.neo4j.causalclustering.core.consensus.log.RaftLogEntry) Test(org.junit.Test)

Example 8 with NewLeaderBarrier

use of org.neo4j.causalclustering.core.consensus.NewLeaderBarrier in project neo4j by neo4j.

the class CommandApplicationProcessTest method duplicatesShouldBeIgnoredButStillIncreaseCommandIndex.

@Test
public void duplicatesShouldBeIgnoredButStillIncreaseCommandIndex() throws Exception {
    // given
    applicationProcess.start();
    // when
    raftLog.append(new RaftLogEntry(0, new NewLeaderBarrier()));
    raftLog.append(new RaftLogEntry(0, new DistributedOperation(nullTx, globalSession, new LocalOperationId(0, 0))));
    // duplicate
    raftLog.append(new RaftLogEntry(0, new DistributedOperation(nullTx, globalSession, new LocalOperationId(0, 0))));
    raftLog.append(new RaftLogEntry(0, new DistributedOperation(nullTx, globalSession, new LocalOperationId(0, 1))));
    applicationProcess.notifyCommitted(3);
    applier.sync(false);
    InOrder inOrder = inOrder(coreStateMachines, commandDispatcher);
    // then
    inOrder.verify(coreStateMachines).commandDispatcher();
    inOrder.verify(commandDispatcher).dispatch(eq(nullTx), eq(1L), anyCallback());
    // duplicate not dispatched
    inOrder.verify(commandDispatcher).dispatch(eq(nullTx), eq(3L), anyCallback());
    inOrder.verify(commandDispatcher).close();
    verifyNoMoreInteractions(commandDispatcher);
}
Also used : InOrder(org.mockito.InOrder) LocalOperationId(org.neo4j.causalclustering.core.replication.session.LocalOperationId) DistributedOperation(org.neo4j.causalclustering.core.replication.DistributedOperation) NewLeaderBarrier(org.neo4j.causalclustering.core.consensus.NewLeaderBarrier) RaftLogEntry(org.neo4j.causalclustering.core.consensus.log.RaftLogEntry) Test(org.junit.Test)

Aggregations

NewLeaderBarrier (org.neo4j.causalclustering.core.consensus.NewLeaderBarrier)8 Test (org.junit.Test)7 RaftLogEntry (org.neo4j.causalclustering.core.consensus.log.RaftLogEntry)7 File (java.io.File)3 InOrder (org.mockito.InOrder)2 RaftMessages (org.neo4j.causalclustering.core.consensus.RaftMessages)1 RaftLogCursor (org.neo4j.causalclustering.core.consensus.log.RaftLogCursor)1 AppendLogEntry (org.neo4j.causalclustering.core.consensus.outcome.AppendLogEntry)1 Outcome (org.neo4j.causalclustering.core.consensus.outcome.Outcome)1 RaftState (org.neo4j.causalclustering.core.consensus.state.RaftState)1 DistributedOperation (org.neo4j.causalclustering.core.replication.DistributedOperation)1 ReplicatedContent (org.neo4j.causalclustering.core.replication.ReplicatedContent)1 LocalOperationId (org.neo4j.causalclustering.core.replication.session.LocalOperationId)1 ReplicatedIdAllocationRequest (org.neo4j.causalclustering.core.state.machines.id.ReplicatedIdAllocationRequest)1 ReplicatedLockTokenRequest (org.neo4j.causalclustering.core.state.machines.locks.ReplicatedLockTokenRequest)1 ReplicatedTokenRequest (org.neo4j.causalclustering.core.state.machines.token.ReplicatedTokenRequest)1 ReplicatedTransaction (org.neo4j.causalclustering.core.state.machines.tx.ReplicatedTransaction)1 MemberId (org.neo4j.causalclustering.identity.MemberId)1 StoreChannel (org.neo4j.io.fs.StoreChannel)1