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);
}
}
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);
}
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();
}
}
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));
}
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);
}
}
Aggregations