예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void mustFlushDirtyPagesOnEvictingAllPages() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void MustFlushDirtyPagesOnEvictingAllPages()
        {
            WriteInitialDataTo(file("a"));
            RecordingPageCacheTracer  tracer       = new RecordingPageCacheTracer();
            RecordingPageCursorTracer cursorTracer = new RecordingPageCursorTracer(typeof(RecordingPageCursorTracer.Fault));
            ConfigurablePageCursorTracerSupplier <RecordingPageCursorTracer> cursorTracerSupplier = new ConfigurablePageCursorTracerSupplier <RecordingPageCursorTracer>(cursorTracer);

            using (MuninnPageCache pageCache = createPageCache(fs, 4, BlockCacheFlush(tracer), cursorTracerSupplier), PagedFile pagedFile = map(pageCache, file("a"), 8))
            {
                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_WRITE_LOCK | PF_NO_GROW))
                {
                    assertTrue(cursor.Next());
                    cursor.PutLong(0L);
                    assertTrue(cursor.Next());
                    cursor.PutLong(0L);
                    assertFalse(cursor.Next());
                }
                cursorTracer.ReportEvents();
                assertNotNull(cursorTracer.Observe(typeof(RecordingPageCursorTracer.Fault)));
                assertNotNull(cursorTracer.Observe(typeof(RecordingPageCursorTracer.Fault)));
                assertEquals(2, cursorTracer.Faults());
                assertEquals(2, tracer.Faults());

                long clockArm = pageCache.EvictPages(2, 0, tracer.BeginPageEvictions(2));
                assertThat(clockArm, @is(2L));
                assertNotNull(tracer.Observe(typeof(Evict)));
                assertNotNull(tracer.Observe(typeof(Evict)));

                ByteBuffer buf = ReadIntoBuffer("a");
                assertThat(buf.Long, @is(0L));
                assertThat(buf.Long, @is(0L));
            }
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void mustEvictCleanPageWithoutFlushing() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void MustEvictCleanPageWithoutFlushing()
        {
            WriteInitialDataTo(file("a"));
            RecordingPageCacheTracer  tracer       = new RecordingPageCacheTracer();
            RecordingPageCursorTracer cursorTracer = new RecordingPageCursorTracer();
            ConfigurablePageCursorTracerSupplier <RecordingPageCursorTracer> cursorTracerSupplier = new ConfigurablePageCursorTracerSupplier <RecordingPageCursorTracer>(cursorTracer);

            using (MuninnPageCache pageCache = createPageCache(fs, 2, BlockCacheFlush(tracer), cursorTracerSupplier), PagedFile pagedFile = map(pageCache, file("a"), 8))
            {
                using (PageCursor cursor = pagedFile.Io(0, PF_SHARED_READ_LOCK))
                {
                    assertTrue(cursor.Next());
                }
                cursorTracer.ReportEvents();
                assertNotNull(cursorTracer.Observe(typeof(RecordingPageCursorTracer.Fault)));
                assertEquals(1, cursorTracer.Faults());
                assertEquals(1, tracer.Faults());

                long clockArm = pageCache.EvictPages(1, 1, tracer.BeginPageEvictions(1));
                assertThat(clockArm, @is(1L));
                assertNotNull(tracer.Observe(typeof(Evict)));
            }
        }