Search in sources :

Example 36 with Dependencies

use of org.neo4j.collection.Dependencies in project neo4j by neo4j.

the class DatabaseManagementServiceFactory method build.

/**
 * Instantiate a graph database given configuration, dependencies, and a custom implementation of {@link org
 * .neo4j.kernel.impl.factory.GraphDatabaseFacade}.
 *
 * @param config configuration
 * @param dependencies the dependencies required to construct the {@link GraphDatabaseFacade}
 * @return the initialised {@link GraphDatabaseFacade}
 */
public DatabaseManagementService build(Config config, final ExternalDependencies dependencies) {
    GlobalModule globalModule = createGlobalModule(config, dependencies);
    AbstractEditionModule edition = editionFactory.apply(globalModule);
    Dependencies globalDependencies = globalModule.getGlobalDependencies();
    LifeSupport globalLife = globalModule.getGlobalLife();
    LogService logService = globalModule.getLogService();
    Log internalLog = logService.getInternalLog(getClass());
    DatabaseManager<?> databaseManager = edition.createDatabaseManager(globalModule);
    DatabaseManagementService managementService = createManagementService(globalModule, globalLife, internalLog, databaseManager);
    globalDependencies.satisfyDependencies(managementService);
    edition.bootstrapFabricServices();
    setupProcedures(globalModule, edition, databaseManager);
    edition.registerSystemGraphComponents(globalModule.getSystemGraphComponents(), globalModule);
    globalLife.add(edition.createSystemGraphInitializer(globalModule));
    var dbmsRuntimeSystemGraphComponent = new DbmsRuntimeSystemGraphComponent(globalModule.getGlobalConfig());
    globalModule.getSystemGraphComponents().register(dbmsRuntimeSystemGraphComponent);
    edition.createDefaultDatabaseResolver(globalModule);
    globalDependencies.satisfyDependency(edition.getDefaultDatabaseResolver());
    edition.createSecurityModule(globalModule);
    SecurityProvider securityProvider = edition.getSecurityProvider();
    globalDependencies.satisfyDependencies(securityProvider.authManager());
    var dbmsRuntimeRepository = edition.createAndRegisterDbmsRuntimeRepository(globalModule, databaseManager, globalDependencies, dbmsRuntimeSystemGraphComponent);
    globalDependencies.satisfyDependency(dbmsRuntimeRepository);
    globalLife.add(new DefaultDatabaseInitializer(databaseManager));
    globalLife.add(globalModule.getGlobalExtensions());
    BoltGraphDatabaseManagementServiceSPI boltGraphDatabaseManagementServiceSPI = edition.createBoltDatabaseManagementServiceProvider(globalDependencies, managementService, globalModule.getGlobalMonitors(), globalModule.getGlobalClock(), logService);
    globalLife.add(createBoltServer(globalModule, edition, boltGraphDatabaseManagementServiceSPI, databaseManager.databaseIdRepository()));
    var webServer = createWebServer(edition, managementService, globalDependencies, config, globalModule.getLogService().getUserLogProvider());
    globalDependencies.satisfyDependency(webServer);
    globalLife.add(webServer);
    globalLife.add(globalModule.getCapabilitiesService());
    startDatabaseServer(globalModule, globalLife, internalLog, databaseManager, managementService);
    return managementService;
}
Also used : GlobalModule(org.neo4j.graphdb.factory.module.GlobalModule) DefaultDatabaseInitializer(org.neo4j.dbms.database.DefaultDatabaseInitializer) Log(org.neo4j.logging.Log) AbstractEditionModule(org.neo4j.graphdb.factory.module.edition.AbstractEditionModule) BoltGraphDatabaseManagementServiceSPI(org.neo4j.bolt.dbapi.BoltGraphDatabaseManagementServiceSPI) DbmsRuntimeSystemGraphComponent(org.neo4j.dbms.database.DbmsRuntimeSystemGraphComponent) SecurityProvider(org.neo4j.kernel.api.security.provider.SecurityProvider) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) Dependencies(org.neo4j.collection.Dependencies) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) LogService(org.neo4j.logging.internal.LogService)

