Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldTimeoutIfLeaderCommitIsNeverKnown() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldTimeoutIfLeaderCommitIsNeverKnown()
        {
            OnDemandJobScheduler jobScheduler = new OnDemandJobScheduler();
            MembershipWaiter     waiter       = new MembershipWaiter(member(0), jobScheduler, () => _dbHealth, 1, NullLogProvider.Instance, new Monitors());

            ExposedRaftState raftState = RaftStateBuilder.raftState().leaderCommit(-1).build().copy();

            RaftMachine raft = mock(typeof(RaftMachine));

            when(raft.State()).thenReturn(raftState);

            CompletableFuture <bool> future = waiter.WaitUntilCaughtUpMember(raft);

            jobScheduler.RunJob();

            try
            {
                future.get(10, MILLISECONDS);
                fail("Should have timed out.");
            }
            catch (TimeoutException)
            {
                // expected
            }
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeElectedLeaderOnReceivingGrantedVoteResponseWithCurrentTerm() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeElectedLeaderOnReceivingGrantedVoteResponseWithCurrentTerm()
        {
            // given
            RaftState state = RaftStateBuilder.raftState().term(1).myself(_myself).votingMembers(_member1, _member2).replicationMembers(_member1, _member2).build();

            // when
            Outcome outcome = CANDIDATE.handler.handle(voteResponse().term(state.Term()).from(_member1).grant().build(), state, Log());

            // then
            assertEquals(LEADER, outcome.Role);
            assertTrue(outcome.ElectionTimeoutRenewed());
            assertThat(outcome.LogCommands, hasItem(new AppendLogEntry(0, new RaftLogEntry(state.Term(), new NewLeaderBarrier()))));
            assertThat(outcome.OutgoingMessages, hasItems(new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Directed(_member1, new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Heartbeat(_myself, state.Term(), -1, -1)), new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Directed(_member2, new Org.Neo4j.causalclustering.core.consensus.RaftMessages_Heartbeat(_myself, state.Term(), -1, -1))));
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWaitUntilLeaderCommitIsAvailable() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldWaitUntilLeaderCommitIsAvailable()
        {
            OnDemandJobScheduler jobScheduler = new OnDemandJobScheduler();
            MembershipWaiter     waiter       = new MembershipWaiter(member(0), jobScheduler, () => _dbHealth, 500, NullLogProvider.Instance, new Monitors());

            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(typeof(RaftMachine));

            when(raft.State()).thenReturn(raftState);

            CompletableFuture <bool> future = waiter.WaitUntilCaughtUpMember(raft);

            jobScheduler.RunJob();

            future.get(1, TimeUnit.SECONDS);
        }