Search in sources :

Example 71 with LogPosition

use of org.neo4j.kernel.impl.transaction.log.LogPosition in project neo4j by neo4j.

the class PositionToRecoverFromTest method shouldRecoverFromStartOfLogZeroIfThereAreNoCheckPointAndOldestLogIsVersionZero.

@Test
public void shouldRecoverFromStartOfLogZeroIfThereAreNoCheckPointAndOldestLogIsVersionZero() throws Throwable {
    // given
    when(finder.find(logVersion)).thenReturn(new LatestCheckPoint(null, true, 10L, INITIAL_LOG_VERSION));
    // when
    LogPosition logPosition = new PositionToRecoverFrom(finder, monitor).apply(logVersion);
    // then
    verify(monitor).noCheckPointFound();
    assertEquals(LogPosition.start(INITIAL_LOG_VERSION), logPosition);
}
Also used : LatestCheckPoint(org.neo4j.kernel.recovery.LatestCheckPointFinder.LatestCheckPoint) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Test(org.junit.Test)

Example 72 with LogPosition

use of org.neo4j.kernel.impl.transaction.log.LogPosition in project neo4j by neo4j.

the class PositionToRecoverFromTest method shouldReturnLogPositionToRecoverFromIfNeeded.

@Test
public void shouldReturnLogPositionToRecoverFromIfNeeded() throws Throwable {
    // given
    LogPosition checkPointLogPosition = new LogPosition(1L, 4242);
    when(finder.find(logVersion)).thenReturn(new LatestCheckPoint(new CheckPoint(checkPointLogPosition), true, 10L, logVersion));
    // when
    LogPosition logPosition = new PositionToRecoverFrom(finder, monitor).apply(logVersion);
    // then
    verify(monitor).commitsAfterLastCheckPoint(checkPointLogPosition, 10L);
    assertEquals(checkPointLogPosition, logPosition);
}
Also used : LatestCheckPoint(org.neo4j.kernel.recovery.LatestCheckPointFinder.LatestCheckPoint) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) CheckPoint(org.neo4j.kernel.impl.transaction.log.entry.CheckPoint) LatestCheckPoint(org.neo4j.kernel.recovery.LatestCheckPointFinder.LatestCheckPoint) Test(org.junit.Test)

Example 73 with LogPosition

use of org.neo4j.kernel.impl.transaction.log.LogPosition in project neo4j by neo4j.

the class StoreMigratorTest method writeAndReadLastTxLogPosition.

@Test
public void writeAndReadLastTxLogPosition() throws IOException {
    StoreMigrator migrator = newStoreMigrator();
    LogPosition writtenLogPosition = new LogPosition(random.nextLong(), random.nextLong());
    migrator.writeLastTxLogPosition(directory.graphDbDir(), writtenLogPosition);
    LogPosition readLogPosition = migrator.readLastTxLogPosition(directory.graphDbDir());
    assertEquals(writtenLogPosition, readLogPosition);
}
Also used : LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Test(org.junit.Test)

Example 74 with LogPosition

use of org.neo4j.kernel.impl.transaction.log.LogPosition in project neo4j by neo4j.

the class MigrationTestUtils method removeCheckPointFromTxLog.

public static void removeCheckPointFromTxLog(FileSystemAbstraction fileSystem, File workingDirectory) throws IOException {
    PhysicalLogFiles logFiles = new PhysicalLogFiles(workingDirectory, fileSystem);
    LogEntryReader<ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader<>();
    LatestCheckPointFinder finder = new LatestCheckPointFinder(logFiles, fileSystem, logEntryReader);
    LatestCheckPointFinder.LatestCheckPoint latestCheckPoint = finder.find(logFiles.getHighestLogVersion());
    if (latestCheckPoint.commitsAfterCheckPoint) {
        // done already
        return;
    }
    // let's assume there is at least a checkpoint
    assertNotNull(latestCheckPoint.checkPoint);
    LogPosition logPosition = latestCheckPoint.checkPoint.getLogPosition();
    File logFile = logFiles.getLogFileForVersion(logPosition.getLogVersion());
    fileSystem.truncate(logFile, logPosition.getByteOffset());
}
Also used : LatestCheckPointFinder(org.neo4j.kernel.recovery.LatestCheckPointFinder) VersionAwareLogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader) File(java.io.File) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) ReadableClosablePositionAwareChannel(org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition)

Example 75 with LogPosition

use of org.neo4j.kernel.impl.transaction.log.LogPosition in project neo4j by neo4j.

the class LogPositionMarkerTest method shouldReturnUnspecifiedIfNothingHasBeenMarked.

@Test
void shouldReturnUnspecifiedIfNothingHasBeenMarked() {
    // given
    final LogPositionMarker marker = new LogPositionMarker();
    // when
    final LogPosition logPosition = marker.newPosition();
    // given
    assertEquals(LogPosition.UNSPECIFIED, logPosition);
}
Also used : LogPositionMarker(org.neo4j.kernel.impl.transaction.log.LogPositionMarker) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Test(org.junit.jupiter.api.Test)

Aggregations

LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)115 Test (org.junit.jupiter.api.Test)50 File (java.io.File)16 Test (org.junit.Test)16 LogFile (org.neo4j.kernel.impl.transaction.log.files.LogFile)15 Path (java.nio.file.Path)14 IOException (java.io.IOException)11 LogPositionMarker (org.neo4j.kernel.impl.transaction.log.LogPositionMarker)10 LogFiles (org.neo4j.kernel.impl.transaction.log.files.LogFiles)10 CheckpointFile (org.neo4j.kernel.impl.transaction.log.files.checkpoint.CheckpointFile)10 StoreId (org.neo4j.storageengine.api.StoreId)10 PhysicalLogFiles (org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles)9 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)8 PhysicalLogFile (org.neo4j.kernel.impl.transaction.log.PhysicalLogFile)8 LogEntryWriter (org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter)8 VersionAwareLogEntryReader (org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader)8 LogTailInformation (org.neo4j.kernel.impl.transaction.log.files.LogTailInformation)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 CommittedTransactionRepresentation (org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation)7 LogEntry (org.neo4j.kernel.impl.transaction.log.entry.LogEntry)7