Search in sources :

Example 1 with IdentifiableLogEntry

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

the class LogEntrySortingCursor method perhapsFetchEntriesFromChannel.

private void perhapsFetchEntriesFromChannel() throws IOException {
    if (idToFetchFrom > 0) {
        // we still have entry to return from the map...
        return;
    }
    LogEntry entry;
    while ((entry = reader.readLogEntry(channel)) != null) {
        if (!(entry instanceof IdentifiableLogEntry)) {
            throw new IllegalStateException("reading from a log which is not a legacy one???");
        }
        final IdentifiableLogEntry identifiableLogEntry = (IdentifiableLogEntry) entry;
        final int identifier = identifiableLogEntry.getIdentifier();
        final LogEntry inner = identifiableLogEntry.getEntry();
        List<LogEntry> list = provideList(idToEntries, identifier);
        list.add(inner);
        if (inner instanceof LogEntryCommit) {
            idToFetchFrom = identifier;
            break;
        }
    }
}
Also used : LogEntryCommit(org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommit) IdentifiableLogEntry(org.neo4j.kernel.impl.transaction.log.entry.IdentifiableLogEntry) LogEntry(org.neo4j.kernel.impl.transaction.log.entry.LogEntry) IdentifiableLogEntry(org.neo4j.kernel.impl.transaction.log.entry.IdentifiableLogEntry)

Example 2 with IdentifiableLogEntry

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

the class LegacyLogEntryReaderTest method shouldReadTheEntries.

@Test
public void shouldReadTheEntries() throws IOException {
    // given
    final LogEntry start = new LogEntryStart(0, 1, 2, 3, EMPTY_ADDITIONAL_ARRAY, UNSPECIFIED);
    NodeRecord record = new NodeRecord(42);
    final LogEntry command = new LogEntryCommand(new Command.NodeCommand(record, record));
    final LogEntry commit = new OnePhaseCommit(42, 43);
    final LogEntryReader<ReadableLogChannel> logEntryReader = mock(LogEntryReader.class);
    when(logEntryReader.readLogEntry(any(ReadableLogChannel.class))).thenReturn(new IdentifiableLogEntry(start, 1), new IdentifiableLogEntry(command, 1), new IdentifiableLogEntry(commit, 1), null);
    final LegacyLogEntryReader reader = new LegacyLogEntryReader(fs, from -> logEntryReader);
    // when
    final IOCursor<LogEntry> cursor = reader.openReadableChannel(input).other();
    // then
    assertTrue(cursor.next());
    assertEquals(start, cursor.get());
    assertTrue(cursor.next());
    assertEquals(command, cursor.get());
    assertTrue(cursor.next());
    assertEquals(commit, cursor.get());
    assertFalse(cursor.next());
    cursor.close();
}
Also used : LogEntryStart(org.neo4j.kernel.impl.transaction.log.entry.LogEntryStart) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) ReadableLogChannel(org.neo4j.kernel.impl.transaction.log.ReadableLogChannel) LogEntryCommand(org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommand) Command(org.neo4j.kernel.impl.transaction.command.Command) LogEntryCommand(org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommand) OnePhaseCommit(org.neo4j.kernel.impl.transaction.log.entry.OnePhaseCommit) IdentifiableLogEntry(org.neo4j.kernel.impl.transaction.log.entry.IdentifiableLogEntry) LogEntry(org.neo4j.kernel.impl.transaction.log.entry.LogEntry) IdentifiableLogEntry(org.neo4j.kernel.impl.transaction.log.entry.IdentifiableLogEntry) Test(org.junit.Test)

Aggregations

IdentifiableLogEntry (org.neo4j.kernel.impl.transaction.log.entry.IdentifiableLogEntry)2 LogEntry (org.neo4j.kernel.impl.transaction.log.entry.LogEntry)2 Test (org.junit.Test)1 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)1 Command (org.neo4j.kernel.impl.transaction.command.Command)1 ReadableLogChannel (org.neo4j.kernel.impl.transaction.log.ReadableLogChannel)1 LogEntryCommand (org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommand)1 LogEntryCommit (org.neo4j.kernel.impl.transaction.log.entry.LogEntryCommit)1 LogEntryStart (org.neo4j.kernel.impl.transaction.log.entry.LogEntryStart)1 OnePhaseCommit (org.neo4j.kernel.impl.transaction.log.entry.OnePhaseCommit)1