Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void oldHeartbeatResponseShouldNotPreventStepdown() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void OldHeartbeatResponseShouldNotPreventStepdown()
        {
            // given
            RaftState state = raftState().votingMembers(asSet(_myself, _member1, _member2)).build();

            Leader leader = new Leader();

            Outcome outcome = leader.Handle(new Org.Neo4j.causalclustering.core.consensus.RaftMessages_HeartbeatResponse(_member1), state, Log());

            state.Update(outcome);

            outcome = leader.Handle(new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Timeout_Election(_myself), state, Log());
            state.Update(outcome);

            assertThat(outcome.Role, @is(LEADER));

            // when
            outcome = leader.Handle(new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Timeout_Election(_myself), state, Log());

            // then
            assertThat(outcome.Role, @is(FOLLOWER));
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void leaderShouldNotStepDownWhenReceivedQuorumOfHeartbeatResponses() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void LeaderShouldNotStepDownWhenReceivedQuorumOfHeartbeatResponses()
        {
            // given
            RaftState state = raftState().votingMembers(asSet(_myself, _member1, _member2)).build();

            Leader leader = new Leader();

            // when
            Outcome outcome = leader.Handle(new Org.Neo4j.causalclustering.core.consensus.RaftMessages_HeartbeatResponse(_member1), state, Log());

            state.Update(outcome);

            // we now have quorum and should not step down
            outcome = leader.Handle(new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Timeout_Election(_myself), state, Log());

            // then
            assertThat(outcome.Role, @is(LEADER));
        }
Exemplo n.º 3
0
        // TODO move this someplace else, since log no longer holds the commit
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void leaderShouldCommitAllPreviouslyAppendedEntriesWhenCommittingLaterEntryInSameTerm() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void LeaderShouldCommitAllPreviouslyAppendedEntriesWhenCommittingLaterEntryInSameTerm()
        {
            // given
            InMemoryRaftLog raftLog = new InMemoryRaftLog();

            raftLog.Append(new RaftLogEntry(0, new ReplicatedString("first!")));
            raftLog.Append(new RaftLogEntry(0, new ReplicatedString("second")));
            raftLog.Append(new RaftLogEntry(0, new ReplicatedString("third")));

            RaftState state = raftState().votingMembers(_myself, _member1, _member2).term(0).entryLog(raftLog).messagesSentToFollower(_member1, raftLog.AppendIndex() + 1).messagesSentToFollower(_member2, raftLog.AppendIndex() + 1).build();

            Leader leader = new Leader();

            // when
            Outcome outcome = leader.Handle(new Org.Neo4j.causalclustering.core.consensus.RaftMessages_AppendEntries_Response(_member1, 0, true, 2, 2), state, Log());

            state.Update(outcome);

            // then
            assertEquals(2, state.CommitIndex());
        }