while (startSeqId <= tEndSeqId) {
correctedEndSeqId = Math.min(startSeqId + NUM_MESSAGES_TO_PRINT - 1, tEndSeqId);
try {
Enumeration<LedgerEntry> seq = lh.readEntries(startSeqId - ledger.startSeqIdIncluded, correctedEndSeqId - ledger.startSeqIdIncluded);
LedgerEntry entry = null;
while (seq.hasMoreElements()) {
entry = seq.nextElement();
Message message;
try {
message = Message.parseFrom(entry.getEntryInputStream());
} catch (IOException e) {
System.out.println("WARN: Unreadable message found\n");
expectedEntryId++;
continue;
}
if (expectedEntryId != entry.getEntryId()
|| (message.getMsgId().getLocalComponent() - ledger.startSeqIdIncluded) != expectedEntryId) {
throw new IOException("ERROR: Message ids are out of order : expected entry id " + expectedEntryId
+ ", current entry id " + entry.getEntryId() + ", msg seq id " + message.getMsgId().getLocalComponent());
}
expectedEntryId++;
formatMessage(message);
}