code: @Override
    public void purgeLogsOlderThan(long minTxIdToKeep) throws IOException {
      checkEnv();
  
      Collection<EditLogLedgerMetadata> ledgers =
          metadataManager.listLedgers(false); // Don't list in-progress ledgers
  
      for (EditLogLedgerMetadata ledger : ledgers) {
        if (ledger.getFirstTxId() < minTxIdToKeep  &&
            ledger.getLastTxId() < minTxIdToKeep) {
          LOG.info("Purging edit log segment: " + ledger);
  
          // Try to delete the associated ZooKeeper metadata
          if (!metadataManager.deleteLedgerMetadata(ledger, -1)) {
            // It's possible that another process has already deleted the
            // metadata
            LOG.warn(ledger + " has already been purged!");
          } else {
            try {
              // Remove the ledger from BookKeeper itself to reclaim diskspace.
              bookKeeperClient.deleteLedger(ledger.getLedgerId());
            } catch (BKException e) {
              bkException("Unrecoverable error deleting " + ledger +
                  " from BookKeeper", e);
            } catch (InterruptedException e) {
              interruptedException("Interrupted deleting " + ledger +
                  " from BookKeeper", e);
            }
          }
        }
      }
    }
docs: For edit log segment that contains transactions with ids earlier than the
  earliest txid to be retained, remove the ZooKeeper-based metadata and
  BookKeeper ledgers associated with these segments.
  
  @param minTxIdToKeep the earliest txid that must be retained after purging
  old logs
  @throws IOException If there is an error talking to BookKeeper or
  ZooKeeper