Search in sources :

Example 41 with LogPosition

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

the class TransactionMetadataCacheTest method shouldClearTheCache.

@Test
public void shouldClearTheCache() {
    // given
    final TransactionMetadataCache cache = new TransactionMetadataCache(2);
    final LogPosition position = new LogPosition(3, 4);
    final int txId = 42;
    final int masterId = 0;
    final int authorId = 1;
    final int checksum = 2;
    final long timestamp = System.currentTimeMillis();
    // when
    cache.cacheTransactionMetadata(txId, position, masterId, authorId, checksum, timestamp);
    cache.clear();
    final TransactionMetadataCache.TransactionMetadata metadata = cache.getTransactionMetadata(txId);
    // then
    assertNull(metadata);
}
Also used : TransactionMetadataCache(org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Test(org.junit.Test)

Example 42 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)

Aggregations

LogPosition (org.neo4j.kernel.impl.transaction.log.LogPosition)42 Test (org.junit.Test)26 File (java.io.File)11 PhysicalLogFile (org.neo4j.kernel.impl.transaction.log.PhysicalLogFile)9 PhysicalLogFiles (org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles)9 IOException (java.io.IOException)6 LogPositionMarker (org.neo4j.kernel.impl.transaction.log.LogPositionMarker)6 ReadableClosablePositionAwareChannel (org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel)5 TransactionMetadataCache (org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache)5 VersionAwareLogEntryReader (org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader)5 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)4 LogHeaderCache (org.neo4j.kernel.impl.transaction.log.LogHeaderCache)4 CheckPoint (org.neo4j.kernel.impl.transaction.log.entry.CheckPoint)4 LogEntry (org.neo4j.kernel.impl.transaction.log.entry.LogEntry)4 LogEntryWriter (org.neo4j.kernel.impl.transaction.log.entry.LogEntryWriter)4 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)4 LatestCheckPoint (org.neo4j.kernel.recovery.LatestCheckPointFinder.LatestCheckPoint)4 LogFile (org.neo4j.kernel.impl.transaction.log.LogFile)3 PhysicalLogicalTransactionStore (org.neo4j.kernel.impl.transaction.log.PhysicalLogicalTransactionStore)3 HashMap (java.util.HashMap)2