Search in sources :

Example 1 with DelegateFileSystemAbstraction

use of org.neo4j.io.fs.DelegateFileSystemAbstraction in project neo4j by neo4j.

the class ConfigurableStandalonePageCacheFactoryTest method mustAutomaticallyStartEvictionThread.

@Test(timeout = 10000)
public void mustAutomaticallyStartEvictionThread() throws IOException {
    try (FileSystemAbstraction fs = new DelegateFileSystemAbstraction(Jimfs.newFileSystem(jimConfig()))) {
        File file = new File("/a").getCanonicalFile();
        fs.create(file).close();
        try (PageCache cache = ConfigurableStandalonePageCacheFactory.createPageCache(fs);
            PagedFile pf = cache.map(file, 4096);
            PageCursor cursor = pf.io(0, PagedFile.PF_SHARED_WRITE_LOCK)) {
            // If the eviction thread has not been started, then this test will block forever.
            for (int i = 0; i < 10_000; i++) {
                assertTrue(cursor.next());
                cursor.putInt(42);
            }
        }
    }
}
Also used : DelegateFileSystemAbstraction(org.neo4j.io.fs.DelegateFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) PagedFile(org.neo4j.io.pagecache.PagedFile) DelegateFileSystemAbstraction(org.neo4j.io.fs.DelegateFileSystemAbstraction) PagedFile(org.neo4j.io.pagecache.PagedFile) File(java.io.File) PageCache(org.neo4j.io.pagecache.PageCache) PageCursor(org.neo4j.io.pagecache.PageCursor) Test(org.junit.Test)

Aggregations

File (java.io.File)1 Test (org.junit.Test)1 DelegateFileSystemAbstraction (org.neo4j.io.fs.DelegateFileSystemAbstraction)1 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)1 PageCache (org.neo4j.io.pagecache.PageCache)1 PageCursor (org.neo4j.io.pagecache.PageCursor)1 PagedFile (org.neo4j.io.pagecache.PagedFile)1