use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class MultipleIndexPopulationStressIT method populateDbAndIndexes.
private void populateDbAndIndexes(long nodeCount, long relCount) throws InterruptedException {
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(directory.homePath()).build();
final GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
try {
try (var tx = db.beginTx();
var softly = new AutoCloseableSoftAssertions()) {
softly.assertThat(tx.getAllNodes().stream().count()).as("Number of nodes").isEqualTo(nodeCount);
softly.assertThat(tx.getAllRelationships().stream().count()).as("Number of relationships").isEqualTo(relCount);
}
createIndexes(db);
final AtomicBoolean end = new AtomicBoolean();
executor = Executors.newCachedThreadPool();
for (int i = 0; i < 10; i++) {
executor.submit(() -> {
ChangeRandomEntities changeRandomEntities = new ChangeRandomEntities(db, RandomValues.create(), nodeCount, relCount);
while (!end.get()) {
changeRandomEntities.node();
changeRandomEntities.relationship();
}
});
}
while (!indexesAreOnline(db)) {
Thread.sleep(100);
}
end.set(true);
executor.shutdown();
executor.awaitTermination(10, SECONDS);
executor = null;
} finally {
managementService.shutdown();
}
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class MultipleIndexPopulationStressIT method dropIndexes.
private void dropIndexes() {
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(directory.homePath()).setConfig(GraphDatabaseSettings.pagecache_memory, "8m").build();
GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
try (Transaction tx = db.beginTx()) {
tx.schema().getIndexes().forEach(IndexDefinition::drop);
tx.commit();
} finally {
managementService.shutdown();
}
expectingNLI = false;
expectingRTI = false;
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class TestDatabaseManagementServiceBuilderTest method databaseStartsWithSystemAndDefaultDatabase.
@Test
void databaseStartsWithSystemAndDefaultDatabase() {
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath()).build();
GraphDatabaseAPI database = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
try {
checkAvailableDatabases(database);
} finally {
managementService.shutdown();
}
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class DbRepresentation method of.
public static DbRepresentation of(Path storeDirectory, String databaseName, Config config) {
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(storeDirectory).setConfig(config).noOpSystemGraphInitializer().build();
GraphDatabaseService db = managementService.database(databaseName);
try {
return of(db);
} finally {
managementService.shutdown();
}
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class SystemTimeZoneLoggingIT method checkStartLogLine.
private void checkStartLogLine(int hoursShift, String timeZoneSuffix) throws IOException {
TimeZone.setDefault(TimeZone.getTimeZone(ZoneOffset.ofHours(hoursShift)));
Path storeDir = testDirectory.homePath(String.valueOf(hoursShift));
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(storeDir).setConfig(GraphDatabaseSettings.db_timezone, LogTimeZone.SYSTEM).build();
managementService.database(DEFAULT_DATABASE_NAME);
managementService.shutdown();
Path debugLog = Paths.get("logs", "debug.log");
String debugLogLine = getLogLine(storeDir, debugLog);
assertTrue(debugLogLine.contains(timeZoneSuffix), debugLogLine);
}
Aggregations