Search in sources :

Example 56 with DatabaseLayout

use of org.neo4j.io.layout.DatabaseLayout 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 57 with DatabaseLayout

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

the class MemoryRecommendationsCommandTest method mustPrintMinimalPageCacheMemorySettingForConfiguredDb.

@Test
void mustPrintMinimalPageCacheMemorySettingForConfiguredDb() throws Exception {
    // given
    Path homeDir = neo4jLayout.homeDirectory();
    Path configDir = homeDir.resolve("conf");
    Files.createDirectories(configDir);
    Path configFile = configDir.resolve(DEFAULT_CONFIG_FILE_NAME);
    Files.createFile(configFile);
    createDatabaseWithNativeIndexes(homeDir, DEFAULT_DATABASE_NAME);
    PrintStream output = mock(PrintStream.class);
    MemoryRecommendationsCommand command = new MemoryRecommendationsCommand(new ExecutionContext(homeDir, configDir, output, mock(PrintStream.class), testDirectory.getFileSystem()));
    String heap = bytesToString(recommendHeapMemory(gibiBytes(8)));
    String pagecache = bytesToString(recommendPageCacheMemory(gibiBytes(8), gibiBytes(2)));
    // when
    CommandLine.populateCommand(command, "--memory=8g");
    command.execute();
    // then
    verify(output).println(contains(initial_heap_size.name() + "=" + heap));
    verify(output).println(contains(max_heap_size.name() + "=" + heap));
    verify(output).println(contains(pagecache_memory.name() + "=" + pagecache));
    DatabaseLayout databaseLayout = neo4jLayout.databaseLayout(DEFAULT_DATABASE_NAME);
    DatabaseLayout systemLayout = neo4jLayout.databaseLayout(SYSTEM_DATABASE_NAME);
    long[] expectedSizes = calculatePageCacheFileSize(databaseLayout);
    long[] systemSizes = calculatePageCacheFileSize(systemLayout);
    long expectedPageCacheSize = expectedSizes[0] + systemSizes[0];
    long expectedLuceneSize = expectedSizes[1] + systemSizes[1];
    verify(output).println(contains("Total size of lucene indexes in all databases: " + bytesToString(expectedLuceneSize)));
    verify(output).println(contains("Total size of data and native indexes in all databases: " + bytesToString(expectedPageCacheSize)));
}
Also used : Path(java.nio.file.Path) PrintStream(java.io.PrintStream) ExecutionContext(org.neo4j.cli.ExecutionContext) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) MemoryRecommendationsCommand.bytesToString(org.neo4j.commandline.dbms.MemoryRecommendationsCommand.bytesToString) Test(org.junit.jupiter.api.Test)

Example 58 with DatabaseLayout

use of org.neo4j.io.layout.DatabaseLayout 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)

Example 59 with DatabaseLayout

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

the class MultipleIndexPopulationStressIT method createRandomData.

private void createRandomData(long nodeCount, long relCount) throws Exception {
    Config config = Config.defaults(neo4j_home, directory.homePath());
    RecordFormats recordFormats = RecordFormatSelector.selectForConfig(config, NullLogProvider.getInstance());
    try (RandomDataInput input = new RandomDataInput(nodeCount, relCount);
        JobScheduler jobScheduler = new ThreadPoolJobScheduler()) {
        DatabaseLayout layout = Neo4jLayout.of(directory.homePath()).databaseLayout(DEFAULT_DATABASE_NAME);
        IndexImporterFactory indexImporterFactory = new IndexImporterFactoryImpl(config);
        BatchImporter importer = new ParallelBatchImporter(layout, fileSystemAbstraction, PageCacheTracer.NULL, DEFAULT, NullLogService.getInstance(), ExecutionMonitor.INVISIBLE, EMPTY, config, recordFormats, NO_MONITOR, jobScheduler, Collector.EMPTY, TransactionLogInitializer.getLogFilesInitializer(), indexImporterFactory, INSTANCE);
        importer.doImport(input);
    }
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler) ParallelBatchImporter(org.neo4j.internal.batchimport.ParallelBatchImporter) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) BatchImporter(org.neo4j.internal.batchimport.BatchImporter) ParallelBatchImporter(org.neo4j.internal.batchimport.ParallelBatchImporter) Config(org.neo4j.configuration.Config) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) IndexImporterFactory(org.neo4j.internal.batchimport.IndexImporterFactory) IndexImporterFactoryImpl(org.neo4j.kernel.impl.index.schema.IndexImporterFactoryImpl) ThreadPoolJobScheduler(org.neo4j.test.scheduler.ThreadPoolJobScheduler)

Example 60 with DatabaseLayout

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

the class IndexCleanupIT method providerDirectories.

private Path[] providerDirectories(FileSystemAbstraction fs, GraphDatabaseAPI db) throws IOException {
    DatabaseLayout databaseLayout = db.databaseLayout();
    Path dbDir = databaseLayout.databaseDirectory();
    Path schemaDir = dbDir.resolve("schema");
    Path indexDir = schemaDir.resolve("index");
    return fs.listFiles(indexDir);
}
Also used : Path(java.nio.file.Path) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout)

Aggregations

DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)108 Test (org.junit.jupiter.api.Test)66 Path (java.nio.file.Path)51 Config (org.neo4j.configuration.Config)35 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)24 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)19 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)17 PageCache (org.neo4j.io.pagecache.PageCache)17 IOException (java.io.IOException)16 ConsistencyCheckService (org.neo4j.consistency.ConsistencyCheckService)16 Transaction (org.neo4j.graphdb.Transaction)13 DefaultIdGeneratorFactory (org.neo4j.internal.id.DefaultIdGeneratorFactory)10 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)9 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)9 CommandFailedException (org.neo4j.cli.CommandFailedException)8 ExecutionContext (org.neo4j.cli.ExecutionContext)8 PageCacheTracer (org.neo4j.io.pagecache.tracing.PageCacheTracer)8 StorageEngineFactory (org.neo4j.storageengine.api.StorageEngineFactory)8 Closeable (java.io.Closeable)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)7