Search in sources :

Example 81 with LogPosition

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

the class StoreMigratorTest method writeAndReadLastTxLogPosition.

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

Example 82 with LogPosition

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

the class VersionAwareLogEntryReaderIT method correctlyResetPositionWhenEndOfCommandsReached.

@Test
void correctlyResetPositionWhenEndOfCommandsReached() throws IOException {
    LogFiles logFiles = LogFilesBuilder.builder(databaseLayout, fs).withLogEntryReader(entryReader).withLogVersionRepository(new SimpleLogVersionRepository()).withTransactionIdStore(new SimpleTransactionIdStore()).withStoreId(StoreId.UNKNOWN).build();
    try (Lifespan lifespan = new Lifespan(logFiles)) {
        LogPosition logPosition = entryReader.lastPosition();
        assertEquals(0L, logPosition.getLogVersion());
        // this position in a log file before 0's are actually starting
        assertEquals(END_OF_DATA_OFFSET, logPosition.getByteOffset());
        for (int i = 0; i < 10; i++) {
            assertEquals(END_OF_DATA_OFFSET, getLastReadablePosition(logFiles));
        }
    }
}
Also used : SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) Lifespan(org.neo4j.kernel.lifecycle.Lifespan) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) Test(org.junit.jupiter.api.Test)

Example 83 with LogPosition

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

the class VersionAwareLogEntryReaderIT method readOnlyLogFilesWhileCommandsAreAvailable.

@Test
@EnabledOnOs(OS.LINUX)
void readOnlyLogFilesWhileCommandsAreAvailable() throws IOException {
    LogFiles logFiles = LogFilesBuilder.builder(databaseLayout, fs).withLogEntryReader(entryReader).withLogVersionRepository(new SimpleLogVersionRepository()).withTransactionIdStore(new SimpleTransactionIdStore()).withStoreId(StoreId.UNKNOWN).build();
    try (Lifespan lifespan = new Lifespan(logFiles)) {
        assertEquals(kibiBytes(128), Files.size(logFiles.getLogFile().getHighestLogFile()));
        LogPosition logPosition = entryReader.lastPosition();
        assertEquals(0L, logPosition.getLogVersion());
        // this position in a log file before 0's are actually starting
        assertEquals(END_OF_DATA_OFFSET, logPosition.getByteOffset());
    }
}
Also used : SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) Lifespan(org.neo4j.kernel.lifecycle.Lifespan) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) EnabledOnOs(org.junit.jupiter.api.condition.EnabledOnOs) Test(org.junit.jupiter.api.Test)

Example 84 with LogPosition

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

the class VersionAwareLogEntryReaderIT method readTillTheEndOfNotPreallocatedFile.

@Test
@DisabledOnOs(OS.LINUX)
void readTillTheEndOfNotPreallocatedFile() throws IOException {
    LogFiles logFiles = LogFilesBuilder.builder(databaseLayout, fs).withLogEntryReader(entryReader).withLogVersionRepository(new SimpleLogVersionRepository()).withTransactionIdStore(new SimpleTransactionIdStore()).withStoreId(StoreId.UNKNOWN).build();
    try (Lifespan lifespan = new Lifespan(logFiles)) {
        LogPosition logPosition = entryReader.lastPosition();
        assertEquals(0L, logPosition.getLogVersion());
        assertEquals(Files.size(logFiles.getLogFile().getHighestLogFile()), logPosition.getByteOffset());
    }
}
Also used : SimpleTransactionIdStore(org.neo4j.kernel.impl.transaction.SimpleTransactionIdStore) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) SimpleLogVersionRepository(org.neo4j.kernel.impl.transaction.SimpleLogVersionRepository) Lifespan(org.neo4j.kernel.lifecycle.Lifespan) LogPosition(org.neo4j.kernel.impl.transaction.log.LogPosition) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Example 85 with LogPosition

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

the class DetachedCheckpointLogEntryParserTest method parseDetachedCheckpointRecord.

@Test
void parseDetachedCheckpointRecord() throws IOException {
    KernelVersion version = KernelVersion.V4_3_D4;
    var storeId = new StoreId(4, 5, 6, 7, 8);
    var channel = new InMemoryClosableChannel();
    int checkpointMillis = 3;
    String checkpointDescription = "checkpoint";
    byte[] bytes = Arrays.copyOf(checkpointDescription.getBytes(), 120);
    // For version confusion, please read LogEntryParserSetV4_3 comments
    var checkpoint = new LogEntryDetachedCheckpoint(version, new LogPosition(1, 2), checkpointMillis, storeId, checkpointDescription);
    channel.putLong(checkpoint.getLogPosition().getLogVersion()).putLong(checkpoint.getLogPosition().getByteOffset()).putLong(checkpointMillis).putLong(storeId.getCreationTime()).putLong(storeId.getRandomId()).putLong(storeId.getStoreVersion()).putLong(storeId.getUpgradeTime()).putLong(storeId.getUpgradeTxId()).putShort((short) checkpointDescription.getBytes().length).put(bytes, bytes.length);
    channel.putChecksum();
    var checkpointParser = LogEntryParserSets.parserSet(version).select(DETACHED_CHECK_POINT);
    LogEntry logEntry = checkpointParser.parse(version, channel, positionMarker, commandReader);
    assertEquals(checkpoint, logEntry);
}
Also used : KernelVersion(org.neo4j.kernel.KernelVersion) StoreId(org.neo4j.storageengine.api.StoreId) InMemoryClosableChannel(org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel) 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