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