}
} 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()) {
Map<Key,Value> tabletKeyValues = tabletIterator.next();
for (Entry<Key,Value> entry : tabletKeyValues.entrySet()) {
if (entry.getKey().getColumnFamily().equals(Constants.METADATA_DATAFILE_COLUMN_FAMILY)
|| entry.getKey().getColumnFamily().equals(Constants.METADATA_SCANFILE_COLUMN_FAMILY)) {
String cf = entry.getKey().getColumnQualifier().toString();
String delete;
if (cf.startsWith("../")) {
delete = cf.substring(2);
} else {
String table = new String(KeyExtent.tableOfMetadataRow(entry.getKey().getRow()), Constants.UTF8);
delete = "/" + table + cf;
}
// WARNING: This line is EXTREMELY IMPORTANT.
// You MUST REMOVE candidates that are still in use
validateFile(delete);
if (candidates.remove(delete))
log.debug("Candidate was still in use in the METADATA table: " + delete);
String path = delete.substring(0, delete.lastIndexOf('/'));
validateDir(path);
if (candidates.remove(path))
log.debug("Candidate was still in use in the METADATA table: " + path);
} else if (Constants.METADATA_DIRECTORY_COLUMN.hasColumns(entry.getKey())) {
String table = new String(KeyExtent.tableOfMetadataRow(entry.getKey().getRow()), Constants.UTF8);
String delete = "/" + table + entry.getValue().toString();
validateDir(delete);
if (candidates.remove(delete))
log.debug("Candidate was still in use in the METADATA table: " + delete);
} else
throw new AccumuloException("Scanner over metadata table returned unexpected column : " + entry.getKey());
}
}
}