use of org.neo4j.kernel.impl.store.StoreFactory in project neo4j by neo4j.
the class CountsComputerTest method rebuildCounts.
private void rebuildCounts(long lastCommittedTransactionId) throws IOException {
cleanupCountsForRebuilding();
StoreFactory storeFactory = new StoreFactory(dir, pageCache, fs, NullLogProvider.getInstance());
try (Lifespan life = new Lifespan();
NeoStores neoStores = storeFactory.openAllNeoStores()) {
NodeStore nodeStore = neoStores.getNodeStore();
RelationshipStore relationshipStore = neoStores.getRelationshipStore();
int highLabelId = (int) neoStores.getLabelTokenStore().getHighId();
int highRelationshipTypeId = (int) neoStores.getRelationshipTypeTokenStore().getHighId();
CountsComputer countsComputer = new CountsComputer(lastCommittedTransactionId, nodeStore, relationshipStore, highLabelId, highRelationshipTypeId);
CountsTracker countsTracker = createCountsTracker();
life.add(countsTracker.setInitializer(countsComputer));
}
}
use of org.neo4j.kernel.impl.store.StoreFactory in project neo4j by neo4j.
the class StoreMigratorIT method shouldBeAbleToResumeMigrationOnMoving.
@Test
public void shouldBeAbleToResumeMigrationOnMoving() throws Exception {
// GIVEN a legacy database
File storeDirectory = directory.graphDbDir();
File prepare = directory.directory("prepare");
MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, storeDirectory, prepare);
// and a state of the migration saying that it has done the actual migration
LogService logService = NullLogService.getInstance();
PageCache pageCache = pageCacheRule.getPageCache(fs);
UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fs, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fs), selectFormat());
String versionToMigrateFrom = upgradableDatabase.checkUpgradeable(storeDirectory).storeVersion();
SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
StoreMigrator migrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider);
File migrationDir = new File(storeDirectory, StoreUpgrader.MIGRATION_DIRECTORY);
fs.mkdirs(migrationDir);
migrator.migrate(storeDirectory, migrationDir, progressMonitor.startSection("section"), versionToMigrateFrom, upgradableDatabase.currentVersion());
// WHEN simulating resuming the migration
progressMonitor = new SilentMigrationProgressMonitor();
migrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider);
migrator.moveMigratedFiles(migrationDir, storeDirectory, versionToMigrateFrom, upgradableDatabase.currentVersion());
// THEN starting the new store should be successful
StoreFactory storeFactory = new StoreFactory(storeDirectory, pageCache, fs, logService.getInternalLogProvider());
storeFactory.openAllNeoStores().close();
}
use of org.neo4j.kernel.impl.store.StoreFactory in project neo4j by neo4j.
the class StoreMigratorIT method shouldBeAbleToResumeMigrationOnRebuildingCounts.
@Test
public void shouldBeAbleToResumeMigrationOnRebuildingCounts() throws Exception {
// GIVEN a legacy database
File storeDirectory = directory.graphDbDir();
File prepare = directory.directory("prepare");
MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, storeDirectory, prepare);
// and a state of the migration saying that it has done the actual migration
LogService logService = NullLogService.getInstance();
PageCache pageCache = pageCacheRule.getPageCache(fs);
UpgradableDatabase upgradableDatabase = new UpgradableDatabase(fs, new StoreVersionCheck(pageCache), new LegacyStoreVersionCheck(fs), selectFormat());
String versionToMigrateFrom = upgradableDatabase.checkUpgradeable(storeDirectory).storeVersion();
SilentMigrationProgressMonitor progressMonitor = new SilentMigrationProgressMonitor();
StoreMigrator migrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider);
File migrationDir = new File(storeDirectory, StoreUpgrader.MIGRATION_DIRECTORY);
fs.mkdirs(migrationDir);
migrator.migrate(storeDirectory, migrationDir, progressMonitor.startSection("section"), versionToMigrateFrom, upgradableDatabase.currentVersion());
migrator.moveMigratedFiles(migrationDir, storeDirectory, versionToMigrateFrom, upgradableDatabase.currentVersion());
// WHEN simulating resuming the migration
progressMonitor = new SilentMigrationProgressMonitor();
migrator = new StoreMigrator(fs, pageCache, CONFIG, logService, schemaIndexProvider);
migrator.rebuildCounts(storeDirectory, versionToMigrateFrom, upgradableDatabase.currentVersion());
// THEN starting the new store should be successful
StoreFactory storeFactory = new StoreFactory(storeDirectory, pageCache, fs, logService.getInternalLogProvider());
storeFactory.openAllNeoStores().close();
}
use of org.neo4j.kernel.impl.store.StoreFactory in project neo4j by neo4j.
the class RecordStorageEngineFactory method loadSchemaRules.
@Override
public List<SchemaRule> loadSchemaRules(FileSystemAbstraction fs, PageCache pageCache, Config config, DatabaseLayout databaseLayout, CursorContext cursorContext) {
StoreFactory factory = new StoreFactory(databaseLayout, config, new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName()), pageCache, fs, NullLogProvider.nullLogProvider(), PageCacheTracer.NULL, readOnly());
try (NeoStores stores = factory.openNeoStores(false, StoreType.SCHEMA, StoreType.PROPERTY_KEY_TOKEN, StoreType.PROPERTY)) {
stores.start(cursorContext);
TokenHolders tokenHolders = tokenHoldersForSchemaStore(stores, new ReadOnlyTokenCreator(), cursorContext);
List<SchemaRule> rules = new ArrayList<>();
new SchemaStorage(stores.getSchemaStore(), tokenHolders, () -> KernelVersion.LATEST).getAll(cursorContext).forEach(rules::add);
return rules;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of org.neo4j.kernel.impl.store.StoreFactory in project neo4j by neo4j.
the class StoreUpgraderTest method verifyStoreUpgradedWithin.
private void verifyStoreUpgradedWithin(long duration, TimeUnit unit) {
StoreFactory factory = new StoreFactory(databaseLayout, allowMigrateConfig, new ScanOnOpenOverwritingIdGeneratorFactory(fileSystem, databaseLayout.getDatabaseName()), pageCache, fileSystem, NullLogProvider.getInstance(), NULL, writable());
try (NeoStores neoStores = factory.openAllNeoStores()) {
assertThat(neoStores.getMetaDataStore().getUpgradeTransaction()).isEqualTo(neoStores.getMetaDataStore().getLastCommittedTransaction());
assertThat(neoStores.getMetaDataStore().getUpgradeTime()).isPositive();
long minuteAgo = System.currentTimeMillis() - unit.toMillis(duration);
assertThat(neoStores.getMetaDataStore().getUpgradeTime()).isGreaterThan(minuteAgo);
}
}
Aggregations