Search in sources :

Example 6 with DependencyResolver

use of org.neo4j.common.DependencyResolver in project neo4j by neo4j.

the class DatabaseAvailabilityIT method stoppedDatabaseIsNotAvailable.

@Test
void stoppedDatabaseIsNotAvailable() {
    DependencyResolver dependencyResolver = database.getDependencyResolver();
    DatabaseManager<?> databaseManager = getDatabaseManager(dependencyResolver);
    DatabaseContext databaseContext = databaseManager.getDatabaseContext(defaultNamedDatabaseId).get();
    databaseContext.database().stop();
    assertThrows(DatabaseShutdownException.class, () -> database.beginTx());
}
Also used : DatabaseContext(org.neo4j.dbms.database.DatabaseContext) DependencyResolver(org.neo4j.common.DependencyResolver) Test(org.junit.jupiter.api.Test)

Example 7 with DependencyResolver

use of org.neo4j.common.DependencyResolver in project neo4j by neo4j.

the class DatabaseAvailabilityIT method anyOfDatabaseUnavailabilityIsGlobalUnavailability.

@Test
void anyOfDatabaseUnavailabilityIsGlobalUnavailability() {
    AvailabilityRequirement outerSpaceRequirement = () -> "outer space";
    DependencyResolver dependencyResolver = database.getDependencyResolver();
    DatabaseManager<?> databaseManager = getDatabaseManager(dependencyResolver);
    CompositeDatabaseAvailabilityGuard compositeGuard = dependencyResolver.resolveDependency(CompositeDatabaseAvailabilityGuard.class);
    assertTrue(compositeGuard.isAvailable());
    DatabaseContext systemContext = databaseManager.getDatabaseContext(NAMED_SYSTEM_DATABASE_ID).get();
    DatabaseContext defaultContext = databaseManager.getDatabaseContext(defaultNamedDatabaseId).get();
    AvailabilityGuard systemGuard = systemContext.dependencies().resolveDependency(DatabaseAvailabilityGuard.class);
    systemGuard.require(outerSpaceRequirement);
    assertFalse(compositeGuard.isAvailable());
    systemGuard.fulfill(outerSpaceRequirement);
    assertTrue(compositeGuard.isAvailable());
    AvailabilityGuard defaultGuard = defaultContext.dependencies().resolveDependency(DatabaseAvailabilityGuard.class);
    defaultGuard.require(outerSpaceRequirement);
    assertFalse(compositeGuard.isAvailable());
    defaultGuard.fulfill(outerSpaceRequirement);
    assertTrue(compositeGuard.isAvailable());
}
Also used : DatabaseContext(org.neo4j.dbms.database.DatabaseContext) CompositeDatabaseAvailabilityGuard(org.neo4j.kernel.availability.CompositeDatabaseAvailabilityGuard) AvailabilityGuard(org.neo4j.kernel.availability.AvailabilityGuard) CompositeDatabaseAvailabilityGuard(org.neo4j.kernel.availability.CompositeDatabaseAvailabilityGuard) DatabaseAvailabilityGuard(org.neo4j.kernel.availability.DatabaseAvailabilityGuard) AvailabilityRequirement(org.neo4j.kernel.availability.AvailabilityRequirement) DependencyResolver(org.neo4j.common.DependencyResolver) Test(org.junit.jupiter.api.Test)

Example 8 with DependencyResolver

use of org.neo4j.common.DependencyResolver in project neo4j by neo4j.

the class SessionExtension method defaultDatabaseName.

public String defaultDatabaseName() {
    assertTestStarted();
    DependencyResolver resolver = gdb.getDependencyResolver();
    Config config = resolver.resolveDependency(Config.class);
    return config.get(GraphDatabaseSettings.default_database);
}
Also used : Config(org.neo4j.configuration.Config) DependencyResolver(org.neo4j.common.DependencyResolver)

Example 9 with DependencyResolver

use of org.neo4j.common.DependencyResolver in project neo4j by neo4j.

the class UniqueIndexSeekIT method uniqueIndexSeekDoNotLeakIndexReaders.

@ParameterizedTest
@MethodSource("indexProviderFactories")
void uniqueIndexSeekDoNotLeakIndexReaders(AbstractIndexProviderFactory providerFactory) throws KernelException {
    TrackingIndexExtensionFactory indexExtensionFactory = new TrackingIndexExtensionFactory(providerFactory);
    GraphDatabaseAPI database = createDatabase(indexExtensionFactory, providerFactory.descriptor());
    DependencyResolver dependencyResolver = database.getDependencyResolver();
    Config config = dependencyResolver.resolveDependency(Config.class);
    try {
        Label label = label("spaceship");
        String nameProperty = "name";
        createUniqueConstraint(database, label, nameProperty);
        generateRandomData(database, label, nameProperty);
        assertNotNull(indexExtensionFactory.getIndexProvider(config.get(default_database)));
        assertThat(numberOfClosedReaders()).isGreaterThan(0L);
        assertThat(numberOfOpenReaders()).isGreaterThan(0L);
        assertThat(numberOfClosedReaders()).isCloseTo(numberOfOpenReaders(), within(1L));
        lockNodeUsingUniqueIndexSeek(database, nameProperty);
        assertThat(numberOfClosedReaders()).isCloseTo(numberOfOpenReaders(), within(1L));
    } finally {
        managementService.shutdown();
    }
}
Also used : TrackingIndexExtensionFactory(org.neo4j.kernel.impl.index.schema.tracking.TrackingIndexExtensionFactory) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Config(org.neo4j.configuration.Config) Label(org.neo4j.graphdb.Label) DependencyResolver(org.neo4j.common.DependencyResolver) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 10 with DependencyResolver

use of org.neo4j.common.DependencyResolver in project neo4j by neo4j.

the class TestDatabaseManagementServiceBuilderTest method checkAvailableDatabases.

private static void checkAvailableDatabases(GraphDatabaseAPI database) {
    DependencyResolver resolver = database.getDependencyResolver();
    DatabaseManager<?> databaseManager = resolver.resolveDependency(DatabaseManager.class);
    assertTrue(databaseManager.getDatabaseContext(NAMED_SYSTEM_DATABASE_ID).isPresent());
    assertTrue(databaseManager.getDatabaseContext(DEFAULT_DATABASE_NAME).isPresent());
}
Also used : DependencyResolver(org.neo4j.common.DependencyResolver)

Aggregations

DependencyResolver (org.neo4j.common.DependencyResolver)41 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)13 Config (org.neo4j.configuration.Config)12 Test (org.junit.jupiter.api.Test)10 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)8 DatabaseContext (org.neo4j.dbms.database.DatabaseContext)6 GraphDatabaseFacade (org.neo4j.kernel.impl.factory.GraphDatabaseFacade)5 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)5 GraphDatabaseQueryService (org.neo4j.kernel.GraphDatabaseQueryService)4 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)4 IndexingService (org.neo4j.kernel.impl.api.index.IndexingService)4 SystemGraphComponents (org.neo4j.dbms.database.SystemGraphComponents)3 Transaction (org.neo4j.graphdb.Transaction)3 IdGeneratorFactory (org.neo4j.internal.id.IdGeneratorFactory)3 PageCache (org.neo4j.io.pagecache.PageCache)3 CheckPointer (org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointer)3 SimpleTriggerInfo (org.neo4j.kernel.impl.transaction.log.checkpoint.SimpleTriggerInfo)3 TokenHolders (org.neo4j.token.TokenHolders)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2