We reuse journal files based on a reference counting algorithm, where we store positive values for every add/update, and negatives for deletes.
When sum(positives) - sum(negatives) = 0 to a file, that file could be deleted or reused on the circular journal.
Second Criteria: The file shouldn't also have any deletes for pending files. The file can't be gone before any depending file.
Look at the javadoc of org.jboss.messaging.core.journal.impl.Reclaimer for more information.