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);
}
}
}
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;
}
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;
}
Aggregations