use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class GraphStoreFixture method directStoreAccess.
public DirectStoreAccess directStoreAccess() {
if (directStoreAccess == null) {
fileSystem = new DefaultFileSystemAbstraction();
PageCache pageCache = getPageCache(fileSystem);
LogProvider logProvider = NullLogProvider.getInstance();
StoreFactory storeFactory = new StoreFactory(directory, pageCache, fileSystem, logProvider);
neoStore = storeFactory.openAllNeoStores();
StoreAccess nativeStores;
if (keepStatistics) {
AccessStatistics accessStatistics = new AccessStatistics();
statistics = new VerboseStatistics(accessStatistics, new DefaultCounts(defaultConsistencyCheckThreadsNumber()), NullLog.getInstance());
nativeStores = new AccessStatsKeepingStoreAccess(neoStore, accessStatistics);
} else {
statistics = Statistics.NONE;
nativeStores = new StoreAccess(neoStore);
}
nativeStores.initialize();
Config config = Config.empty();
OperationalMode operationalMode = OperationalMode.single;
IndexStoreView indexStoreView = new NeoStoreIndexStoreView(LockService.NO_LOCK_SERVICE, nativeStores.getRawNeoStores());
Dependencies dependencies = new Dependencies();
dependencies.satisfyDependencies(Config.defaults(), fileSystem, new SimpleLogService(logProvider, logProvider), indexStoreView, pageCache);
KernelContext kernelContext = new SimpleKernelContext(directory, UNKNOWN, dependencies);
LabelScanStore labelScanStore = startLabelScanStore(config, dependencies, kernelContext);
directStoreAccess = new DirectStoreAccess(nativeStores, labelScanStore, createIndexes(fileSystem, config, operationalMode));
}
return directStoreAccess;
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class NodeStoreTest method shouldCloseStoreFileOnFailureToOpen.
@Test
public void shouldCloseStoreFileOnFailureToOpen() throws Exception {
// GIVEN
final AtomicBoolean fired = new AtomicBoolean();
FileSystemAbstraction fs = new DelegatingFileSystemAbstraction(efs.get()) {
@Override
public StoreChannel open(File fileName, String mode) throws IOException {
return new DelegatingStoreChannel(super.open(fileName, mode)) {
@Override
public int read(ByteBuffer dst) throws IOException {
Exception stack = new Exception();
if (containsStackTraceElement(stack, item -> item.getMethodName().equals("initGenerator")) && !containsStackTraceElement(stack, item -> item.getMethodName().equals("createNodeStore"))) {
fired.set(true);
throw new IOException("Proving a point here");
}
return super.read(dst);
}
};
}
};
// WHEN
try (PageCache pageCache = pageCacheRule.getPageCache(fs)) {
newNodeStore(fs);
fail("Should fail");
}// Close the page cache here so that we can see failure to close (due to still mapped files)
catch (Exception e) {
// THEN
assertTrue(contains(e, IOException.class));
assertTrue(fired.get());
}
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class TestArrayStore method before.
@Before
public void before() throws Exception {
File dir = testDirectory.graphDbDir();
FileSystemAbstraction fs = fileSystemRule.get();
DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
PageCache pageCache = pageCacheRule.getPageCache(fs);
StoreFactory factory = new StoreFactory(dir, Config.empty(), idGeneratorFactory, pageCache, fs, NullLogProvider.getInstance());
neoStores = factory.openAllNeoStores(true);
arrayStore = neoStores.getPropertyStore().getArrayStore();
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class RecordFormatsMigrationIT method assertStoreFormat.
private void assertStoreFormat(RecordFormats expected) throws IOException {
Config config = Config.embeddedDefaults(stringMap(GraphDatabaseSettings.pagecache_memory.name(), "8m"));
try (PageCache pageCache = ConfigurableStandalonePageCacheFactory.createPageCache(fileSystemRule.get(), config)) {
RecordFormats actual = RecordFormatSelector.selectForStoreOrConfig(config, testDirectory.graphDbDir(), fileSystemRule.get(), pageCache, NullLogProvider.getInstance());
assertNotNull(actual);
assertEquals(expected.storeVersion(), actual.storeVersion());
}
}
use of org.neo4j.io.pagecache.PageCache in project neo4j by neo4j.
the class StoreMigrationIT method data.
@Parameterized.Parameters(name = "Migrate: {0}->{1}")
public static Iterable<Object[]> data() throws IOException {
FileSystemAbstraction fs = fileSystemRule.get();
PageCache pageCache = pageCacheRule.getPageCache(fs);
File dir = TestDirectory.testDirectory(StoreMigrationIT.class).prepareDirectoryForTest("migration");
StoreVersionCheck storeVersionCheck = new StoreVersionCheck(pageCache);
LegacyStoreVersionCheck legacyStoreVersionCheck = new LegacyStoreVersionCheck(fs);
List<Object[]> data = new ArrayList<>();
ArrayList<RecordFormats> recordFormatses = new ArrayList<>();
RecordFormatSelector.allFormats().forEach((f) -> addIfNotThere(f, recordFormatses));
for (RecordFormats toFormat : recordFormatses) {
UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fs, storeVersionCheck, legacyStoreVersionCheck, toFormat);
for (RecordFormats fromFormat : recordFormatses) {
File db = new File(dir, baseDirName(toFormat, fromFormat));
try {
createDb(fromFormat, db);
if (!upgradableDatabase.hasCurrentVersion(db)) {
upgradableDatabase.checkUpgradeable(db);
data.add(new Object[] { fromFormat, toFormat });
}
} catch (Exception e) {
//This means that the combination is not migratable.
}
fs.deleteRecursively(db);
}
}
return data;
}
Aggregations