Search in sources :

Example 61 with DatabaseLayout

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

the class TokenIndexProviderCompatibilitySuiteTest method createIndexProvider.

@Override
protected IndexProvider createIndexProvider(PageCache pageCache, FileSystemAbstraction fs, Path graphDbDir, Config config) {
    Monitors monitors = new Monitors();
    String monitorTag = "";
    RecoveryCleanupWorkCollector recoveryCleanupWorkCollector = RecoveryCleanupWorkCollector.immediate();
    DatabaseLayout databaseLayout = DatabaseLayout.ofFlat(graphDbDir);
    var readOnlyChecker = new DatabaseReadOnlyChecker.Default(config, databaseLayout.getDatabaseName());
    return TokenIndexProviderFactory.create(pageCache, graphDbDir, fs, monitors, monitorTag, config, readOnlyChecker, recoveryCleanupWorkCollector, databaseLayout, PageCacheTracer.NULL);
}
Also used : Monitors(org.neo4j.monitoring.Monitors) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) RecoveryCleanupWorkCollector(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector)

Example 62 with DatabaseLayout

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

the class DatabaseRecoveryIT method copyStore.

private DatabaseLayout copyStore() throws IOException {
    DatabaseLayout restoreDbLayout = Neo4jLayout.of(directory.homePath("restore-db")).databaseLayout(DEFAULT_DATABASE_NAME);
    fileSystem.mkdirs(restoreDbLayout.databaseDirectory());
    fileSystem.mkdirs(restoreDbLayout.getTransactionLogsDirectory());
    copy(fileSystem, databaseLayout.getTransactionLogsDirectory(), restoreDbLayout.getTransactionLogsDirectory());
    copy(fileSystem, databaseLayout.databaseDirectory(), restoreDbLayout.databaseDirectory());
    return restoreDbLayout;
}
Also used : DatabaseLayout(org.neo4j.io.layout.DatabaseLayout)

Example 63 with DatabaseLayout

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

the class TransactionLogInitializerTest method shouldResetMetaDataStoreWithTransactionId.

@Test
void shouldResetMetaDataStoreWithTransactionId() throws Exception {
    // Given
    var metaStore = mock(MetadataProvider.class);
    var txn = new TransactionId(3, -1322858814, currentTimeMillis());
    when(metaStore.getStoreId()).thenReturn(new StoreId(versionStringToLong(LATEST_STORE_VERSION)));
    when(metaStore.getLastClosedTransaction()).thenReturn(new long[] { txn.transactionId(), 0, 1613 });
    when(metaStore.getLastCommittedTransaction()).thenReturn(txn);
    when(metaStore.getLastCommittedTransactionId()).thenReturn(txn.transactionId());
    when(metaStore.getLastClosedTransactionId()).thenReturn(txn.transactionId());
    DatabaseLayout databaseLayout = Neo4jLayout.of(testDirectory.homePath()).databaseLayout(DEFAULT_DATABASE_NAME);
    // When
    var initializer = new TransactionLogInitializer(testDirectory.getFileSystem(), metaStore, INSTANCE, PageCacheTracer.NULL);
    initializer.initializeEmptyLogFile(databaseLayout, databaseLayout.getTransactionLogsDirectory(), "LostFiles");
    // Then
    verify(metaStore).resetLastClosedTransaction(eq(txn.transactionId()), eq(txn.transactionId()), eq((long) CURRENT_FORMAT_LOG_HEADER_SIZE), eq(true), any());
}
Also used : StoreId(org.neo4j.storageengine.api.StoreId) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) TransactionId(org.neo4j.storageengine.api.TransactionId) Test(org.junit.jupiter.api.Test)

Example 64 with DatabaseLayout

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

the class DatabaseFileListingTest method shouldCloseIndexSnapshots.

@Test
void shouldCloseIndexSnapshots() throws Exception {
    // Given
    IndexingService indexingService = mock(IndexingService.class);
    DatabaseLayout databaseLayout = mock(DatabaseLayout.class);
    when(databaseLayout.metadataStore()).thenReturn(mock(Path.class));
    LogFiles logFiles = mock(LogFiles.class);
    filesInStoreDirAre(databaseLayout, STANDARD_STORE_DIR_FILES, STANDARD_STORE_DIR_DIRECTORIES);
    StorageEngine storageEngine = mock(StorageEngine.class);
    IdGeneratorFactory idGeneratorFactory = mock(IdGeneratorFactory.class);
    DatabaseFileListing fileListing = new DatabaseFileListing(databaseLayout, logFiles, indexingService, storageEngine, idGeneratorFactory);
    ResourceIterator<Path> indexSnapshot = indexFilesAre(indexingService, new String[] { "schema/index/my.index" });
    ResourceIterator<StoreFileMetadata> result = fileListing.builder().excludeLogFiles().build();
    // When
    result.close();
    // Then
    verify(indexSnapshot).close();
}
Also used : Path(java.nio.file.Path) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) IdGeneratorFactory(org.neo4j.internal.id.IdGeneratorFactory) StoreFileMetadata(org.neo4j.storageengine.api.StoreFileMetadata) StorageEngine(org.neo4j.storageengine.api.StorageEngine) Test(org.junit.jupiter.api.Test)

Example 65 with DatabaseLayout

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

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