use of org.neo4j.kernel.impl.transaction.log.entry.LogVersions.CURRENT_FORMAT_LOG_HEADER_SIZE in project neo4j by neo4j.
the class ThresholdBasedPruneStrategyTest method shouldNotDeleteAnythingIfThresholdDoesNotAllow.
@Test
void shouldNotDeleteAnythingIfThresholdDoesNotAllow() throws IOException {
// Given
Path fileName0 = Path.of("logical.log.v0");
Path fileName1 = Path.of("logical.log.v1");
Path fileName2 = Path.of("logical.log.v2");
Path fileName3 = Path.of("logical.log.v3");
Path fileName4 = Path.of("logical.log.v4");
Path fileName5 = Path.of("logical.log.v5");
Path fileName6 = Path.of("logical.log.v6");
when(logFile.getLogFileForVersion(6)).thenReturn(fileName6);
when(logFile.getLogFileForVersion(5)).thenReturn(fileName5);
when(logFile.getLogFileForVersion(4)).thenReturn(fileName4);
when(logFile.getLogFileForVersion(3)).thenReturn(fileName3);
when(logFile.getLogFileForVersion(2)).thenReturn(fileName2);
when(logFile.getLogFileForVersion(1)).thenReturn(fileName1);
when(logFile.getLogFileForVersion(0)).thenReturn(fileName0);
when(logFile.getLowestLogVersion()).thenReturn(0L);
when(fileSystem.fileExists(fileName6)).thenReturn(true);
when(fileSystem.fileExists(fileName5)).thenReturn(true);
when(fileSystem.fileExists(fileName4)).thenReturn(true);
when(fileSystem.fileExists(fileName3)).thenReturn(true);
when(fileSystem.fileExists(fileName2)).thenReturn(true);
when(fileSystem.fileExists(fileName1)).thenReturn(true);
when(fileSystem.fileExists(fileName0)).thenReturn(true);
when(fileSystem.getFileSize(any(Path.class))).thenReturn(CURRENT_FORMAT_LOG_HEADER_SIZE + 1L);
when(threshold.reached(any(), anyLong(), any())).thenReturn(false);
ThresholdBasedPruneStrategy strategy = new ThresholdBasedPruneStrategy(logFile, threshold);
// When
strategy.findLogVersionsToDelete(7L).forEachOrdered(uncheckedLongConsumer(v -> fileSystem.deleteFile(logFile.getLogFileForVersion(v))));
// Then
verify(threshold).init();
verify(fileSystem, never()).deleteFile(any(Path.class));
}
use of org.neo4j.kernel.impl.transaction.log.entry.LogVersions.CURRENT_FORMAT_LOG_HEADER_SIZE in project neo4j by neo4j.
the class ThresholdBasedPruneStrategyTest method shouldDeleteJustWhatTheThresholdSays.
@Test
void shouldDeleteJustWhatTheThresholdSays() throws IOException {
// Given
when(threshold.reached(any(), eq(6L), any())).thenReturn(false);
when(threshold.reached(any(), eq(5L), any())).thenReturn(false);
when(threshold.reached(any(), eq(4L), any())).thenReturn(false);
when(threshold.reached(any(), eq(3L), any())).thenReturn(true);
Path fileName1 = Path.of("logical.log.v1");
Path fileName2 = Path.of("logical.log.v2");
Path fileName3 = Path.of("logical.log.v3");
Path fileName4 = Path.of("logical.log.v4");
Path fileName5 = Path.of("logical.log.v5");
Path fileName6 = Path.of("logical.log.v6");
when(logFile.getLogFileForVersion(6)).thenReturn(fileName6);
when(logFile.getLogFileForVersion(5)).thenReturn(fileName5);
when(logFile.getLogFileForVersion(4)).thenReturn(fileName4);
when(logFile.getLogFileForVersion(3)).thenReturn(fileName3);
when(logFile.getLogFileForVersion(2)).thenReturn(fileName2);
when(logFile.getLogFileForVersion(1)).thenReturn(fileName1);
when(logFile.getLowestLogVersion()).thenReturn(1L);
when(fileSystem.getFileSize(any(Path.class))).thenReturn(CURRENT_FORMAT_LOG_HEADER_SIZE + 1L);
ThresholdBasedPruneStrategy strategy = new ThresholdBasedPruneStrategy(logFile, threshold);
// When
strategy.findLogVersionsToDelete(7L).forEachOrdered(uncheckedLongConsumer(v -> fileSystem.deleteFile(logFile.getLogFileForVersion(v))));
// Then
verify(threshold).init();
verify(fileSystem).deleteFile(fileName1);
verify(fileSystem).deleteFile(fileName2);
verify(fileSystem).deleteFile(fileName3);
verify(fileSystem, never()).deleteFile(fileName4);
verify(fileSystem, never()).deleteFile(fileName5);
verify(fileSystem, never()).deleteFile(fileName6);
}
Aggregations