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());
}
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());
}
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);
}
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();
}
}
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());
}
Aggregations