public void purgeUnusedTempPartitions(TxLog txLog) throws JournalException { final Tx tx = new Tx(); final String lagPartitionName = hasIrregularPartition() ? getIrregularPartition().getName() : null; File[] files = getLocation() .listFiles( new FileFilter() { public boolean accept(File f) { return f.isDirectory() && f.getName().startsWith(Constants.TEMP_DIRECTORY_PREFIX) && (lagPartitionName == null || !lagPartitionName.equals(f.getName())); } }); if (files != null) { Arrays.sort(files); for (int i = 0; i < files.length; i++) { if (!txLog.isEmpty()) { txLog.head(tx); if (files[i].getName().equals(tx.lagName)) { continue; } } // get exclusive lock Lock lock = LockManager.lockExclusive(files[i]); try { if (lock != null && lock.isValid()) { LOGGER.trace("Purging : %s", files[i]); if (!Files.delete(files[i])) { LOGGER.info("Could not purge: %s", files[i]); } } else { LOGGER.trace("Partition in use: %s", files[i]); } } finally { LockManager.release(lock); } } } }