* A utility to add files to the {@value MetadataTable#NAME} table that are not listed in the root tablet. This is a recovery tool for someone who knows what
* they are doing. It might be better to save off files, and recover your instance by re-initializing and importing the existing files.
*/
public static void main(String[] args) throws Exception {
Opts opts = new Opts();
BatchWriterOpts bwOpts = new BatchWriterOpts();
opts.parseArgs(AddFilesWithMissingEntries.class.getName(), args, bwOpts);
final Scanner scanner = opts.getConnector().createScanner(MetadataTable.NAME, Authorizations.EMPTY);
scanner.setRange(MetadataSchema.TabletsSection.getRange());
final Configuration conf = new Configuration();
final FileSystem fs = FileSystem.get(conf);
KeyExtent last = new KeyExtent();
String directory = null;
Set<String> knownFiles = new HashSet<String>();
int count = 0;
final MultiTableBatchWriter writer = opts.getConnector().createMultiTableBatchWriter(bwOpts.getBatchWriterConfig());
// collect the list of known files and the directory for each extent
for (Entry<Key,Value> entry : scanner) {
Key key = entry.getKey();
KeyExtent ke = new KeyExtent(key.getRow(), (Text) null);