예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPersistAtSpecifiedLogIndex() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPersistAtSpecifiedLogIndex()
        {
            // when
            _raft.handle(appendEntriesRequest().leaderTerm(0).prevLogIndex(0).prevLogTerm(0).logEntry(new RaftLogEntry(0, _content)).build());

            // then
            assertEquals(1, _testEntryLog.appendIndex());
            assertEquals(_content, readLogEntry(_testEntryLog, 1).content());
        }
예제 #2
0
 public override void Handle <T1>(Org.Neo4j.causalclustering.core.consensus.RaftMessages_ReceivedInstantClusterIdAwareMessage <T1> wrappedMessage)
 {
     lock (this)
     {
         try
         {
             ConsensusOutcome outcome = _raftMachine.handle(wrappedMessage.message());
             if (outcome.NeedsFreshSnapshot())
             {
                 Optional <JobHandle> downloadJob = _downloadService.scheduleDownload(_catchupAddressProvider);
                 if (downloadJob.Present)
                 {
                     downloadJob.get().waitTermination();
                 }
             }
             else
             {
                 NotifyCommitted(outcome.CommitIndex);
             }
         }
         catch (Exception e)
         {
             _log.error("Error handling message", e);
             _raftMachine.panic();
             _localDatabase.panic(e);
         }
     }
 }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnFalseOnAppendRequestFromOlderTerm() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReturnFalseOnAppendRequestFromOlderTerm()
        {
            // when
            _raft.handle(appendEntriesRequest().from(_otherMember).leaderTerm(-1).prevLogIndex(0).prevLogTerm(0).leaderCommit(0).build());

            // then
            verify(_outbound).send(same(_otherMember), eq(appendEntriesResponse().from(_myself).term(0).appendIndex(0).matchIndex(-1).failure().build()));
        }