* This method attempts to do its best to remove files from the filesystem that have been confirmed for deletion.
*/
private void deleteFiles(SortedSet<String> confirmedDeletes) {
// create a batchwriter to remove the delete flags for successful
// deletes; Need separate writer for the root tablet.
BatchWriter writer = null;
BatchWriter rootWriter = null;
if (!offline) {
Connector c;
try {
c = instance.getConnector(SecurityConstants.SYSTEM_PRINCIPAL, SecurityConstants.getSystemToken());
writer = c.createBatchWriter(Constants.METADATA_TABLE_NAME, new BatchWriterConfig());
rootWriter = c.createBatchWriter(Constants.METADATA_TABLE_NAME, new BatchWriterConfig());
} catch (Exception e) {
log.error("Unable to create writer to remove file from the !METADATA table", e);
}
}
// when deleting a dir and all files in that dir, only need to delete the dir
// the dir will sort right before the files... so remove the files in this case
// to minimize namenode ops
Iterator<String> cdIter = confirmedDeletes.iterator();
String lastDir = null;
while (cdIter.hasNext()) {
String delete = cdIter.next();
if (isDir(delete)) {
lastDir = delete;
} else if (lastDir != null) {
if (delete.startsWith(lastDir)) {
log.debug("Ignoring " + delete + " because " + lastDir + " exist");
try {
putMarkerDeleteMutation(delete, writer, rootWriter);
} catch (MutationsRejectedException e) {
throw new RuntimeException(e);
}
cdIter.remove();
} else {
lastDir = null;
}
}
}
final BatchWriter finalWriter = writer;
final BatchWriter finalRootWriter = rootWriter;
ExecutorService deleteThreadPool = Executors.newFixedThreadPool(numDeleteThreads, new NamingThreadFactory("deleting"));
for (final String delete : confirmedDeletes) {