code: private void updateMaxLedgerEntryIdSeen() throws IOException {
      long lcFromMetadata = ledger.getLastAddConfirmed();
      long lcFromQuorum;
      try {
        lcFromQuorum = ledger.readLastConfirmed();
      } catch (BKException e) {
        bkException("Unable to read last confirmed ledger entry id "
            + "from ledger " + ledger.getId(), e);
        return;
      } catch (InterruptedException e) {
        interruptedException("Interrupted reading last confirmed ledger " +
            "entry id from ledger " + ledger.getId(), e);
        return;
      }
      long newMaxLedgerEntryIdSeen = Math.max(lcFromMetadata, lcFromQuorum);
      if (newMaxLedgerEntryIdSeen > maxLedgerEntryIdSeen) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Resetting maxLedgerEntryIdSeen from " + maxLedgerEntryIdSeen +
              " to " + newMaxLedgerEntryIdSeen);
        }
        maxLedgerEntryIdSeen = newMaxLedgerEntryIdSeen;
      }
    }
docs: Set <code>maxLedgerEntryIdSeen</code> to the maximum of last confirmed
  entry-id from a quorum of bookies and last confirmed entry-id from
  metadata stored in ZooKeeper. The reason is to handle the case of
  when a ledger becomes finalized mid-flight: in this case last confirmed
  entry-id that is read from a quorum is no longer reliable, but a reliable
  last-confirmed entry-id is now available in ZooKeeper metadata which is
  updated when a ledger is finalized.
  @throws IOException If there's an error talking to BookKeeper
  or ZooKeeper