示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldListenToLeaderUpdates() throws ReplicationFailureException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldListenToLeaderUpdates()
        {
            OneProgressTracker oneProgressTracker = new OneProgressTracker(this);

            oneProgressTracker.Last.setReplicated();
            CapturingOutbound <Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage> outbound = new CapturingOutbound <Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage>();
            RaftReplicator    replicator = GetReplicator(outbound, oneProgressTracker, new Monitors());
            ReplicatedInteger content    = ReplicatedInteger.valueOf(5);

            LeaderInfo lastLeader = _leaderInfo;

            // set initial leader, sens to that leader
            replicator.OnLeaderSwitch(lastLeader);
            replicator.Replicate(content, false);
            assertEquals(outbound.LastTo, lastLeader.MemberId());

            // update with valid new leader, sends to new leader
            lastLeader = new LeaderInfo(new MemberId(System.Guid.randomUUID()), 1);
            replicator.OnLeaderSwitch(lastLeader);
            replicator.Replicate(content, false);
            assertEquals(outbound.LastTo, lastLeader.MemberId());
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldSuccessfullySendIfLeaderIsLostAndFound() throws InterruptedException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldSuccessfullySendIfLeaderIsLostAndFound()
        {
            OneProgressTracker capturedProgress = new OneProgressTracker(this);
            CapturingOutbound <Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage> outbound = new CapturingOutbound <Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage>();

            RaftReplicator replicator = GetReplicator(outbound, capturedProgress, new Monitors());

            replicator.OnLeaderSwitch(_leaderInfo);

            ReplicatedInteger content           = ReplicatedInteger.valueOf(5);
            ReplicatingThread replicatingThread = replicatingThread(replicator, content, false);

            // when
            replicatingThread.Start();

            // then
            assertEventually("send count", () => outbound.Count, greaterThan(1), DEFAULT_TIMEOUT_MS, MILLISECONDS);
            replicator.OnLeaderSwitch(new LeaderInfo(null, 1));
            capturedProgress.Last.setReplicated();
            replicator.OnLeaderSwitch(_leaderInfo);

            replicatingThread.Join(DEFAULT_TIMEOUT_MS);
        }