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

            ExposedRaftState raftState = RaftStateBuilder.raftState().votingMembers(member(0), member(1)).leaderCommit(0).build().copy();

            RaftMachine raft = mock(typeof(RaftMachine));

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

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

            jobScheduler.RunJob();
            jobScheduler.RunJob();

            try
            {
                future.get(10, MILLISECONDS);
                fail("Should have timed out.");
            }
            catch (TimeoutException)
            {
                // expected
            }
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnImmediatelyIfMemberAndCaughtUp() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReturnImmediatelyIfMemberAndCaughtUp()
        {
            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();
            jobScheduler.RunJob();

            future.get(0, NANOSECONDS);
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void scheduleUpdatePulling() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ScheduleUpdatePulling()
        {
            OnDemandJobScheduler  jobScheduler    = new OnDemandJobScheduler(false);
            UpdatePullerScheduler pullerScheduler = new UpdatePullerScheduler(jobScheduler, NullLogProvider.Instance, _updatePuller, 10);

            // schedule update pulling and run it
            pullerScheduler.Init();
            jobScheduler.RunJob();

            verify(_updatePuller).pullUpdates();
            assertNotNull("Job should be scheduled", jobScheduler.Job);

            // stop scheduler - job should be canceled
            pullerScheduler.Shutdown();

            assertNull("Job should be canceled", jobScheduler.Job);
        }