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);
}
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));
}
}
}
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());
}
}
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());
}
}
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);
}
Aggregations