Search in sources :

Example 6 with Neo4jLayout

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

the class KernelDiagnosticsIT method shouldIncludeNativeIndexFilesInTotalMappedSize.

@Test
void shouldIncludeNativeIndexFilesInTotalMappedSize() {
    for (GraphDatabaseSettings.SchemaIndex schemaIndex : GraphDatabaseSettings.SchemaIndex.values()) {
        // given
        Neo4jLayout layout = neo4jLayout;
        createIndexInIsolatedDbInstance(layout.homeDirectory(), schemaIndex);
        // when
        DatabaseLayout databaseLayout = layout.databaseLayout(DEFAULT_DATABASE_NAME);
        StorageEngineFactory storageEngineFactory = StorageEngineFactory.defaultStorageEngine();
        StoreFilesDiagnostics files = new StoreFilesDiagnostics(storageEngineFactory, fs, databaseLayout);
        SizeCapture capture = new SizeCapture();
        files.dump(capture::log);
        assertNotNull(capture.size);
        // then
        long expected = manuallyCountTotalMappedFileSize(databaseLayout.databaseDirectory());
        assertEquals(bytesToString(expected), capture.size);
    }
}
Also used : GraphDatabaseSettings(org.neo4j.configuration.GraphDatabaseSettings) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) StoreFilesDiagnostics(org.neo4j.kernel.diagnostics.providers.StoreFilesDiagnostics) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) Neo4jLayout(org.neo4j.io.layout.Neo4jLayout) Test(org.junit.jupiter.api.Test)

Example 7 with Neo4jLayout

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

the class DbRepresentation method of.

public static DbRepresentation of(DatabaseLayout databaseLayout, Config config) {
    Neo4jLayout layout = databaseLayout.getNeo4jLayout();
    Config cfg = Config.newBuilder().fromConfig(config).setDefault(transaction_logs_root_path, layout.transactionLogsRootDirectory().toAbsolutePath()).setDefault(databases_root_path, layout.databasesDirectory().toAbsolutePath()).setDefault(default_database, databaseLayout.getDatabaseName()).build();
    return of(databaseLayout.databaseDirectory(), cfg);
}
Also used : Config(org.neo4j.configuration.Config) Neo4jLayout(org.neo4j.io.layout.Neo4jLayout)

Example 8 with Neo4jLayout

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

the class DatabaseManagementServiceBuilderIT method notConfiguredDatabasesRootPath.

@Test
void notConfiguredDatabasesRootPath() throws IOException {
    Neo4jLayout layout = neo4jLayout;
    DatabaseManagementService managementService = getDbmsBuilderWithLimitedTxLogSize(layout.homeDirectory()).build();
    try {
        assertFalse(isEmptyOrNonExistingDirectory(fs, layout.databaseLayout(DEFAULT_DATABASE_NAME).databaseDirectory()));
        assertFalse(isEmptyOrNonExistingDirectory(fs, layout.databaseLayout(SYSTEM_DATABASE_NAME).databaseDirectory()));
    } finally {
        managementService.shutdown();
    }
}
Also used : Neo4jLayout(org.neo4j.io.layout.Neo4jLayout) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) Test(org.junit.jupiter.api.Test)

Example 9 with Neo4jLayout

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

the class MemoryRecommendationsCommand method execute.

@Override
protected void execute() throws IOException {
    if (memory == null) {
        memory = OsBeanUtil.getTotalPhysicalMemory();
    }
    Path configFile = ctx.confDir().resolve(Config.DEFAULT_CONFIG_FILE_NAME);
    Config config = getConfig(configFile);
    final long offHeapMemory = recommendTxStateMemory(config, memory);
    String os = bytesToString(recommendOsMemory(memory));
    String heap = bytesToString(recommendHeapMemory(memory));
    String pagecache = bytesToString(recommendPageCacheMemory(memory, offHeapMemory));
    String txState = bytesToString(offHeapMemory);
    Path databasesRoot = config.get(databases_root_path);
    Neo4jLayout storeLayout = Neo4jLayout.of(config);
    Collection<DatabaseLayout> layouts = storeLayout.databaseLayouts();
    long pageCacheSize = pageCacheSize(layouts);
    long luceneSize = luceneSize(layouts);
    print("# Memory settings recommendation from neo4j-admin memrec:");
    print("#");
    print("# Assuming the system is dedicated to running Neo4j and has " + ByteUnit.bytesToString(memory) + " of memory,");
    print("# we recommend a heap size of around " + heap + ", and a page cache of around " + pagecache + ",");
    print("# and that about " + os + " is left for the operating system, and the native memory");
    print("# needed by Lucene and Netty.");
    print("#");
    print("# Tip: If the indexing storage use is high, e.g. there are many indexes or most");
    print("# data indexed, then it might advantageous to leave more memory for the");
    print("# operating system.");
    print("#");
    print("# Tip: Depending on the workload type you may want to increase the amount");
    print("# of off-heap memory available for storing transaction state.");
    print("# For instance, in case of large write-intensive transactions");
    print("# increasing it can lower GC overhead and thus improve performance.");
    print("# On the other hand, if vast majority of transactions are small or read-only");
    print("# then you can decrease it and increase page cache instead.");
    print("#");
    print("# Tip: The more concurrent transactions your workload has and the more updates");
    print("# they do, the more heap memory you will need. However, don't allocate more");
    print("# than 31g of heap, since this will disable pointer compression, also known as");
    print("# \"compressed oops\", in the JVM and make less effective use of the heap.");
    print("#");
    print("# Tip: Setting the initial and the max heap size to the same value means the");
    print("# JVM will never need to change the heap size. Changing the heap size otherwise");
    print("# involves a full GC, which is desirable to avoid.");
    print("#");
    print("# Based on the above, the following memory settings are recommended:");
    printSetting(initial_heap_size, heap);
    printSetting(max_heap_size, heap);
    printSetting(pagecache_memory, pagecache);
    if (offHeapMemory != 0) {
        printSetting(tx_state_max_off_heap_memory, txState);
    }
    print("#");
    print("# It is also recommended turning out-of-memory errors into full crashes,");
    print("# instead of allowing a partially crashed database to continue running:");
    printSetting(additional_jvm, "-XX:+ExitOnOutOfMemoryError");
    print("#");
    print("# The numbers below have been derived based on your current databases located at: '" + databasesRoot + "'.");
    print("# They can be used as an input into more detailed memory analysis.");
    print("# Total size of lucene indexes in all databases: " + bytesToString(luceneSize));
    print("# Total size of data and native indexes in all databases: " + bytesToString(pageCacheSize));
}
Also used : Path(java.nio.file.Path) Config(org.neo4j.configuration.Config) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) Neo4jLayout(org.neo4j.io.layout.Neo4jLayout)

