//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHaveNoEffectWhenTruncatingNonExistingEntries() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHaveNoEffectWhenTruncatingNonExistingEntries() { // Given RaftLog log = CreateRaftLog(); RaftLogEntry logEntryA = new RaftLogEntry(1, valueOf(1)); RaftLogEntry logEntryB = new RaftLogEntry(1, valueOf(2)); log.Append(logEntryA, logEntryB); try { // When log.Truncate(5); fail("Truncate at index after append index should never be attempted"); } catch (System.ArgumentException) { // Then // an exception should be thrown } // Then, assert that the state is unchanged assertThat(log.AppendIndex(), @is(1L)); assertThat(readLogEntry(log, 0), equalTo(logEntryA)); assertThat(readLogEntry(log, 1), equalTo(logEntryB)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAppendAndCommit() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAppendAndCommit() { RaftLog log = _logFactory.createBasedOn(FsRule.get()); RaftLogEntry logEntry = new RaftLogEntry(1, ReplicatedInteger.valueOf(1)); log.Append(logEntry); VerifyCurrentLogAndNewLogLoadedFromFileSystem(log, FsRule.get(), myLog => assertThat(myLog.appendIndex(), @is(0L))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAppendDataAndNotCommitImmediately() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAppendDataAndNotCommitImmediately() { RaftLog log = CreateRaftLog(); RaftLogEntry logEntry = new RaftLogEntry(1, valueOf(1)); log.Append(logEntry); assertThat(log.AppendIndex(), @is(0L)); assertThat(readLogEntry(log, 0), equalTo(logEntry)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldTruncatePreviouslyAppendedEntries() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldTruncatePreviouslyAppendedEntries() { RaftLog log = _logFactory.createBasedOn(FsRule.get()); RaftLogEntry logEntryA = new RaftLogEntry(1, ReplicatedInteger.valueOf(1)); RaftLogEntry logEntryB = new RaftLogEntry(1, ReplicatedInteger.valueOf(2)); log.Append(logEntryA); log.Append(logEntryB); log.Truncate(1); VerifyCurrentLogAndNewLogLoadedFromFileSystem(log, FsRule.get(), myLog => assertThat(myLog.appendIndex(), @is(0L))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLogDifferentContentTypes() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldLogDifferentContentTypes() { RaftLog log = CreateRaftLog(); RaftLogEntry logEntryA = new RaftLogEntry(1, valueOf(1)); RaftLogEntry logEntryB = new RaftLogEntry(1, ReplicatedString.valueOf("hejzxcjkzhxcjkxz")); log.Append(logEntryA, logEntryB); assertThat(log.AppendIndex(), @is(1L)); assertThat(readLogEntry(log, 0), equalTo(logEntryA)); assertThat(readLogEntry(log, 1), equalTo(logEntryB)); }
public override bool Equals(object o) { if (this == o) { return(true); } if (o == null || this.GetType() != o.GetType()) { return(false); } RaftLogEntry that = ( RaftLogEntry )o; return(_term == that._term && _content.Equals(that._content)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldTruncatePreviouslyAppendedEntries() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldTruncatePreviouslyAppendedEntries() { RaftLog log = CreateRaftLog(); RaftLogEntry logEntryA = new RaftLogEntry(1, valueOf(1)); RaftLogEntry logEntryB = new RaftLogEntry(1, valueOf(2)); log.Append(logEntryA, logEntryB); assertThat(log.AppendIndex(), @is(1L)); log.Truncate(1); assertThat(log.AppendIndex(), @is(0L)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToAppendAfterSkip() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToAppendAfterSkip() { int term = 0; _raftLog.append(new RaftLogEntry(term, valueOf(10))); int newTerm = 3; _raftLog.skip(5, newTerm); RaftLogEntry newEntry = new RaftLogEntry(newTerm, valueOf(20)); _raftLog.append(newEntry); // this will be logIndex 6 assertEquals(newEntry, RaftLogHelper.ReadLogEntry(_raftLog, 6)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAppendDataAndNotCommitImmediately() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAppendDataAndNotCommitImmediately() { RaftLog log = _logFactory.createBasedOn(FsRule.get()); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final RaftLogEntry logEntry = new RaftLogEntry(1, org.neo4j.causalclustering.core.consensus.ReplicatedInteger.valueOf(1)); RaftLogEntry logEntry = new RaftLogEntry(1, ReplicatedInteger.valueOf(1)); log.Append(logEntry); VerifyCurrentLogAndNewLogLoadedFromFileSystem(log, FsRule.get(), myLog => { assertThat(myLog.appendIndex(), @is(0L)); assertThat(readLogEntry(myLog, 0), equalTo(logEntry)); }); }
private long AppendSingle(RaftLogEntry logEntry) { lock (this) { Objects.requireNonNull(logEntry); if (logEntry.Term() >= _term) { _term = logEntry.Term(); } else { throw new System.InvalidOperationException(string.Format("Non-monotonic term {0:D} for in entry {1} in term {2:D}", logEntry.Term(), logEntry.ToString(), _term)); } _appendIndex++; _raftLog[_appendIndex] = logEntry; return(_appendIndex); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAppendAfterReloadingFromFileSystem() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAppendAfterReloadingFromFileSystem() { RaftLog log = _logFactory.createBasedOn(FsRule.get()); RaftLogEntry logEntryA = new RaftLogEntry(1, ReplicatedInteger.valueOf(1)); log.Append(logEntryA); FsRule.get().crash(); log = _logFactory.createBasedOn(FsRule.get()); RaftLogEntry logEntryB = new RaftLogEntry(1, ReplicatedInteger.valueOf(2)); log.Append(logEntryB); assertThat(log.AppendIndex(), @is(1L)); assertThat(readLogEntry(log, 0), @is(logEntryA)); assertThat(readLogEntry(log, 1), @is(logEntryB)); }
private void Read(RaftLog raftLog) { try { using (RaftLogCursor cursor = raftLog.GetEntryCursor(0)) { while (cursor.Next()) { RaftLogEntry entry = cursor.get(); ReplicatedString content = ( ReplicatedString )entry.Content(); assertEquals(StringForIndex(cursor.Index()), content.Value()); } } } catch (IOException e) { throw new Exception(e); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldLogDifferentContentTypes() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldLogDifferentContentTypes() { RaftLog log = _logFactory.createBasedOn(FsRule.get()); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final RaftLogEntry logEntryA = new RaftLogEntry(1, org.neo4j.causalclustering.core.consensus.ReplicatedInteger.valueOf(1)); RaftLogEntry logEntryA = new RaftLogEntry(1, ReplicatedInteger.valueOf(1)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final RaftLogEntry logEntryB = new RaftLogEntry(1, org.neo4j.causalclustering.core.consensus.ReplicatedString.valueOf("hejzxcjkzhxcjkxz")); RaftLogEntry logEntryB = new RaftLogEntry(1, ReplicatedString.valueOf("hejzxcjkzhxcjkxz")); log.Append(logEntryA); log.Append(logEntryB); VerifyCurrentLogAndNewLogLoadedFromFileSystem(log, FsRule.get(), myLog => { assertThat(myLog.appendIndex(), @is(1L)); assertThat(readLogEntry(myLog, 0), equalTo(logEntryA)); assertThat(readLogEntry(myLog, 1), equalTo(logEntryB)); }); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReplacePreviouslyAppendedEntries() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReplacePreviouslyAppendedEntries() { RaftLog log = CreateRaftLog(); RaftLogEntry logEntryA = new RaftLogEntry(1, valueOf(1)); RaftLogEntry logEntryB = new RaftLogEntry(1, valueOf(2)); RaftLogEntry logEntryC = new RaftLogEntry(1, valueOf(3)); RaftLogEntry logEntryD = new RaftLogEntry(1, valueOf(4)); RaftLogEntry logEntryE = new RaftLogEntry(1, valueOf(5)); log.Append(logEntryA, logEntryB, logEntryC); log.Truncate(1); log.Append(logEntryD, logEntryE); assertThat(log.AppendIndex(), @is(2L)); assertThat(readLogEntry(log, 0), equalTo(logEntryA)); assertThat(readLogEntry(log, 1), equalTo(logEntryD)); assertThat(readLogEntry(log, 2), equalTo(logEntryE)); }
public bool next() { currentIndex++; bool hasNext; lock ( _outerInstance ) { hasNext = currentIndex <= _outerInstance.appendIndex; if (hasNext) { if (currentIndex <= _outerInstance.prevIndex || currentIndex > _outerInstance.appendIndex) { return(false); } current = _outerInstance.raftLog[currentIndex]; } else { current = null; } } return(hasNext); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReplacePreviouslyAppendedEntries() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReplacePreviouslyAppendedEntries() { RaftLog log = _logFactory.createBasedOn(FsRule.get()); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final RaftLogEntry logEntryA = new RaftLogEntry(1, org.neo4j.causalclustering.core.consensus.ReplicatedInteger.valueOf(1)); RaftLogEntry logEntryA = new RaftLogEntry(1, ReplicatedInteger.valueOf(1)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final RaftLogEntry logEntryB = new RaftLogEntry(1, org.neo4j.causalclustering.core.consensus.ReplicatedInteger.valueOf(2)); RaftLogEntry logEntryB = new RaftLogEntry(1, ReplicatedInteger.valueOf(2)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final RaftLogEntry logEntryC = new RaftLogEntry(1, org.neo4j.causalclustering.core.consensus.ReplicatedInteger.valueOf(3)); RaftLogEntry logEntryC = new RaftLogEntry(1, ReplicatedInteger.valueOf(3)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final RaftLogEntry logEntryD = new RaftLogEntry(1, org.neo4j.causalclustering.core.consensus.ReplicatedInteger.valueOf(4)); RaftLogEntry logEntryD = new RaftLogEntry(1, ReplicatedInteger.valueOf(4)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final RaftLogEntry logEntryE = new RaftLogEntry(1, org.neo4j.causalclustering.core.consensus.ReplicatedInteger.valueOf(5)); RaftLogEntry logEntryE = new RaftLogEntry(1, ReplicatedInteger.valueOf(5)); log.Append(logEntryA); log.Append(logEntryB); log.Append(logEntryC); log.Truncate(1); log.Append(logEntryD); log.Append(logEntryE); VerifyCurrentLogAndNewLogLoadedFromFileSystem(log, FsRule.get(), myLog => { assertThat(myLog.appendIndex(), @is(2L)); assertThat(readLogEntry(myLog, 0), equalTo(logEntryA)); assertThat(readLogEntry(myLog, 1), equalTo(logEntryD)); assertThat(readLogEntry(myLog, 2), equalTo(logEntryE)); }); }
public EntryRecord(long logIndex, RaftLogEntry logEntry) { this._logIndex = logIndex; this._logEntry = logEntry; }