use of org.neo4j.kernel.impl.transaction.log.files.LogFiles 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.kernel.impl.transaction.log.files.LogFiles in project neo4j by neo4j.
the class DatabaseFileListingTest method verifyLogFilesWithCustomPathListing.
private void verifyLogFilesWithCustomPathListing(Path path) throws IOException {
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath("customDb")).setConfig(GraphDatabaseSettings.transaction_logs_root_path, path).build();
GraphDatabaseAPI graphDatabase = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
Database database = graphDatabase.getDependencyResolver().resolveDependency(Database.class);
LogFiles logFiles = graphDatabase.getDependencyResolver().resolveDependency(LogFiles.class);
assertTrue(database.listStoreFiles(true).stream().anyMatch(metadata -> metadata.isLogFile() && logFiles.isLogFile(metadata.path())));
assertEquals(path.getFileName().toString(), logFiles.logFilesDirectory().getParent().getFileName().toString());
managementService.shutdown();
}
use of org.neo4j.kernel.impl.transaction.log.files.LogFiles in project neo4j by neo4j.
the class CheckPointerIntegrationTest method checkPointsInTxLog.
private static List<CheckpointInfo> checkPointsInTxLog(GraphDatabaseService db) throws IOException {
DependencyResolver dependencyResolver = ((GraphDatabaseAPI) db).getDependencyResolver();
LogFiles logFiles = dependencyResolver.resolveDependency(LogFiles.class);
return logFiles.getCheckpointFile().reachableCheckpoints();
}
use of org.neo4j.kernel.impl.transaction.log.files.LogFiles in project neo4j by neo4j.
the class VersionAwareLogEntryReaderIT method correctlyResetPositionWhenEndOfCommandsReached.
@Test
void correctlyResetPositionWhenEndOfCommandsReached() throws IOException {
LogFiles logFiles = LogFilesBuilder.builder(databaseLayout, fs).withLogEntryReader(entryReader).withLogVersionRepository(new SimpleLogVersionRepository()).withTransactionIdStore(new SimpleTransactionIdStore()).withStoreId(StoreId.UNKNOWN).build();
try (Lifespan lifespan = new Lifespan(logFiles)) {
LogPosition logPosition = entryReader.lastPosition();
assertEquals(0L, logPosition.getLogVersion());
// this position in a log file before 0's are actually starting
assertEquals(END_OF_DATA_OFFSET, logPosition.getByteOffset());
for (int i = 0; i < 10; i++) {
assertEquals(END_OF_DATA_OFFSET, getLastReadablePosition(logFiles));
}
}
}
use of org.neo4j.kernel.impl.transaction.log.files.LogFiles in project neo4j by neo4j.
the class VersionAwareLogEntryReaderIT method readOnlyLogFilesWhileCommandsAreAvailable.
@Test
@EnabledOnOs(OS.LINUX)
void readOnlyLogFilesWhileCommandsAreAvailable() throws IOException {
LogFiles logFiles = LogFilesBuilder.builder(databaseLayout, fs).withLogEntryReader(entryReader).withLogVersionRepository(new SimpleLogVersionRepository()).withTransactionIdStore(new SimpleTransactionIdStore()).withStoreId(StoreId.UNKNOWN).build();
try (Lifespan lifespan = new Lifespan(logFiles)) {
assertEquals(kibiBytes(128), Files.size(logFiles.getLogFile().getHighestLogFile()));
LogPosition logPosition = entryReader.lastPosition();
assertEquals(0L, logPosition.getLogVersion());
// this position in a log file before 0's are actually starting
assertEquals(END_OF_DATA_OFFSET, logPosition.getByteOffset());
}
}
Aggregations