use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class ManyPropertyKeysIT method databaseWithManyPropertyKeys.
private GraphDatabaseAPI databaseWithManyPropertyKeys(int propertyKeyCount) throws IOException {
PageCache pageCache = pageCacheRule.getPageCache(fileSystemRule.get());
StoreFactory storeFactory = new StoreFactory(storeDir, pageCache, fileSystemRule.get(), NullLogProvider.getInstance());
NeoStores neoStores = storeFactory.openAllNeoStores(true);
PropertyKeyTokenStore store = neoStores.getPropertyKeyTokenStore();
for (int i = 0; i < propertyKeyCount; i++) {
PropertyKeyTokenRecord record = new PropertyKeyTokenRecord((int) store.nextId());
record.setInUse(true);
Collection<DynamicRecord> nameRecords = store.allocateNameRecords(PropertyStore.encodeString(key(i)));
record.addNameRecords(nameRecords);
record.setNameId((int) Iterables.first(nameRecords).getId());
store.updateRecord(record);
}
neoStores.close();
return database();
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class ConfigurableStandalonePageCacheFactory method createPageCache.
/**
* Create page cache
* @param fileSystem file system that page cache will be based on
* @param pageCacheTracer global page cache tracer
* @param pageCursorTracerSupplier supplier of thread local (transaction local) page cursor tracer that will provide
* thread local page cache statistics
* @param config page cache configuration
* @return created page cache instance
*/
public static PageCache createPageCache(FileSystemAbstraction fileSystem, PageCacheTracer pageCacheTracer, PageCursorTracerSupplier pageCursorTracerSupplier, Config config) {
Config finalConfig = config.withDefaults(MapUtil.stringMap(GraphDatabaseSettings.pagecache_memory.name(), "8M"));
FormattedLogProvider logProvider = FormattedLogProvider.toOutputStream(System.err);
ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(fileSystem, finalConfig, pageCacheTracer, pageCursorTracerSupplier, logProvider.getLog(PageCache.class));
return pageCacheFactory.getOrCreatePageCache();
}
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));
}
Aggregations