public GetEntriesResult getEntriesFrom(@Nonnegative long beginningIndex, @Nonnegative int max) {
checkArgument(beginningIndex >= 0);
long previousIndex = beginningIndex - 1;
Entry previous = previousIndex <= 0 ? SENTINEL : journal.get(log.get(previousIndex));
Iterable<Entry> entries = FluentIterable
.from(log.tailMap(beginningIndex).values())
.limit(max)
.transform(new Function<RaftJournal.Mark, Entry>() {
@Nullable
@Override
public Entry apply(@Nullable RaftJournal.Mark input) {
return journal.get(input);
}
});
return new GetEntriesResult(previous.getTerm(), previousIndex, entries);
}