Example 37 with Dependencies

use of org.neo4j.collection.Dependencies in project neo4j by neo4j.

the class DefaultIndexProviderMapTest method shouldNotSupportMultipleProvidersWithSameDescriptor.

@Test
void shouldNotSupportMultipleProvidersWithSameDescriptor() {
    // given
    IndexProvider provider;
    Dependencies dependencies = new Dependencies();
    dependencies.satisfyDependency(provider = provider("provider", "1.2"));
    dependencies.satisfyDependency(provider("provider", "1.2"));
    dependencies.satisfyDependency(fulltext());
    dependencies.satisfyDependency(tokenProvider());
    // when
    assertThrows(IllegalArgumentException.class, () -> createDefaultProviderMap(dependencies, provider.getProviderDescriptor()).init());
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) Dependencies(org.neo4j.collection.Dependencies) Test(org.junit.jupiter.api.Test)

Example 38 with Dependencies

use of org.neo4j.collection.Dependencies in project neo4j by neo4j.

the class DefaultIndexProviderMapTest method shouldInitializeTokenIndexProvider.

@Test
void shouldInitializeTokenIndexProvider() {
    // given
    IndexProvider tokenIndexProvider = tokenProvider();
    IndexProvider provider;
    Dependencies dependencies = new Dependencies();
    dependencies.satisfyDependency(provider = provider("provider", "1.2"));
    dependencies.satisfyDependency(tokenIndexProvider);
    // when
    DefaultIndexProviderMap defaultIndexProviderMap = new DefaultIndexProviderMap(dependencies, Config.newBuilder().set(GraphDatabaseSettings.default_schema_provider, provider.getProviderDescriptor().name()).build());
    defaultIndexProviderMap.init();
    Assertions.assertThat(defaultIndexProviderMap.getTokenIndexProvider()).isEqualTo(tokenIndexProvider);
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) Dependencies(org.neo4j.collection.Dependencies) Test(org.junit.jupiter.api.Test)

Example 39 with Dependencies

use of org.neo4j.collection.Dependencies in project neo4j by neo4j.

the class LogFilesBuilderTest method buildDefaultContextWithDependencies.

@Test
void buildDefaultContextWithDependencies() throws IOException {
    SimpleLogVersionRepository logVersionRepository = new SimpleLogVersionRepository(2);
    SimpleTransactionIdStore transactionIdStore = new SimpleTransactionIdStore();
    DatabaseHealth databaseHealth = new DatabaseHealth(PanicEventGenerator.NO_OP, NullLog.getInstance());
    Dependencies dependencies = new Dependencies();
    dependencies.satisfyDependency(logVersionRepository);
    dependencies.satisfyDependency(transactionIdStore);
    dependencies.satisfyDependency(databaseHealth);
    TransactionLogFilesContext context = builder(databaseLayout, fileSystem).withDependencies(dependencies).withLogEntryReader(logEntryReader()).buildContext();
    assertEquals(fileSystem, context.getFileSystem());
    assertNotNull(context.getLogEntryReader());
    assertEquals(ByteUnit.mebiBytes(250), context.getRotationThreshold().get());
    assertEquals(databaseHealth, context.getDatabaseHealth());
    assertEquals(1, context.getLastCommittedTransactionId());
    assertEquals(2, context.getLogVersionRepository().getCurrentLogVersion());
}
Also used : DatabaseHealth(org.neo4j.monitoring.DatabaseHealth) SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) Dependencies(org.neo4j.collection.Dependencies) Test(org.junit.jupiter.api.Test)

Example 40 with Dependencies

