Search in sources :

Example 1 with CompositeDatabaseAvailabilityGuard

use of org.neo4j.kernel.availability.CompositeDatabaseAvailabilityGuard 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)

Aggregations

Test (org.junit.jupiter.api.Test)1 DependencyResolver (org.neo4j.common.DependencyResolver)1 DatabaseContext (org.neo4j.dbms.database.DatabaseContext)1 AvailabilityGuard (org.neo4j.kernel.availability.AvailabilityGuard)1 AvailabilityRequirement (org.neo4j.kernel.availability.AvailabilityRequirement)1 CompositeDatabaseAvailabilityGuard (org.neo4j.kernel.availability.CompositeDatabaseAvailabilityGuard)1 DatabaseAvailabilityGuard (org.neo4j.kernel.availability.DatabaseAvailabilityGuard)1