use of org.neo4j.internal.id.IdGeneratorFactory in project neo4j by neo4j.
the class IdContextFactoryBuilderTest method createContextWithFactoryWrapper.
@Test
void createContextWithFactoryWrapper() {
IdGeneratorFactory idGeneratorFactory = mock(IdGeneratorFactory.class);
Function<IdGeneratorFactory, IdGeneratorFactory> factoryWrapper = ignored -> idGeneratorFactory;
IdContextFactory contextFactory = IdContextFactoryBuilder.of(fs, jobScheduler, defaults(), PageCacheTracer.NULL).withFactoryWrapper(factoryWrapper).build();
DatabaseIdContext idContext = contextFactory.createIdContext(databaseIdRepository.getByName("database").get());
assertSame(idGeneratorFactory, idContext.getIdGeneratorFactory());
}
use of org.neo4j.internal.id.IdGeneratorFactory in project neo4j by neo4j.
the class NeoStoresTest method reinitializeStores.
private void reinitializeStores(DatabaseLayout databaseLayout) {
Dependencies dependencies = new Dependencies();
Config config = Config.defaults(GraphDatabaseSettings.fail_on_missing_files, false);
dependencies.satisfyDependency(config);
closeStorageEngine();
IdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName());
TokenHolders tokenHolders = new TokenHolders(createReadOnlyTokenHolder(TokenHolder.TYPE_PROPERTY_KEY), createReadOnlyTokenHolder(TokenHolder.TYPE_LABEL), createReadOnlyTokenHolder(TokenHolder.TYPE_RELATIONSHIP_TYPE));
storageEngine = new RecordStorageEngine(databaseLayout, config, pageCache, fs, nullLogProvider(), tokenHolders, new DatabaseSchemaState(nullLogProvider()), new StandardConstraintRuleAccessor(), i -> i, NO_LOCK_SERVICE, mock(Health.class), idGeneratorFactory, new DefaultIdController(), immediate(), PageCacheTracer.NULL, true, INSTANCE, writable(), CommandLockVerification.Factory.IGNORE, LockVerificationMonitor.Factory.IGNORE);
life = new LifeSupport();
life.add(storageEngine);
life.add(storageEngine.schemaAndTokensLifecycle());
life.start();
NeoStores neoStores = storageEngine.testAccessNeoStores();
pStore = neoStores.getPropertyStore();
nodeStore = neoStores.getNodeStore();
storageReader = storageEngine.newReader();
}
use of org.neo4j.internal.id.IdGeneratorFactory in project neo4j by neo4j.
the class NeoStoreOpenFailureTest method mustCloseAllStoresIfNeoStoresFailToOpen.
@Test
@DisabledForRoot
void mustCloseAllStoresIfNeoStoresFailToOpen() {
Config config = Config.defaults();
IdGeneratorFactory idGenFactory = new DefaultIdGeneratorFactory(fileSystem, immediate(), databaseLayout.getDatabaseName());
LogProvider logProvider = NullLogProvider.getInstance();
RecordFormats formats = Standard.LATEST_RECORD_FORMATS;
RecordFormatPropertyConfigurator.configureRecordFormat(formats, config);
boolean create = true;
StoreType[] storeTypes = StoreType.values();
ImmutableSet<OpenOption> openOptions = immutable.empty();
NeoStores neoStores = new NeoStores(fileSystem, databaseLayout, config, idGenFactory, pageCache, logProvider, formats, create, NULL, writable(), storeTypes, openOptions);
Path schemaStore = neoStores.getSchemaStore().getStorageFile();
neoStores.close();
// Make the schema store inaccessible, to sabotage the next initialisation we'll do.
assumeTrue(schemaStore.toFile().setReadable(false));
assumeTrue(schemaStore.toFile().setWritable(false));
assertThrows(RuntimeException.class, () -> new NeoStores(fileSystem, databaseLayout, config, idGenFactory, pageCache, logProvider, formats, create, NULL, writable(), storeTypes, openOptions));
// We verify that the successfully opened stores were closed again by the failed NeoStores open,
// by closing the page cache, which will throw if not all files have been unmapped.
pageCache.close();
}
use of org.neo4j.internal.id.IdGeneratorFactory in project neo4j by neo4j.
the class NodeStoreTest method newNodeStore.
private NodeStore newNodeStore(FileSystemAbstraction fs, PageCache pageCache) {
IdGeneratorFactory idGeneratorFactory = spy(new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName()) {
@Override
protected IndexedIdGenerator instantiate(FileSystemAbstraction fs, PageCache pageCache, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, Path fileName, LongSupplier highIdSupplier, long maxValue, IdType idType, DatabaseReadOnlyChecker readOnlyChecker, Config config, CursorContext cursorContext, String databaseName, ImmutableSet<OpenOption> openOptions) {
return spy(super.instantiate(fs, pageCache, recoveryCleanupWorkCollector, fileName, highIdSupplier, maxValue, idType, readOnlyChecker, config, cursorContext, databaseName, openOptions));
}
});
StoreFactory factory = new StoreFactory(databaseLayout, Config.defaults(), idGeneratorFactory, pageCache, fs, NullLogProvider.getInstance(), PageCacheTracer.NULL, writable());
neoStores = factory.openAllNeoStores(true);
nodeStore = neoStores.getNodeStore();
return nodeStore;
}
use of org.neo4j.internal.id.IdGeneratorFactory in project neo4j by neo4j.
the class CommunityEditionModuleIntegrationTest method createBufferedIdComponentsByDefault.
@Test
void createBufferedIdComponentsByDefault() {
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath()).build();
GraphDatabaseAPI database = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
try {
DependencyResolver dependencyResolver = database.getDependencyResolver();
IdController idController = dependencyResolver.resolveDependency(IdController.class);
IdGeneratorFactory idGeneratorFactory = dependencyResolver.resolveDependency(IdGeneratorFactory.class);
assertThat(idController).isInstanceOf(BufferedIdController.class);
assertThat(idGeneratorFactory).isInstanceOf(BufferingIdGeneratorFactory.class);
} finally {
managementService.shutdown();
}
}
Aggregations