Search in sources :

Example 1 with Neo4jLayout

use of org.neo4j.io.layout.Neo4jLayout in project neo4j by neo4j.

the class Neo4jLayoutSupportExtensionTest method shouldUseDefaultConfig.

@Test
void shouldUseDefaultConfig() {
    Config defaultConfig = Config.defaults(neo4j_home, testDirectory.homePath());
    Neo4jLayout defaultNeo4jLayout = Neo4jLayout.of(defaultConfig);
    DatabaseLayout defaultDatabaseLayout = defaultNeo4jLayout.databaseLayout(defaultConfig.get(default_database));
    assertEquals(defaultNeo4jLayout.homeDirectory(), neo4jLayout.homeDirectory());
    assertEquals(defaultNeo4jLayout.databasesDirectory(), neo4jLayout.databasesDirectory());
    assertEquals(defaultNeo4jLayout.transactionLogsRootDirectory(), neo4jLayout.transactionLogsRootDirectory());
    assertEquals(defaultDatabaseLayout.databaseDirectory(), databaseLayout.databaseDirectory());
    assertEquals(defaultDatabaseLayout.getTransactionLogsDirectory(), databaseLayout.getTransactionLogsDirectory());
}
Also used : Config(org.neo4j.configuration.Config) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) Neo4jLayout(org.neo4j.io.layout.Neo4jLayout) Test(org.junit.jupiter.api.Test)

Example 2 with Neo4jLayout

use of org.neo4j.io.layout.Neo4jLayout 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()));
}
Also used : Path(java.nio.file.Path) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) Neo4jLayout(org.neo4j.io.layout.Neo4jLayout) Test(org.junit.Test)

Example 3 with Neo4jLayout

use of org.neo4j.io.layout.Neo4jLayout in project neo4j by neo4j.

the class DatabaseLayoutWatcher method watchDirectories.

private void watchDirectories() {
    Neo4jLayout layout = databaseLayout.getNeo4jLayout();
    watch(databaseLayout.databaseDirectory());
    watch(databaseLayout.getTransactionLogsDirectory());
    watch(layout.databasesDirectory());
    watch(layout.transactionLogsRootDirectory());
    watch(layout.homeDirectory());
    startWatching();
}
Also used : Neo4jLayout(org.neo4j.io.layout.Neo4jLayout)

Example 4 with Neo4jLayout

use of org.neo4j.io.layout.Neo4jLayout in project neo4j by neo4j.

the class PushToCloudCommandTest method createDbAndDump.

private void createDbAndDump() {
    Config config = Config.newBuilder().set(GraphDatabaseSettings.neo4j_home, homeDir.toAbsolutePath()).set(default_database, DBNAME).build();
    DatabaseLayout databaseLayout = DatabaseLayout.of(config);
    Neo4jLayout neo4jLayout = databaseLayout.getNeo4jLayout();
    DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(neo4jLayout.homeDirectory()).setConfig(config).build();
    managementService.database(databaseLayout.getDatabaseName());
    managementService.shutdown();
    dump = directory.file("some-archive.dump");
    new RealDumpCreator(ctx).dumpDatabase(DBNAME, dump);
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) Config(org.neo4j.configuration.Config) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) Neo4jLayout(org.neo4j.io.layout.Neo4jLayout) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService)

Example 5 with Neo4jLayout

use of org.neo4j.io.layout.Neo4jLayout in project neo4j by neo4j.

the class Neo4jLayoutSupportExtension method prepare.

private void prepare(ExtensionContext context) {
    TestInstances testInstances = context.getRequiredTestInstances();
    TestDirectory testDir = getTestDirectory(context);
    Config config = Config.defaults(neo4j_home, testDir.homePath());
    Neo4jLayout neo4jLayout = Neo4jLayout.of(config);
    DatabaseLayout databaseLayout = neo4jLayout.databaseLayout(config.get(default_database));
    createDirectories(testDir.getFileSystem(), neo4jLayout, databaseLayout);
    for (Object testInstance : testInstances.getAllInstances()) {
        injectInstance(testInstance, neo4jLayout, Neo4jLayout.class);
        injectInstance(testInstance, databaseLayout, DatabaseLayout.class);
    }
}
Also used : TestDirectory(org.neo4j.test.rule.TestDirectory) Config(org.neo4j.configuration.Config) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) TestInstances(org.junit.jupiter.api.extension.TestInstances) Neo4jLayout(org.neo4j.io.layout.Neo4jLayout)

Aggregations

Neo4jLayout (org.neo4j.io.layout.Neo4jLayout)10 Config (org.neo4j.configuration.Config)6 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)6 Path (java.nio.file.Path)3 Test (org.junit.jupiter.api.Test)3 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)3 StorageEngineFactory (org.neo4j.storageengine.api.StorageEngineFactory)2 String.format (java.lang.String.format)1 Arrays (java.util.Arrays)1 Comparator.comparing (java.util.Comparator.comparing)1 List (java.util.List)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Test (org.junit.Test)1 TestInstances (org.junit.jupiter.api.extension.TestInstances)1 AbstractCommand (org.neo4j.cli.AbstractCommand)1 CommandFailedException (org.neo4j.cli.CommandFailedException)1 ExecutionContext (org.neo4j.cli.ExecutionContext)1 GraphDatabaseSettings (org.neo4j.configuration.GraphDatabaseSettings)1 Pair (org.neo4j.internal.helpers.collection.Pair)1