use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class RecoveryRequiredCheckerTest method startStopDatabase.
private static void startStopDatabase(FileSystemAbstraction fileSystem, Path storeDir) {
DatabaseManagementService managementService = startDatabase(fileSystem, storeDir);
managementService.shutdown();
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class Neo4jExtension method beforeAll.
@Override
public void beforeAll(ExtensionContext context) {
Neo4j neo = builder.build();
DatabaseManagementService managementService = neo.databaseManagementService();
GraphDatabaseService service = neo.defaultDatabaseService();
context.getStore(NAMESPACE).put(Neo4j.class, neo);
context.getStore(NAMESPACE).put(DatabaseManagementService.class, managementService);
context.getStore(NAMESPACE).put(GraphDatabaseService.class, service);
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class BaseBootstrapperIT method shouldHaveSameLayoutAsEmbedded.
@Test
public void shouldHaveSameLayoutAsEmbedded() throws Exception {
Path serverDir = testDirectory.directory("server-dir");
NeoBootstrapper.start(bootstrapper, withConnectorsOnRandomPortsConfig("--home-dir", serverDir.toAbsolutePath().toString()));
assertEventually("Server was not started", bootstrapper::isRunning, Conditions.TRUE, 1, TimeUnit.MINUTES);
var databaseAPI = (GraphDatabaseAPI) bootstrapper.getDatabaseManagementService().database(DEFAULT_DATABASE_NAME);
var serverLayout = databaseAPI.databaseLayout().getNeo4jLayout();
bootstrapper.stop();
Path embeddedDir = testDirectory.directory("embedded-dir");
DatabaseManagementService dbms = newEmbeddedDbms(embeddedDir);
Neo4jLayout embeddedLayout = ((GraphDatabaseAPI) dbms.database(DEFAULT_DATABASE_NAME)).databaseLayout().getNeo4jLayout();
dbms.shutdown();
assertEquals(serverDir.relativize(serverLayout.homeDirectory()), embeddedDir.relativize(embeddedLayout.homeDirectory()));
assertEquals(serverDir.relativize(serverLayout.databasesDirectory()), embeddedDir.relativize(embeddedLayout.databasesDirectory()));
assertEquals(serverDir.relativize(serverLayout.transactionLogsRootDirectory()), embeddedDir.relativize(embeddedLayout.transactionLogsRootDirectory()));
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class ConcurrentUpdateIT method populateDbWithConcurrentUpdates.
@Test
void populateDbWithConcurrentUpdates() throws Exception {
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(databaseLayout).build();
GraphDatabaseService database = managementService.database(DEFAULT_DATABASE_NAME);
try {
RandomValues randomValues = RandomValues.create();
int counter = 1;
for (int j = 0; j < 100; j++) {
try (Transaction transaction = database.beginTx()) {
for (int i = 0; i < 5; i++) {
Node node = transaction.createNode(Label.label("label" + counter));
node.setProperty("property", randomValues.nextValue().asObject());
}
transaction.commit();
}
counter++;
}
int populatorCount = 5;
ExecutorService executor = Executors.newFixedThreadPool(populatorCount);
CountDownLatch startSignal = new CountDownLatch(1);
AtomicBoolean endSignal = new AtomicBoolean();
for (int i = 0; i < populatorCount; i++) {
executor.submit(new Populator(database, counter, startSignal, endSignal));
}
try {
try (Transaction transaction = database.beginTx()) {
transaction.schema().indexFor(Label.label("label10")).on("property").create();
transaction.commit();
}
startSignal.countDown();
try (Transaction transaction = database.beginTx()) {
transaction.schema().awaitIndexesOnline(populatorCount, TimeUnit.MINUTES);
transaction.commit();
}
} finally {
endSignal.set(true);
executor.shutdown();
// Basically we don't care to await their completion because they've done their job
}
} finally {
managementService.shutdown();
ConsistencyCheckService consistencyCheckService = new ConsistencyCheckService();
Config config = Config.defaults(GraphDatabaseSettings.pagecache_memory, "8m");
consistencyCheckService.runFullConsistencyCheck(databaseLayout, config, ProgressMonitorFactory.NONE, new Log4jLogProvider(System.out), false);
}
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class IndexPopulationIT method shutdownDatabaseDuringIndexPopulations.
@Test
void shutdownDatabaseDuringIndexPopulations() {
AssertableLogProvider assertableLogProvider = new AssertableLogProvider(true);
Path storeDir = directory.directory("shutdownDbTest");
Label testLabel = Label.label("testLabel");
String propertyName = "testProperty";
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(storeDir).setInternalLogProvider(assertableLogProvider).build();
GraphDatabaseService shutDownDb = managementService.database(DEFAULT_DATABASE_NAME);
prePopulateDatabase(shutDownDb, testLabel, propertyName);
try (Transaction transaction = shutDownDb.beginTx()) {
transaction.schema().indexFor(testLabel).on(propertyName).create();
transaction.commit();
}
managementService.shutdown();
assertThat(assertableLogProvider).forClass(IndexPopulationJob.class).forLevel(ERROR).doesNotHaveAnyLogs();
}
Aggregations