use of org.neo4j.storageengine.api.StorageEngineFactory in project neo4j by neo4j.
the class KernelDiagnosticsOfflineReportProvider method listDataDirectory.
/**
* Print a tree view of all the files in the database directory with files sizes.
*
* @param sources destination of the sources.
*/
private void listDataDirectory(List<DiagnosticsReportSource> sources) {
StorageEngineFactory storageEngineFactory = StorageEngineFactory.defaultStorageEngine();
StoreFilesDiagnostics storeFiles = new StoreFilesDiagnostics(storageEngineFactory, fs, databaseLayout);
List<String> files = new ArrayList<>();
storeFiles.dump(files::add);
sources.add(DiagnosticsReportSources.newDiagnosticsString("tree.txt", () -> String.join(System.lineSeparator(), files)));
}
use of org.neo4j.storageengine.api.StorageEngineFactory in project neo4j by neo4j.
the class DbmsDiagnosticsManager method dumpDatabaseDiagnostics.
private static void dumpDatabaseDiagnostics(Database database, Log log, boolean checkStatus) {
dumpAsSingleMessageWithDbPrefix(log, stringJoiner -> {
dumpDatabaseSectionName(database, stringJoiner::add);
if (checkStatus) {
logDatabaseStatus(database, stringJoiner::add);
if (!database.isStarted()) {
return;
}
}
Dependencies databaseResolver = database.getDependencyResolver();
DbmsInfo dbmsInfo = databaseResolver.resolveDependency(DbmsInfo.class);
FileSystemAbstraction fs = databaseResolver.resolveDependency(FileSystemAbstraction.class);
StorageEngineFactory storageEngineFactory = databaseResolver.resolveDependency(StorageEngineFactory.class);
StorageEngine storageEngine = databaseResolver.resolveDependency(StorageEngine.class);
DiagnosticsManager.dump(new VersionDiagnostics(dbmsInfo, database.getStoreId()), log, stringJoiner::add);
DiagnosticsManager.dump(new StoreFilesDiagnostics(storageEngineFactory, fs, database.getDatabaseLayout()), log, stringJoiner::add);
DiagnosticsManager.dump(new TransactionRangeDiagnostics(database), log, stringJoiner::add);
storageEngine.dumpDiagnostics(log, stringJoiner::add);
}, database.getNamedDatabaseId());
}
use of org.neo4j.storageengine.api.StorageEngineFactory in project neo4j by neo4j.
the class DbmsDiagnosticsManagerTest method setUp.
@BeforeEach
@SuppressWarnings("unchecked")
void setUp() throws IOException {
logProvider = new AssertableLogProvider();
databaseManager = mock(DatabaseManager.class);
storageEngine = mock(StorageEngine.class);
storageEngineFactory = mock(StorageEngineFactory.class);
defaultContext = mock(StandaloneDatabaseContext.class);
defaultDatabase = prepareDatabase();
when(storageEngineFactory.listStorageFiles(any(), any())).thenReturn(Collections.emptyList());
dependencies = new Dependencies();
dependencies.satisfyDependency(Config.defaults());
dependencies.satisfyDependency(databaseManager);
when(defaultContext.database()).thenReturn(defaultDatabase);
when(databaseManager.getDatabaseContext(DEFAULT_DATABASE_ID)).thenReturn(Optional.of(defaultContext));
when(databaseManager.registeredDatabases()).thenReturn(new TreeMap<>(singletonMap(DEFAULT_DATABASE_ID, defaultContext)));
diagnosticsManager = new DbmsDiagnosticsManager(dependencies, new SimpleLogService(logProvider));
}
use of org.neo4j.storageengine.api.StorageEngineFactory in project neo4j by neo4j.
the class KernelDiagnosticsTest method shouldCountFileSizeRecursively.
@Test
void shouldCountFileSizeRecursively() throws IOException {
// file structure:
// storeDir/indexDir/indexFile (1 kB)
// storeDir/neostore (3 kB)
Path storeDir = testDirectory.directory("storedir");
DatabaseLayout layout = DatabaseLayout.ofFlat(storeDir);
Path indexDir = directory(storeDir, "indexDir");
file(indexDir, "indexFile", (int) kibiBytes(1));
file(storeDir, layout.metadataStore().getFileName().toString(), (int) kibiBytes(3));
StorageEngineFactory storageEngineFactory = mock(StorageEngineFactory.class);
when(storageEngineFactory.listStorageFiles(any(), any())).thenReturn(singletonList(layout.metadataStore()));
AssertableLogProvider logProvider = new AssertableLogProvider();
StoreFilesDiagnostics storeFiles = new StoreFilesDiagnostics(storageEngineFactory, fs, layout);
storeFiles.dump(logProvider.getLog(getClass())::debug);
assertThat(logProvider).containsMessages("Total size of store: 4.000KiB", "Total size of mapped files: 3.000KiB");
}
use of org.neo4j.storageengine.api.StorageEngineFactory in project neo4j by neo4j.
the class KernelDiagnosticsTest method printDatabaseFileStoreType.
@Test
void printDatabaseFileStoreType() {
StorageEngineFactory storageEngineFactory = mock(StorageEngineFactory.class);
AssertableLogProvider logProvider = new AssertableLogProvider();
StoreFilesDiagnostics storeFiles = new StoreFilesDiagnostics(storageEngineFactory, fs, databaseLayout);
storeFiles.dump(logProvider.getLog(getClass())::debug);
assertThat(logProvider).containsMessages("Storage files stored on file store: ");
}
Aggregations