use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class PlatformModule method createPageCache.
protected PageCache createPageCache(FileSystemAbstraction fileSystem, Config config, LogService logging, Tracers tracers) {
Log pageCacheLog = logging.getInternalLog(PageCache.class);
ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(fileSystem, config, tracers.pageCacheTracer, tracers.pageCursorTracerSupplier, pageCacheLog);
PageCache pageCache = pageCacheFactory.getOrCreatePageCache();
if (config.get(GraphDatabaseSettings.dump_configuration)) {
pageCacheFactory.dumpConfiguration();
}
return pageCache;
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class RecoveryRequiredCheckerTest method shouldWantToRecoverBrokenStore.
@Test
public void shouldWantToRecoverBrokenStore() throws Exception {
try (FileSystemAbstraction fileSystemAbstraction = createSomeDataAndCrash(storeDir, fileSystem)) {
PageCache pageCache = pageCacheRule.getPageCache(fileSystemAbstraction);
RecoveryRequiredChecker recoverer = new RecoveryRequiredChecker(fileSystemAbstraction, pageCache);
assertThat(recoverer.isRecoveryRequiredAt(storeDir), is(true));
}
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class RecordStorageEngineTest method mustFlushStoresWithGivenIOLimiter.
@Test
public void mustFlushStoresWithGivenIOLimiter() throws Exception {
IOLimiter limiter = (stamp, completedIOs, swapper) -> 0;
FileSystemAbstraction fs = fsRule.get();
AtomicReference<IOLimiter> observedLimiter = new AtomicReference<>();
PageCache pageCache = new DelegatingPageCache(pageCacheRule.getPageCache(fs)) {
@Override
public void flushAndForce(IOLimiter limiter) throws IOException {
super.flushAndForce(limiter);
observedLimiter.set(limiter);
}
};
RecordStorageEngine engine = storageEngineRule.getWith(fs, pageCache).build();
engine.flushAndForce(limiter);
assertThat(observedLimiter.get(), sameInstance(limiter));
}
use of org.neo4j.io.pagecache.PageCache 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);
}
}
}
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class ConfiguringPageCacheFactoryTest method mustIgnoreExplicitlySpecifiedCachePageSizeIfPageSwapperHintIsStrict.
@Test
public void mustIgnoreExplicitlySpecifiedCachePageSizeIfPageSwapperHintIsStrict() throws Exception {
// Given
int cachePageSizeHint = 16 * 1024;
PageSwapperFactoryForTesting.cachePageSizeHint.set(cachePageSizeHint);
PageSwapperFactoryForTesting.cachePageSizeHintIsStrict.set(true);
Config config = Config.embeddedDefaults(stringMap(GraphDatabaseSettings.pagecache_swapper.name(), TEST_PAGESWAPPER_NAME));
// When
ConfiguringPageCacheFactory factory = new ConfiguringPageCacheFactory(fsRule.get(), config, PageCacheTracer.NULL, PageCursorTracerSupplier.NULL, NullLog.getInstance());
// Then
try (PageCache cache = factory.getOrCreatePageCache()) {
assertThat(cache.pageSize(), is(cachePageSizeHint));
}
}
Aggregations