Search in sources :

Example 16 with StorageEngineFactory

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)));
}
Also used : StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) StoreFilesDiagnostics(org.neo4j.kernel.diagnostics.providers.StoreFilesDiagnostics) ArrayList(java.util.ArrayList)

Example 17 with StorageEngineFactory

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());
}
Also used : FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) DbmsInfo(org.neo4j.kernel.impl.factory.DbmsInfo) Dependencies(org.neo4j.collection.Dependencies) StorageEngine(org.neo4j.storageengine.api.StorageEngine)

Example 18 with StorageEngineFactory

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));
}
Also used : DatabaseManager(org.neo4j.dbms.database.DatabaseManager) SimpleLogService(org.neo4j.logging.internal.SimpleLogService) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) Dependencies(org.neo4j.collection.Dependencies) StorageEngine(org.neo4j.storageengine.api.StorageEngine) StandaloneDatabaseContext(org.neo4j.dbms.database.StandaloneDatabaseContext) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 19 with StorageEngineFactory

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");
}
Also used : Path(java.nio.file.Path) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test)

Example 20 with StorageEngineFactory

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: ");
}
Also used : StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test)

Aggregations

StorageEngineFactory (org.neo4j.storageengine.api.StorageEngineFactory)24 Test (org.junit.jupiter.api.Test)9 Path (java.nio.file.Path)7 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)7 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)5 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)5 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)4 Dependencies (org.neo4j.collection.Dependencies)3 Config (org.neo4j.configuration.Config)3 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)3 CursorContext (org.neo4j.io.pagecache.context.CursorContext)3 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)3 StoreVersion (org.neo4j.storageengine.api.StoreVersion)3 SchemaIndexMigrator (org.neo4j.storageengine.migration.SchemaIndexMigrator)3 ArrayList (java.util.ArrayList)2 Transaction (org.neo4j.graphdb.Transaction)2 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)2 Neo4jLayout (org.neo4j.io.layout.Neo4jLayout)2 PageCache (org.neo4j.io.pagecache.PageCache)2 IndexDirectoryStructure (org.neo4j.kernel.api.index.IndexDirectoryStructure)2