use of org.neo4j.collection.Dependencies 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();
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) Sets.immutable(org.eclipse.collections.api.factory.Sets.immutable) LongSupplier(java.util.function.LongSupplier) DefaultIdController(org.neo4j.internal.id.DefaultIdController) CursorContext(org.neo4j.io.pagecache.context.CursorContext) NORMAL(org.neo4j.kernel.impl.store.record.RecordLoad.NORMAL) Config(org.neo4j.configuration.Config) Value(org.neo4j.values.storable.Value) NullLogProvider(org.neo4j.logging.NullLogProvider) INTERNAL(org.neo4j.storageengine.api.TransactionApplicationMode.INTERNAL) EMPTY_BYTE_ARRAY(org.apache.commons.lang3.ArrayUtils.EMPTY_BYTE_ARRAY) StorageNodeCursor(org.neo4j.storageengine.api.StorageNodeCursor) DEFAULT_DATABASE_NAME(org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME) StorageRelationshipScanCursor(org.neo4j.storageengine.api.StorageRelationshipScanCursor) Duration(java.time.Duration) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) NULL(org.neo4j.io.pagecache.context.CursorContext.NULL) RecoveryCleanupWorkCollector(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector) Path(java.nio.file.Path) PageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer) StoreTokens.createReadOnlyTokenHolder(org.neo4j.internal.recordstorage.StoreTokens.createReadOnlyTokenHolder) Position(org.neo4j.kernel.impl.store.MetaDataStore.Position) Dependencies(org.neo4j.collection.Dependencies) UncloseableDelegatingFileSystemAbstraction(org.neo4j.io.fs.UncloseableDelegatingFileSystemAbstraction) PropertyKeyValue(org.neo4j.storageengine.api.PropertyKeyValue) IdType(org.neo4j.internal.id.IdType) EphemeralNeo4jLayoutExtension(org.neo4j.test.extension.EphemeralNeo4jLayoutExtension) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) RelationshipType(org.neo4j.graphdb.RelationshipType) Mockito.mock(org.mockito.Mockito.mock) AUTH_DISABLED(org.neo4j.internal.kernel.api.security.AuthSubject.AUTH_DISABLED) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) TransactionId(org.neo4j.storageengine.api.TransactionId) RecordFormatSelector(org.neo4j.kernel.impl.store.format.RecordFormatSelector) Node(org.neo4j.graphdb.Node) ArrayList(java.util.ArrayList) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) DelegatingTokenHolder(org.neo4j.token.DelegatingTokenHolder) StorageReader(org.neo4j.storageengine.api.StorageReader) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) NONE(org.neo4j.lock.LockTracer.NONE) NullLogProvider.nullLogProvider(org.neo4j.logging.NullLogProvider.nullLogProvider) UTF8(org.neo4j.string.UTF8) IOException(java.io.IOException) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) RecoveryCleanupWorkCollector.immediate(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector.immediate) AfterEach(org.junit.jupiter.api.AfterEach) KernelException(org.neo4j.exceptions.KernelException) TokenHolders(org.neo4j.token.TokenHolders) CURRENT_FORMAT_LOG_HEADER_SIZE(org.neo4j.kernel.impl.transaction.log.entry.LogVersions.CURRENT_FORMAT_LOG_HEADER_SIZE) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) IndexedIdGenerator(org.neo4j.internal.id.indexed.IndexedIdGenerator) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) LockVerificationMonitor(org.neo4j.internal.recordstorage.LockVerificationMonitor) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) TransactionToApply(org.neo4j.kernel.impl.api.TransactionToApply) ByteBuffer(java.nio.ByteBuffer) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) UnderlyingStorageException(org.neo4j.exceptions.UnderlyingStorageException) StoreChannel(org.neo4j.io.fs.StoreChannel) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) StorageRelationshipTraversalCursor(org.neo4j.storageengine.api.StorageRelationshipTraversalCursor) DatabaseSchemaState(org.neo4j.kernel.impl.api.DatabaseSchemaState) Record(org.neo4j.kernel.impl.store.record.Record) PageCache(org.neo4j.io.pagecache.PageCache) DatabaseReadOnlyChecker.writable(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.writable) TestDirectory(org.neo4j.test.rule.TestDirectory) BASE_TX_COMMIT_TIMESTAMP(org.neo4j.storageengine.api.TransactionIdStore.BASE_TX_COMMIT_TIMESTAMP) RecordStorageEngine(org.neo4j.internal.recordstorage.RecordStorageEngine) StoragePropertyCursor(org.neo4j.storageengine.api.StoragePropertyCursor) Test(org.junit.jupiter.api.Test) List(java.util.List) CommandCreationContext(org.neo4j.storageengine.api.CommandCreationContext) INSTANCE(org.neo4j.memory.EmptyMemoryTracker.INSTANCE) NO_LOCK_SERVICE(org.neo4j.lock.LockService.NO_LOCK_SERVICE) StorageProperty(org.neo4j.storageengine.api.StorageProperty) DatabaseReadOnlyChecker(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation) RelationshipVisitor(org.neo4j.storageengine.api.RelationshipVisitor) IdGeneratorFactory(org.neo4j.internal.id.IdGeneratorFactory) GraphDatabaseSettings(org.neo4j.configuration.GraphDatabaseSettings) TxState(org.neo4j.kernel.impl.api.state.TxState) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) StorageCommand(org.neo4j.storageengine.api.StorageCommand) Values(org.neo4j.values.storable.Values) StandardConstraintRuleAccessor(org.neo4j.storageengine.api.StandardConstraintRuleAccessor) TokenHolder(org.neo4j.token.api.TokenHolder) PropertyReceiver(org.neo4j.internal.recordstorage.TransactionRecordState.PropertyReceiver) Inject(org.neo4j.test.extension.Inject) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) ALL_RELATIONSHIPS(org.neo4j.storageengine.api.RelationshipSelection.ALL_RELATIONSHIPS) GraphDatabaseInternalSettings.counts_store_rotation_timeout(org.neo4j.configuration.GraphDatabaseInternalSettings.counts_store_rotation_timeout) OpenOption(java.nio.file.OpenOption) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) IGNORE(org.neo4j.lock.ResourceLocker.IGNORE) TransactionState(org.neo4j.kernel.api.txstate.TransactionState) CommandLockVerification(org.neo4j.internal.recordstorage.CommandLockVerification) Health(org.neo4j.monitoring.Health) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) EphemeralPageCacheExtension(org.neo4j.test.extension.pagecache.EphemeralPageCacheExtension) FIELD_NOT_PRESENT(org.neo4j.kernel.impl.store.format.standard.MetaDataRecordFormat.FIELD_NOT_PRESENT) Relationship(org.neo4j.graphdb.Relationship) ImmutableSet(org.eclipse.collections.api.set.ImmutableSet) TransactionIdStore(org.neo4j.storageengine.api.TransactionIdStore) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultIdController(org.neo4j.internal.id.DefaultIdController) DatabaseSchemaState(org.neo4j.kernel.impl.api.DatabaseSchemaState) Config(org.neo4j.configuration.Config) RecordStorageEngine(org.neo4j.internal.recordstorage.RecordStorageEngine) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) IdGeneratorFactory(org.neo4j.internal.id.IdGeneratorFactory) Dependencies(org.neo4j.collection.Dependencies) TokenHolders(org.neo4j.token.TokenHolders) StandardConstraintRuleAccessor(org.neo4j.storageengine.api.StandardConstraintRuleAccessor)

Aggregations

Dependencies (org.neo4j.collection.Dependencies)40 Test (org.junit.jupiter.api.Test)13 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)7 Config (org.neo4j.configuration.Config)6 Monitors (org.neo4j.monitoring.Monitors)6 PageCache (org.neo4j.io.pagecache.PageCache)5 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)5 DatabaseHealth (org.neo4j.monitoring.DatabaseHealth)5 StorageEngine (org.neo4j.storageengine.api.StorageEngine)5 BeforeEach (org.junit.jupiter.api.BeforeEach)4 DatabaseReadOnlyChecker (org.neo4j.configuration.helpers.DatabaseReadOnlyChecker)4 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)4 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)4 Database (org.neo4j.kernel.database.Database)4 IndexingService (org.neo4j.kernel.impl.api.index.IndexingService)4 StorageEngineFactory (org.neo4j.storageengine.api.StorageEngineFactory)4 IOException (java.io.IOException)3 RecoveryCleanupWorkCollector (org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector)3 GlobalExtensionContext (org.neo4j.kernel.extension.context.GlobalExtensionContext)3 IndexStatisticsStore (org.neo4j.kernel.impl.api.index.stats.IndexStatisticsStore)3