コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void applyTo()
        public virtual void ApplyTo()
        {
            //Test that truncate commands correctly remove entries from the cache.

            //given
            AssertableLogProvider logProvider = new AssertableLogProvider();
            Log  log       = logProvider.getLog(this.GetType());
            long fromIndex = 2L;
            TruncateLogCommand truncateLogCommand = new TruncateLogCommand(fromIndex);
            InFlightCache      inFlightCache      = new ConsecutiveInFlightCache();

            inFlightCache.Put(0L, new RaftLogEntry(0L, valueOf(0)));
            inFlightCache.Put(1L, new RaftLogEntry(1L, valueOf(1)));
            inFlightCache.Put(2L, new RaftLogEntry(2L, valueOf(2)));
            inFlightCache.Put(3L, new RaftLogEntry(3L, valueOf(3)));

            //when
            truncateLogCommand.ApplyTo(inFlightCache, log);

            //then
            assertNotNull(inFlightCache.Get(0L));
            assertNotNull(inFlightCache.Get(1L));
            assertNull(inFlightCache.Get(2L));
            assertNull(inFlightCache.Get(3L));

            logProvider.AssertAtLeastOnce(inLog(this.GetType()).debug("Start truncating in-flight-map from index %d. Current map:%n%s", fromIndex, inFlightCache));
        }
コード例 #2
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (o == null || this.GetType() != o.GetType())
            {
                return(false);
            }
            TruncateLogCommand that = ( TruncateLogCommand )o;

            return(FromIndex == that.FromIndex);
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldTruncateWithGaps()
        public virtual void ShouldTruncateWithGaps()
        {
            //given
            long fromIndex = 1L;
            TruncateLogCommand truncateLogCommand = new TruncateLogCommand(fromIndex);

            InFlightCache inFlightCache = new ConsecutiveInFlightCache();

            inFlightCache.Put(0L, new RaftLogEntry(0L, valueOf(0)));
            inFlightCache.Put(2L, new RaftLogEntry(1L, valueOf(1)));
            inFlightCache.Put(4L, new RaftLogEntry(2L, valueOf(2)));

            truncateLogCommand.ApplyTo(inFlightCache, NullLog.Instance);

            inFlightCache.Put(1L, new RaftLogEntry(3L, valueOf(1)));
            inFlightCache.Put(2L, new RaftLogEntry(4L, valueOf(2)));

            assertNotNull(inFlightCache.Get(1L));
            assertNotNull(inFlightCache.Get(2L));
        }