AtomixLogStorageReader implements LogStorageReader { @Override public long readLastBlock(final DirectBuffer readBuffer) { final var firstIndex = reader.getFirstIndex(); var index = reader.getLastIndex(); do { reader.reset(index); if (!reader.hasNext()) { break; } final var indexed = reader.next(); if (indexed.type() == ZeebeEntry.class) { wrapEntryData(indexed.cast(), readBuffer); return reader.getNextIndex(); } index--; } while (index >= firstIndex); return LogStorage.OP_RESULT_NO_DATA; } AtomixLogStorageReader(
      final ZeebeIndexMapping zeebeIndexMapping, final RaftLogReader reader); @Override boolean isEmpty(); @Override long read(final DirectBuffer readBuffer, final long address); @Override long readLastBlock(final DirectBuffer readBuffer); @Override long lookUpApproximateAddress(final long position); @Override void close(); Optional<Indexed<ZeebeEntry>> findEntry(final long index);  }
@Test public void shouldReadLastZeebeEntry() { final var reader = storageRule.get().newReader(); final var expected = append(1, 4, allocateData(1)); storageRule .getRaftLog() .writer() .append(new ConfigurationEntry(1, System.currentTimeMillis(), Collections.emptyList())); final var address = reader.readLastBlock(buffer); assertThat(address).isEqualTo(expected.index() + 1); assertThat(buffer.getInt(0, BYTE_ORDER)).isEqualTo(1); }