示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void doNoProfileAfterStop() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DoNoProfileAfterStop()
        {
            using (PageCache pageCache = _pageCacheRule.getPageCache(_fs, _cfg), PagedFile ignore = pageCache.Map(_file, pageCache.PageSize(), StandardOpenOption.CREATE))
            {
                PageCacheWarmer warmer = new PageCacheWarmer(_fs, pageCache, _scheduler, _testDirectory.databaseDir());
                warmer.Start();
                warmer.Stop();
                assertSame(long?.empty(), warmer.Profile());
            }
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void listOnlyDatabaseRelaterFilesInListOfMetadata() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ListOnlyDatabaseRelaterFilesInListOfMetadata()
        {
            File ignoredFile = new File(_testDirectory.storeDir(), "b");

            using (PageCache pageCache = _pageCacheRule.getPageCache(_fs, _cfg), PagedFile include = pageCache.Map(_file, pageCache.PageSize(), StandardOpenOption.CREATE), PagedFile ignore = pageCache.Map(ignoredFile, pageCache.PageSize(), StandardOpenOption.CREATE))
            {
                PageCacheWarmer warmer = new PageCacheWarmer(_fs, pageCache, _scheduler, _testDirectory.databaseDir());
                warmer.Start();
                warmer.Profile();

                List <StoreFileMetadata> filesMetadata = new List <StoreFileMetadata>();
                warmer.AddFilesTo(filesMetadata);

                assertThat(filesMetadata, hasSize(1));
                assertTrue(filesMetadata[0].File().Name.StartsWith(_file.Name));

                warmer.Stop();
                assertSame(long?.empty(), warmer.Profile());
            }
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unused") @Test public void profileMustNotDeleteFilesCurrentlyExposedViaFileListing() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ProfileMustNotDeleteFilesCurrentlyExposedViaFileListing()
        {
            using (PageCache pageCache = _pageCacheRule.getPageCache(_fs, _cfg), PagedFile pf = pageCache.Map(_file, pageCache.PageSize(), StandardOpenOption.CREATE))
            {
                using (PageCursor writer = pf.Io(0, Org.Neo4j.Io.pagecache.PagedFile_Fields.PfSharedWriteLock))
                {
                    assertTrue(writer.Next(1));
                    assertTrue(writer.Next(3));
                }
                pf.FlushAndForce();
                PageCacheWarmer warmer = new PageCacheWarmer(_fs, pageCache, _scheduler, _testDirectory.databaseDir());
                warmer.Start();
                warmer.Profile();
                warmer.Profile();
                warmer.Profile();

                IList <StoreFileMetadata> fileListing = new List <StoreFileMetadata>();
                using (Resource firstListing = warmer.AddFilesTo(fileListing))
                {
                    warmer.Profile();
                    warmer.Profile();

                    // The files in the file listing cannot be deleted while the listing is in use.
                    assertThat(fileListing.Count, greaterThan(0));
                    AssertFilesExists(fileListing);
                    warmer.Profile();
                    using (Resource secondListing = warmer.AddFilesTo(new List <StoreFileMetadata>()))
                    {
                        warmer.Profile();
                        // This must hold even when there are file listings overlapping in time.
                        AssertFilesExists(fileListing);
                    }
                    warmer.Profile();
                    // And continue to hold after other overlapping listing finishes.
                    AssertFilesExists(fileListing);
                }
                // Once we are done with the file listing, profile should remove those files.
                warmer.Profile();
                warmer.Stop();
                AssertFilesNotExists(fileListing);
            }
        }
示例#4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void reheatingMustWorkOnLargeNumberOfPages() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ReheatingMustWorkOnLargeNumberOfPages()
        {
            int maxPagesInMemory = 1_000;

            int[] pageIds = RandomSortedPageIds(maxPagesInMemory);

            string pageCacheMemory = (maxPagesInMemory * ByteUnit.kibiBytes(9)).ToString();

            using (PageCache pageCache = _pageCacheRule.getPageCache(_fs, _cfg.withMemory(pageCacheMemory)), PagedFile pf = pageCache.Map(_file, pageCache.PageSize(), StandardOpenOption.CREATE))
            {
                using (PageCursor writer = pf.Io(0, Org.Neo4j.Io.pagecache.PagedFile_Fields.PfSharedWriteLock))
                {
                    foreach (int pageId in pageIds)
                    {
                        assertTrue(writer.Next(pageId));
                    }
                }
                pf.FlushAndForce();
                PageCacheWarmer warmer = new PageCacheWarmer(_fs, pageCache, _scheduler, _testDirectory.databaseDir());
                warmer.Profile();
            }

            long initialFaults = _cacheTracer.faults();

            ClearTracerCounts();
            using (PageCache pageCache = _pageCacheRule.getPageCache(_fs, _cfg), PagedFile pf = pageCache.Map(_file, pageCache.PageSize()))
            {
                PageCacheWarmer warmer = new PageCacheWarmer(_fs, pageCache, _scheduler, _testDirectory.databaseDir());
                warmer.Start();
                warmer.Reheat();

                pageCache.ReportEvents();
                assertThat(_cacheTracer.faults(), @is(initialFaults + pageIds.Length));

                using (PageCursor reader = pf.Io(0, Org.Neo4j.Io.pagecache.PagedFile_Fields.PF_SHARED_READ_LOCK))
                {
                    foreach (int pageId in pageIds)
                    {
                        assertTrue(reader.Next(pageId));
                    }
                }

                // No additional faults must have been reported.
                pageCache.ReportEvents();
                assertThat(_cacheTracer.faults(), @is(initialFaults + pageIds.Length));
            }
        }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void profileAndReheatAfterRestart() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ProfileAndReheatAfterRestart()
        {
            using (PageCache pageCache = _pageCacheRule.getPageCache(_fs, _cfg), PagedFile pf = pageCache.Map(_file, pageCache.PageSize(), StandardOpenOption.CREATE))
            {
                PageCacheWarmer warmer = new PageCacheWarmer(_fs, pageCache, _scheduler, _testDirectory.databaseDir());
                warmer.Start();
                warmer.Stop();
                warmer.Start();
                using (PageCursor writer = pf.Io(0, Org.Neo4j.Io.pagecache.PagedFile_Fields.PfSharedWriteLock))
                {
                    assertTrue(writer.Next(1));
                    assertTrue(writer.Next(3));
                }
                warmer.Profile();
                assertNotSame(long?.empty(), warmer.Reheat());
            }
        }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustReheatProfiledPageCache() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustReheatProfiledPageCache()
        {
            using (PageCache pageCache = _pageCacheRule.getPageCache(_fs, _cfg), PagedFile pf = pageCache.Map(_file, pageCache.PageSize(), StandardOpenOption.CREATE))
            {
                using (PageCursor writer = pf.Io(0, Org.Neo4j.Io.pagecache.PagedFile_Fields.PfSharedWriteLock))
                {
                    assertTrue(writer.Next(1));
                    assertTrue(writer.Next(3));
                }
                pf.FlushAndForce();
                PageCacheWarmer warmer = new PageCacheWarmer(_fs, pageCache, _scheduler, _testDirectory.databaseDir());
                warmer.Start();
                warmer.Profile();
            }

            ClearTracerCounts();
            long initialFaults = _cacheTracer.faults();

            using (PageCache pageCache = _pageCacheRule.getPageCache(_fs, _cfg), PagedFile pf = pageCache.Map(_file, pageCache.PageSize()))
            {
                PageCacheWarmer warmer = new PageCacheWarmer(_fs, pageCache, _scheduler, _testDirectory.databaseDir());
                warmer.Start();
                warmer.Reheat();

                pageCache.ReportEvents();
                assertThat(_cacheTracer.faults(), @is(initialFaults + 2L));

                using (PageCursor reader = pf.Io(0, Org.Neo4j.Io.pagecache.PagedFile_Fields.PF_SHARED_READ_LOCK))
                {
                    assertTrue(reader.Next(1));
                    assertTrue(reader.Next(3));
                }

                // No additional faults must have been reported.
                pageCache.ReportEvents();
                assertThat(_cacheTracer.faults(), @is(initialFaults + 2L));
            }
        }