Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void freedIdsMustNotBeReusedBeforeVacuum()
        internal virtual void FreedIdsMustNotBeReusedBeforeVacuum()
        {
            PageSwapper   swapper = new DummyPageSwapper("a", 42);
            MutableIntSet ids     = new IntHashSet(10_000);

            for (int i = 0; i < 10_000; i++)
            {
                AllocateFreeAndAssertNotReused(swapper, ids, i);
            }
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void mustNotUseZeroAsSwapperId()
        internal virtual void MustNotUseZeroAsSwapperId()
        {
            PageSwapper   swapper   = new DummyPageSwapper("a", 42);
            Matcher <int> isNotZero = @is(not(0));

            for (int i = 0; i < 10_000; i++)
            {
                assertThat(_set.allocate(swapper), isNotZero);
            }
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void mustReturnAllocationWithSwapper()
        internal virtual void MustReturnAllocationWithSwapper()
        {
            DummyPageSwapper a = new DummyPageSwapper("a", 42);
            DummyPageSwapper b = new DummyPageSwapper("b", 43);
            int idA            = _set.allocate(a);
            int idB            = _set.allocate(b);

            SwapperSet.SwapperMapping allocA = _set.getAllocation(idA);
            SwapperSet.SwapperMapping allocB = _set.getAllocation(idB);
            assertThat(allocA.Swapper, @is(a));
            assertThat(allocB.Swapper, @is(b));
        }
Beispiel #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void mustKeepTrackOfAvailableSwapperIds()
        internal virtual void MustKeepTrackOfAvailableSwapperIds()
        {
            PageSwapper swapper = new DummyPageSwapper("a", 42);
            int         initial = (1 << 21) - 2;

            assertThat(_set.countAvailableIds(), @is(initial));
            int id = _set.allocate(swapper);

            assertThat(_set.countAvailableIds(), @is(initial - 1));
            _set.free(id);
            assertThat(_set.countAvailableIds(), @is(initial - 1));
            _set.vacuum(x =>
            {
            });
            assertThat(_set.countAvailableIds(), @is(initial));
        }
Beispiel #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void vacuumMustNotDustOffAnyIdsWhenNoneHaveBeenFreed()
        internal virtual void VacuumMustNotDustOffAnyIdsWhenNoneHaveBeenFreed()
        {
            PageSwapper swapper = new DummyPageSwapper("a", 42);

            for (int i = 0; i < 100; i++)
            {
                _set.allocate(swapper);
            }
            MutableIntSet vacuumedIds = new IntHashSet();

            _set.vacuum(vacuumedIds.addAll);
            if (!vacuumedIds.Empty)
            {
                throw new AssertionError("Vacuum found id " + vacuumedIds + " when it should have found nothing");
            }
        }
Beispiel #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void traceFileFlush()
        public virtual void TraceFileFlush()
        {
            VerbosePageCacheTracer tracer  = CreateTracer();
            DummyPageSwapper       swapper = new DummyPageSwapper("fileToFlush", 1);

            using (MajorFlushEvent fileToFlush = tracer.BeginFileFlush(swapper))
            {
                FlushEventOpportunity flushEventOpportunity = fileToFlush.FlushEventOpportunity();
                FlushEvent            flushEvent            = flushEventOpportunity.BeginFlush(1, 2, swapper);
                flushEvent.AddPagesFlushed(100);
                flushEvent.AddBytesWritten(ByteUnit.ONE_MEBI_BYTE);
                flushEvent.Done();
                _clock.forward(1, TimeUnit.SECONDS);
                FlushEvent flushEvent2 = flushEventOpportunity.BeginFlush(1, 2, swapper);
                flushEvent2.AddPagesFlushed(10);
                flushEvent2.AddBytesWritten(ByteUnit.ONE_MEBI_BYTE);
                flushEvent2.Done();
            }
            _logProvider.formattedMessageMatcher().assertContains("Flushing file: 'fileToFlush'.");
            _logProvider.formattedMessageMatcher().assertContains("'fileToFlush' flush completed. Flushed 2.000MiB in 110 pages. Flush took: 1s. Average speed: 2.000MiB/s.");
        }
Beispiel #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void freedAllocationsMustBecomeAvailableAfterVacuum()
        internal virtual void FreedAllocationsMustBecomeAvailableAfterVacuum()
        {
            MutableIntSet allocated = new IntHashSet();
            MutableIntSet freed     = new IntHashSet();
            MutableIntSet vacuumed  = new IntHashSet();
            MutableIntSet reused    = new IntHashSet();
            PageSwapper   swapper   = new DummyPageSwapper("a", 42);

            AllocateAndAddTenThousand(allocated, swapper);

            allocated.forEach(id =>
            {
                _set.free(id);
                freed.add(id);
            });
            _set.vacuum(vacuumed.addAll);

            AllocateAndAddTenThousand(reused, swapper);

            assertThat(allocated, @is(equalTo(freed)));
            assertThat(allocated, @is(equalTo(vacuumed)));
            assertThat(allocated, @is(equalTo(reused)));
        }