* This method removes candidates from the candidate list under two conditions: 1. They are in the same folder as a bulk processing file, if that option is
* selected 2. They are still in use in the file column family in the METADATA table
*/
public void confirmDeletes(SortedSet<String> candidates) throws AccumuloException {
Scanner scanner;
if (offline) {
try {
scanner = new OfflineMetadataScanner(instance.getConfiguration(), fs);
} catch (IOException e) {
throw new IllegalStateException("Unable to create offline metadata scanner", e);
}
} else {
try {
scanner = new IsolatedScanner(instance.getConnector(credentials.getPrincipal(), CredentialHelper.extractToken(credentials)).createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS));
} catch (AccumuloSecurityException ex) {
throw new AccumuloException(ex);
} catch (TableNotFoundException ex) {
throw new AccumuloException(ex);
}
}
// skip candidates that are in a bulk processing folder
if (checkForBulkProcessingFiles) {
log.debug("Checking for bulk processing flags");
scanner.setRange(Constants.METADATA_BLIP_KEYSPACE);
// WARNING: This block is IMPORTANT
// You MUST REMOVE candidates that are in the same folder as a bulk
// processing flag!
for (Entry<Key,Value> entry : scanner) {
String blipPath = entry.getKey().getRow().toString().substring(Constants.METADATA_BLIP_FLAG_PREFIX.length());
validateDir(blipPath);
Iterator<String> tailIter = candidates.tailSet(blipPath).iterator();
int count = 0;
while (tailIter.hasNext()) {
if (tailIter.next().startsWith(blipPath)) {
count++;
tailIter.remove();
} else {
break;
}
}
if (count > 0)
log.debug("Folder has bulk processing flag: " + blipPath);
}
}
// skip candidates that are still in use in the file column family in
// the metadata table
scanner.clearColumns();
scanner.fetchColumnFamily(Constants.METADATA_DATAFILE_COLUMN_FAMILY);
scanner.fetchColumnFamily(Constants.METADATA_SCANFILE_COLUMN_FAMILY);
Constants.METADATA_DIRECTORY_COLUMN.fetch(scanner);
TabletIterator tabletIterator = new TabletIterator(scanner, Constants.METADATA_KEYSPACE, false, true);
while (tabletIterator.hasNext()) {