use of org.neo4j.kernel.impl.transaction.log.entry.LogHeader in project neo4j by neo4j.
the class TransactionLogFileInformationTest method shouldReadAndCacheFirstCommittedTransactionIdForAGivenVersionWhenNotCached.
@Test
void shouldReadAndCacheFirstCommittedTransactionIdForAGivenVersionWhenNotCached() throws Exception {
TransactionLogFileInformation info = new TransactionLogFileInformation(logFiles, logHeaderCache, context);
long expected = 5;
long version = 10L;
when(logHeaderCache.getLogHeader(version)).thenReturn(null);
when(logFiles.getLogFile().versionExists(version)).thenReturn(true);
LogHeader expectedHeader = new LogHeader((byte) -1, /*ignored*/
-1L, /*ignored*/
expected - 1L, CURRENT_FORMAT_LOG_HEADER_SIZE);
when(logFiles.getLogFile().extractHeader(version)).thenReturn(expectedHeader);
long firstCommittedTxId = info.getFirstEntryId(version);
assertEquals(expected, firstCommittedTxId);
verify(logHeaderCache).putHeader(version, expectedHeader);
}
use of org.neo4j.kernel.impl.transaction.log.entry.LogHeader in project neo4j by neo4j.
the class TransactionLogFileInformationTest method doNotReadAgainPreviouslyObservedLogTransactionTime.
@Test
void doNotReadAgainPreviouslyObservedLogTransactionTime() throws IOException {
var logEntryReader = mock(LogEntryReader.class);
var readableLogChannel = mock(ReadableLogChannel.class);
when(logEntryReader.readLogEntry(readableLogChannel)).thenReturn(new LogEntryStart(1, 1, 1, new byte[] {}, LogPosition.UNSPECIFIED));
when(context.getLogEntryReader()).thenReturn(logEntryReader);
var fileInfo = new TransactionLogFileInformation(logFiles, logHeaderCache, context);
var expectedHeader = new LogHeader((byte) 1, 2, 3, 4);
when(logFile.extractHeader(anyLong())).thenReturn(expectedHeader);
when(logFile.getRawReader(any())).thenReturn(readableLogChannel);
fileInfo.getFirstStartRecordTimestamp(1);
fileInfo.getFirstStartRecordTimestamp(1);
fileInfo.getFirstStartRecordTimestamp(1);
fileInfo.getFirstStartRecordTimestamp(1);
fileInfo.getFirstStartRecordTimestamp(1);
verify(logFile, times(1)).getRawReader(any());
}
use of org.neo4j.kernel.impl.transaction.log.entry.LogHeader in project neo4j by neo4j.
the class LogHeaderCacheTest method shouldReturnTheHeaderIfInTheCache.
@Test
void shouldReturnTheHeaderIfInTheCache() {
// given
final LogHeaderCache cache = new LogHeaderCache(2);
// when
cache.putHeader(5, new LogHeader(1, 3, StoreId.UNKNOWN));
final LogHeader logHeader = cache.getLogHeader(5);
// then
assertEquals(3, logHeader.getLastCommittedTxId());
}
use of org.neo4j.kernel.impl.transaction.log.entry.LogHeader in project neo4j by neo4j.
the class LogHeaderCacheTest method shouldReturnNullWhenThereIsNoHeaderInTheCache.
@Test
void shouldReturnNullWhenThereIsNoHeaderInTheCache() {
// given
final LogHeaderCache cache = new LogHeaderCache(2);
// when
final LogHeader logHeader = cache.getLogHeader(5);
// then
assertNull(logHeader);
}
use of org.neo4j.kernel.impl.transaction.log.entry.LogHeader in project neo4j by neo4j.
the class TransactionRangeDiagnostics method dumpTransactionLogInformation.
private void dumpTransactionLogInformation(DiagnosticsLogger logger, LogFile logFile) throws IOException {
logger.log("Transaction log files:");
logger.log(" - existing transaction log versions " + logFile.getLowestLogVersion() + "-" + logFile.getHighestLogVersion());
for (long logVersion = logFile.getLowestLogVersion(); logFile.versionExists(logVersion); logVersion++) {
if (logFile.hasAnyEntries(logVersion)) {
LogHeader header = logFile.extractHeader(logVersion);
long firstTransactionIdInThisLog = header.getLastCommittedTxId() + 1;
logger.log(" - oldest transaction " + firstTransactionIdInThisLog + " found in log with version " + logVersion);
return;
}
}
logger.log(" - no transactions found");
}
Aggregations