use of org.neo4j.internal.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class NeoStoresTest method newStoreFactory.
private static StoreFactory newStoreFactory(DatabaseLayout databaseLayout, PageCache pageCache, FileSystemAbstraction fs) {
RecordFormats recordFormats = RecordFormatSelector.defaultFormat();
Config config = Config.defaults();
IdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName());
return new StoreFactory(databaseLayout, config, idGeneratorFactory, pageCache, fs, recordFormats, LOG_PROVIDER, PageCacheTracer.NULL, writable(), immutable.empty());
}
use of org.neo4j.internal.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class NeoStoresTest method isPresentAfterCreatingAllStores.
@Test
void isPresentAfterCreatingAllStores() throws Exception {
// given
fs.deleteRecursively(databaseLayout.databaseDirectory());
DefaultIdGeneratorFactory idFactory = new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName());
StoreFactory factory = new StoreFactory(databaseLayout, Config.defaults(), idFactory, pageCache, fs, LOG_PROVIDER, PageCacheTracer.NULL, writable());
// when
try (NeoStores ignore = factory.openAllNeoStores(true)) {
// then
assertTrue(NeoStores.isStorePresent(fs, databaseLayout));
}
}
use of org.neo4j.internal.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class NeoStoresTest method isPresentFalseAfterCreatingAllButLastStoreType.
@Test
void isPresentFalseAfterCreatingAllButLastStoreType() throws Exception {
// given
fs.deleteRecursively(databaseLayout.databaseDirectory());
DefaultIdGeneratorFactory idFactory = new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName());
StoreFactory factory = new StoreFactory(databaseLayout, Config.defaults(), idFactory, pageCache, fs, LOG_PROVIDER, PageCacheTracer.NULL, writable());
StoreType[] allStoreTypes = StoreType.values();
StoreType[] allButLastStoreTypes = Arrays.copyOf(allStoreTypes, allStoreTypes.length - 1);
// when
try (NeoStores ignore = factory.openNeoStores(true, allButLastStoreTypes)) {
// then
assertFalse(NeoStores.isStorePresent(fs, databaseLayout));
}
}
use of org.neo4j.internal.id.DefaultIdGeneratorFactory 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.internal.id.DefaultIdGeneratorFactory in project neo4j by neo4j.
the class DirectRecordStoreMigrator method migrate.
public void migrate(DatabaseLayout fromDirectoryStructure, RecordFormats fromFormat, DatabaseLayout toDirectoryStructure, RecordFormats toFormat, ProgressReporter progressReporter, StoreType[] types, StoreType... additionalTypesToOpen) throws IOException {
StoreType[] storesToOpen = ArrayUtil.concat(types, additionalTypesToOpen);
progressReporter.start(storesToOpen.length);
try (NeoStores fromStores = new StoreFactory(fromDirectoryStructure, config, new ScanOnOpenReadOnlyIdGeneratorFactory(), pageCache, fs, fromFormat, NullLogProvider.getInstance(), cacheTracer, readOnly(), immutable.empty()).openNeoStores(true, storesToOpen);
NeoStores toStores = new StoreFactory(toDirectoryStructure, withPersistedStoreHeadersAsConfigFrom(fromStores, storesToOpen), new DefaultIdGeneratorFactory(fs, immediate(), toDirectoryStructure.getDatabaseName()), pageCache, fs, toFormat, NullLogProvider.getInstance(), cacheTracer, writable(), immutable.empty()).openNeoStores(true, storesToOpen);
var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer(DIRECT_STORE_MIGRATOR_TAG))) {
toStores.start(cursorContext);
for (StoreType type : types) {
// This condition will exclude counts store first and foremost.
migrate(fromStores.getRecordStore(type), toStores.getRecordStore(type), cursorContext);
progressReporter.progress(1);
}
}
}
Aggregations