コード例 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void append(long baseIndex, org.neo4j.causalclustering.core.consensus.log.RaftLogEntry... entries) throws java.io.IOException
        public override void Append(long baseIndex, params RaftLogEntry[] entries)
        {
            /* The warnings in this method are rarely expected occurrences which warrant to be logged with significance. */

            foreach (RaftLogEntry entry in entries)
            {
                if (entry.Content() is RaftGroup)
                {
                    RaftGroup <MemberId> raftGroup = (RaftGroup <MemberId>)entry.Content();

                    if (_state.uncommittedMemberChangeInLog())
                    {
                        _log.warn("Appending with uncommitted membership change in log");
                    }

                    if (_state.append(baseIndex, new HashSet <MemberId>(raftGroup.Members)))
                    {
                        _log.info("Appending new member set %s", _state);
                        _storage.persistStoreData(_state);
                        UpdateMemberSets();
                    }
                    else
                    {
                        _log.warn("Appending member set was ignored. Current state: %s, Appended set: %s, Log index: %d%n", _state, raftGroup, baseIndex);
                    }
                }
                baseIndex++;
            }
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUpdateLatestOnAppend()
        public virtual void ShouldUpdateLatestOnAppend()
        {
            // when
            _state.append(0, _membersA);

            // then
            assertEquals(_state.Latest, _membersA);

            // when
            _state.append(1, _membersB);

            // then
            assertEquals(_state.Latest, _membersB);
            assertEquals(1, _state.Ordinal);
        }