use of org.neo4j.kernel.impl.transaction.log.files.checkpoint.CheckpointFile in project neo4j by neo4j.
the class CorruptedLogsTruncator method backupCorruptedContent.
private void backupCorruptedContent(long recoveredTransactionLogVersion, long recoveredTransactionOffset, Optional<CheckpointInfo> corruptCheckpoint) throws IOException {
Path corruptedLogArchive = getArchiveFile(recoveredTransactionLogVersion, recoveredTransactionOffset);
try (ZipOutputStream recoveryContent = new ZipOutputStream(fs.openAsOutputStream(corruptedLogArchive, false));
var bufferScope = new HeapScopedBuffer(1, MebiByte, memoryTracker)) {
LogFile transactionLogFile = logFiles.getLogFile();
copyLogsContent(recoveredTransactionLogVersion, recoveredTransactionOffset, transactionLogFile.getHighestLogVersion(), recoveryContent, bufferScope, transactionLogFile::getLogFileForVersion);
if (corruptCheckpoint.isPresent()) {
LogPosition checkpointPosition = corruptCheckpoint.get().getCheckpointEntryPosition();
CheckpointFile checkpointFile = logFiles.getCheckpointFile();
copyLogsContent(checkpointPosition.getLogVersion(), checkpointPosition.getByteOffset(), checkpointFile.getCurrentDetachedLogVersion(), recoveryContent, bufferScope, checkpointFile::getDetachedCheckpointFileForVersion);
}
}
}
use of org.neo4j.kernel.impl.transaction.log.files.checkpoint.CheckpointFile in project neo4j by neo4j.
the class TransactionRangeDiagnosticsTest method logs.
private static LogFiles logs(ThrowingConsumer<LogFile, IOException> transactionLogs, ThrowingConsumer<CheckpointFile, IOException> checkpointLogs) throws IOException {
LogFiles files = mock(TransactionLogFiles.class);
when(files.logFilesDirectory()).thenReturn(Path.of("."));
LogFile transactionFiles = mock(LogFile.class);
when(files.getLogFile()).thenReturn(transactionFiles);
transactionLogs.accept(transactionFiles);
CheckpointFile checkpointFiles = mock(CheckpointFile.class);
when(files.getCheckpointFile()).thenReturn(checkpointFiles);
checkpointLogs.accept(checkpointFiles);
return files;
}
use of org.neo4j.kernel.impl.transaction.log.files.checkpoint.CheckpointFile in project neo4j by neo4j.
the class DetachedCheckpointAppenderTest method appendedCheckpointsCanBeLookedUpFromCheckpointFile.
@Test
void appendedCheckpointsCanBeLookedUpFromCheckpointFile() throws IOException {
CheckpointFile checkpointFile = logFiles.getCheckpointFile();
var logPosition1 = new LogPosition(0, 10);
var logPosition2 = new LogPosition(0, 20);
var logPosition3 = new LogPosition(0, 30);
assertThat(checkpointFile.reachableCheckpoints()).hasSize(0);
checkpointAppender.checkPoint(LogCheckPointEvent.NULL, logPosition1, Instant.now(), "first");
checkpointAppender.checkPoint(LogCheckPointEvent.NULL, logPosition2, Instant.now(), "second");
checkpointAppender.checkPoint(LogCheckPointEvent.NULL, logPosition3, Instant.now(), "third");
var checkpoints = checkpointFile.reachableCheckpoints();
assertThat(checkpoints).hasSize(3);
assertThat(checkpoints.get(0)).hasFieldOrPropertyWithValue("transactionLogPosition", logPosition1);
assertThat(checkpoints.get(1)).hasFieldOrPropertyWithValue("transactionLogPosition", logPosition2);
assertThat(checkpoints.get(2)).hasFieldOrPropertyWithValue("transactionLogPosition", logPosition3);
}
Aggregations