Search in sources :

Example 21 with LatestCheckPoint

use of org.neo4j.kernel.recovery.LatestCheckPointFinder.LatestCheckPoint in project neo4j by neo4j.

the class LatestCheckPointFinderTest method olderLogFileContainingAStartAndNewerFileContainingACheckPointPointingToAPreviousPositionThanStart.

@Test
public void olderLogFileContainingAStartAndNewerFileContainingACheckPointPointingToAPreviousPositionThanStart() throws Throwable {
    // given
    long txId = 123;
    StartEntry start = start();
    setupLogFiles(logFile(start, commit(txId)), logFile(checkPoint(start)));
    // when
    LatestCheckPoint latestCheckPoint = finder.find(endLogVersion);
    // then
    assertLatestCheckPoint(true, true, txId, endLogVersion, latestCheckPoint);
}
Also used : LatestCheckPoint(org.neo4j.kernel.recovery.LatestCheckPointFinder.LatestCheckPoint) Test(org.junit.Test)

Example 22 with LatestCheckPoint

use of org.neo4j.kernel.recovery.LatestCheckPointFinder.LatestCheckPoint in project neo4j by neo4j.

the class PositionToRecoverFromTest method shouldReturnUnspecifiedIfThereIsNoNeedForRecovery.

@Test
public void shouldReturnUnspecifiedIfThereIsNoNeedForRecovery() throws Throwable {
    // given
    when(finder.find(logVersion)).thenReturn(new LatestCheckPoint(null, false, NO_TRANSACTION_ID, logVersion));
    // when
    LogPosition logPosition = new PositionToRecoverFrom(finder, monitor).apply(logVersion);
    // then
    verify(monitor).noCommitsAfterLastCheckPoint(null);
    assertEquals(LogPosition.UNSPECIFIED, logPosition);
}
Also used : LatestCheckPoint(org.neo4j.kernel.recovery.LatestCheckPointFinder.LatestCheckPoint) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Test(org.junit.Test)

Example 23 with LatestCheckPoint

use of org.neo4j.kernel.recovery.LatestCheckPointFinder.LatestCheckPoint 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 24 with LatestCheckPoint

use of org.neo4j.kernel.recovery.LatestCheckPointFinder.LatestCheckPoint in project neo4j by neo4j.

the class PositionToRecoverFromTest method shouldFailIfThereAreNoCheckPointsAndOldestLogVersionInNotZero.

@Test
public void shouldFailIfThereAreNoCheckPointsAndOldestLogVersionInNotZero() throws Throwable {
    // given
    long oldestLogVersionFound = 1L;
    when(finder.find(logVersion)).thenReturn(new LatestCheckPoint(null, true, 10L, oldestLogVersionFound));
    // when
    try {
        new PositionToRecoverFrom(finder, monitor).apply(logVersion);
    } catch (UnderlyingStorageException ex) {
        // then
        final String expectedMessage = "No check point found in any log file from version " + oldestLogVersionFound + " to " + logVersion;
        assertEquals(expectedMessage, ex.getMessage());
    }
}
Also used : LatestCheckPoint(org.neo4j.kernel.recovery.LatestCheckPointFinder.LatestCheckPoint) UnderlyingStorageException(org.neo4j.kernel.impl.store.UnderlyingStorageException) Test(org.junit.Test)

Example 25 with LatestCheckPoint

use of org.neo4j.kernel.recovery.LatestCheckPointFinder.LatestCheckPoint 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)

Aggregations

LatestCheckPoint (org.neo4j.kernel.recovery.LatestCheckPointFinder.LatestCheckPoint)25 Test (org.junit.Test)24 LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)3 IOException (java.io.IOException)1 UnderlyingStorageException (org.neo4j.kernel.impl.store.UnderlyingStorageException)1 Result (org.neo4j.kernel.impl.storemigration.StoreVersionCheck.Result)1 PhysicalLogFiles (org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles)1 ReadableClosablePositionAwareChannel (org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel)1 CheckPoint (org.neo4j.kernel.impl.transaction.log.entry.CheckPoint)1 VersionAwareLogEntryReader (org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader)1 LatestCheckPointFinder (org.neo4j.kernel.recovery.LatestCheckPointFinder)1