Search in sources :

Example 6 with SingleFilePageSwapperFactory

use of org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory in project neo4j by neo4j.

the class PageCacheStressTest method run.

public void run() throws Exception {
    try (FileSystemAbstraction fs = new DefaultFileSystemAbstraction()) {
        PageSwapperFactory swapperFactory = new SingleFilePageSwapperFactory();
        swapperFactory.setFileSystemAbstraction(fs);
        try (PageCache pageCacheUnderTest = new MuninnPageCache(swapperFactory, numberOfCachePages, cachePageSize, tracer, pageCursorTracerSupplier)) {
            PageCacheStresser pageCacheStresser = new PageCacheStresser(numberOfPages, numberOfThreads, workingDirectory);
            pageCacheStresser.stress(pageCacheUnderTest, condition);
        }
    }
}
Also used : PageSwapperFactory(org.neo4j.io.pagecache.PageSwapperFactory) SingleFilePageSwapperFactory(org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) MuninnPageCache(org.neo4j.io.pagecache.impl.muninn.MuninnPageCache) SingleFilePageSwapperFactory(org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory) PageCache(org.neo4j.io.pagecache.PageCache) MuninnPageCache(org.neo4j.io.pagecache.impl.muninn.MuninnPageCache)

Example 7 with SingleFilePageSwapperFactory

use of org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory in project neo4j by neo4j.

the class ConfiguringPageCacheFactory method createAndConfigureSwapperFactory.

private PageSwapperFactory createAndConfigureSwapperFactory(FileSystemAbstraction fs, Config config, Log log) {
    String desiredImplementation = config.get(pagecache_swapper);
    if (desiredImplementation != null) {
        for (PageSwapperFactory factory : Service.load(PageSwapperFactory.class)) {
            if (factory.implementationName().equals(desiredImplementation)) {
                factory.setFileSystemAbstraction(fs);
                if (factory instanceof ConfigurablePageSwapperFactory) {
                    ConfigurablePageSwapperFactory configurableFactory = (ConfigurablePageSwapperFactory) factory;
                    configurableFactory.configure(config);
                }
                log.info("Configured " + pagecache_swapper.name() + ": " + desiredImplementation);
                return factory;
            }
        }
        throw new IllegalArgumentException("Cannot find PageSwapperFactory: " + desiredImplementation);
    }
    SingleFilePageSwapperFactory factory = new SingleFilePageSwapperFactory();
    factory.setFileSystemAbstraction(fs);
    return factory;
}
Also used : PageSwapperFactory(org.neo4j.io.pagecache.PageSwapperFactory) SingleFilePageSwapperFactory(org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory) SingleFilePageSwapperFactory(org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory)

Example 8 with SingleFilePageSwapperFactory

use of org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory in project neo4j by neo4j.

the class PageCacheTest method factoryCountingSyncDevice.

private PageSwapperFactory factoryCountingSyncDevice(final AtomicInteger syncDeviceCounter, final Queue<Integer> expectedCountsInForce) {
    SingleFilePageSwapperFactory factory = new SingleFilePageSwapperFactory() {

        @Override
        public void syncDevice() {
            super.syncDevice();
            syncDeviceCounter.getAndIncrement();
        }

        @Override
        public PageSwapper createPageSwapper(File file, int filePageSize, PageEvictionCallback onEviction, boolean createIfNotExist) throws IOException {
            PageSwapper delegate = super.createPageSwapper(file, filePageSize, onEviction, createIfNotExist);
            return new DelegatingPageSwapper(delegate) {

                @Override
                public void force() throws IOException {
                    super.force();
                    assertThat(syncDeviceCounter.get(), is(expectedCountsInForce.poll()));
                }
            };
        }
    };
    factory.setFileSystemAbstraction(fs);
    return factory;
}
Also used : SingleFilePageSwapperFactory(org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory) AdversarialPagedFile(org.neo4j.adversaries.pagecache.AdversarialPagedFile) File(java.io.File)

Aggregations

SingleFilePageSwapperFactory (org.neo4j.io.pagecache.impl.SingleFilePageSwapperFactory)8 PageSwapperFactory (org.neo4j.io.pagecache.PageSwapperFactory)3 File (java.io.File)2 IOException (java.io.IOException)2 ClosedChannelException (java.nio.channels.ClosedChannelException)2 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)2 NoSuchFileException (java.nio.file.NoSuchFileException)2 Test (org.junit.Test)2 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)2 FileIsMappedException (org.neo4j.io.pagecache.impl.FileIsMappedException)2 MuninnPageCache (org.neo4j.io.pagecache.impl.muninn.MuninnPageCache)2 HashMap (java.util.HashMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1 TimeoutException (java.util.concurrent.TimeoutException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 RandomAdversary (org.neo4j.adversaries.RandomAdversary)1 AdversarialFileSystemAbstraction (org.neo4j.adversaries.fs.AdversarialFileSystemAbstraction)1 AdversarialPagedFile (org.neo4j.adversaries.pagecache.AdversarialPagedFile)1