@Override
public List<ReplicatedLogEntry> getFrom(long logEntryIndex) {
+ return getFrom(logEntryIndex, journal.size());
+ }
+
+ @Override
+ public List<ReplicatedLogEntry> getFrom(long logEntryIndex, int max) {
int adjustedIndex = adjustedIndex(logEntryIndex);
int size = journal.size();
List<ReplicatedLogEntry> entries = new ArrayList<>(100);
if (adjustedIndex >= 0 && adjustedIndex < size) {
// physical index should be less than list size and >= 0
- entries.addAll(journal.subList(adjustedIndex, size));
+ int maxIndex = adjustedIndex + max;
+ if(maxIndex > size){
+ maxIndex = size;
+ }
+ entries.addAll(journal.subList(adjustedIndex, maxIndex));
}
return entries;
}
+
@Override
public long size() {
return journal.size();