Example 10 with Neo4jLayout

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

the class StoreInfoCommand method execute.

@Override
public void execute() {
    var storageEngineFactory = StorageEngineFactory.defaultStorageEngine();
    var config = CommandHelpers.buildConfig(ctx, allowCommandExpansion);
    var neo4jLayout = Neo4jLayout.of(config);
    try (var fs = ctx.fs();
        var jobScheduler = createInitialisedScheduler();
        var pageCache = StandalonePageCacheFactory.createPageCache(fs, jobScheduler, PageCacheTracer.NULL)) {
        validatePath(fs, all, path, neo4jLayout);
        if (all) {
            var collector = structured ? Collectors.joining(",", "[", "]") : Collectors.joining(System.lineSeparator() + System.lineSeparator());
            var result = Arrays.stream(fs.listFiles(path)).sorted(comparing(Path::getFileName)).map(dbPath -> neo4jLayout.databaseLayout(dbPath.getFileName().toString())).filter(dbLayout -> Validators.isExistingDatabase(fs, dbLayout)).map(dbLayout -> printInfo(fs, dbLayout, pageCache, storageEngineFactory, config, structured, true)).collect(collector);
            ctx.out().println(result);
        } else {
            var databaseLayout = neo4jLayout.databaseLayout(path.getFileName().toString());
            ctx.out().println(printInfo(fs, databaseLayout, pageCache, storageEngineFactory, config, structured, false));
        }
    } catch (CommandFailedException e) {
        throw e;
    } catch (Exception e) {
        throw new CommandFailedException(format("Failed to execute command: '%s'.", e.getMessage()), e);
    }
}
Also used : Arrays(java.util.Arrays) Parameters(picocli.CommandLine.Parameters) NullLogService(org.neo4j.logging.internal.NullLogService) CursorContext(org.neo4j.io.pagecache.context.CursorContext) Config(org.neo4j.configuration.Config) EmptyMemoryTracker(org.neo4j.memory.EmptyMemoryTracker) JobSchedulerFactory.createInitialisedScheduler(org.neo4j.kernel.impl.scheduler.JobSchedulerFactory.createInitialisedScheduler) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) Recovery.isRecoveryRequired(org.neo4j.kernel.recovery.Recovery.isRecoveryRequired) AbstractCommand(org.neo4j.cli.AbstractCommand) Comparator.comparing(java.util.Comparator.comparing) Command(picocli.CommandLine.Command) Path(java.nio.file.Path) MemoryTracker(org.neo4j.memory.MemoryTracker) PageCache(org.neo4j.io.pagecache.PageCache) Validators(org.neo4j.kernel.impl.util.Validators) StandalonePageCacheFactory(org.neo4j.io.pagecache.impl.muninn.StandalonePageCacheFactory) Collectors(java.util.stream.Collectors) Neo4jLayout(org.neo4j.io.layout.Neo4jLayout) String.format(java.lang.String.format) ExecutionContext(org.neo4j.cli.ExecutionContext) Objects(java.util.Objects) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) Option(picocli.CommandLine.Option) List(java.util.List) FileLockException(org.neo4j.kernel.internal.locker.FileLockException) CommandFailedException(org.neo4j.cli.CommandFailedException) Pair(org.neo4j.internal.helpers.collection.Pair) StoreVersion(org.neo4j.storageengine.api.StoreVersion) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) CommandFailedException(org.neo4j.cli.CommandFailedException) FileLockException(org.neo4j.kernel.internal.locker.FileLockException) CommandFailedException(org.neo4j.cli.CommandFailedException)

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