Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRemoveUpwardsFrom()
        public virtual void ShouldRemoveUpwardsFrom()
        {
            // given
            int cacheSize = 100;
            RaftLogMetadataCache cache = new RaftLogMetadataCache(cacheSize);

            for (int i = 0; i < cacheSize; i++)
            {
                cache.CacheMetadata(i, i, new LogPosition(i, i));
            }

            // when
            int upFrom = 60;

            cache.RemoveUpwardsFrom(upFrom);

            // then
            long i = 0;

            for ( ; i < upFrom; i++)
            {
                RaftLogMetadataCache.RaftLogEntryMetadata metadata = cache.GetMetadata(i);
                assertNotNull(metadata);
                assertEquals(i, metadata.EntryTerm);
            }
            for ( ; i < cacheSize; i++)
            {
                assertNull(cache.GetMetadata(i));
            }
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnNullWhenMissingAnEntryInTheCache()
        public virtual void ShouldReturnNullWhenMissingAnEntryInTheCache()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final RaftLogMetadataCache cache = new RaftLogMetadataCache(2);
            RaftLogMetadataCache cache = new RaftLogMetadataCache(2);

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final RaftLogMetadataCache.RaftLogEntryMetadata metadata = cache.getMetadata(42);
            RaftLogMetadataCache.RaftLogEntryMetadata metadata = cache.GetMetadata(42);

            // then
            assertNull(metadata);
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldClearTheCache()
        public virtual void ShouldClearTheCache()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final RaftLogMetadataCache cache = new RaftLogMetadataCache(2);
            RaftLogMetadataCache cache = new RaftLogMetadataCache(2);
            const long           index = 12L;
            const long           term  = 12L;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.LogPosition position = new org.neo4j.kernel.impl.transaction.log.LogPosition(3, 4);
            LogPosition position = new LogPosition(3, 4);

            // when
            cache.CacheMetadata(index, term, position);
            cache.Clear();
            RaftLogMetadataCache.RaftLogEntryMetadata metadata = cache.GetMetadata(index);

            // then
            assertNull(metadata);
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAcceptAndReturnIndexesInRangeJustDeleted()
        public virtual void ShouldAcceptAndReturnIndexesInRangeJustDeleted()
        {
            // given
            int cacheSize = 100;
            RaftLogMetadataCache cache = new RaftLogMetadataCache(cacheSize);

            for (int i = 0; i < cacheSize; i++)
            {
                cache.CacheMetadata(i, i, new LogPosition(i, i));
            }

            // when
            int upFrom = 60;

            cache.RemoveUpwardsFrom(upFrom);

            // and we add something in the deleted range
            int  insertedIndex = 70;
            long insertedTerm  = 150;

            cache.CacheMetadata(insertedIndex, insertedTerm, new LogPosition(insertedIndex, insertedIndex));

            // then
            // nothing should be resurrected in the deleted range just because we inserted something there
            int i = upFrom;

            for ( ; i < insertedIndex; i++)
            {
                assertNull(cache.GetMetadata(i));
            }
            // i here should be insertedIndex
            assertEquals(insertedTerm, cache.GetMetadata(i).EntryTerm);
            i++;               // to continue iteration in the rest of the deleted range
            for ( ; i < cacheSize; i++)
            {
                assertNull(cache.GetMetadata(i));
            }
        }