@Test public void testOriginalCmdForm() throws Exception { String[] cliArgs = {"in_dir", "false"}; expect(cli.hasOption("t")).andReturn(false).once(); expect(shellState.getTableName()).andReturn("tablename").once(); expect(cli.getArgs()).andReturn(cliArgs).atLeastOnce(); expect(shellState.getAccumuloClient()).andReturn(client).atLeastOnce(); expect(client.tableOperations()).andReturn(tableOperations); shellState.checkTableState(); expectLastCall().once(); expect(tableOperations.importDirectory("in_dir")).andReturn(bulkImport).once(); expect(bulkImport.to("tablename")).andReturn(bulkImport).once(); expect(bulkImport.tableTime(false)).andReturn(bulkImport).once(); bulkImport.load(); expectLastCall().once(); replay(client, cli, shellState, tableOperations, bulkImport); cmd.execute("importdirectory in_dir false", cli, shellState); }
@SuppressWarnings("deprecation") @Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException, AccumuloException, AccumuloSecurityException, TableNotFoundException { final String tableName = OptUtil.getTableOpt(cl, shellState); String[] args = cl.getArgs(); boolean setTime; String dir = args.length > 0 ? args[0] : ""; int status = 0; switch (args.length) { case 2: { setTime = Boolean.parseBoolean(cl.getArgs()[1]); shellState.getAccumuloClient().tableOperations().importDirectory(dir).to(tableName) .tableTime(setTime).load(); break; } case 3: { Shell.log.warn( "Deprecated since 2.0.0. New bulk import technique does not take a failure directory " + "as an argument."); String failureDir = args[1]; setTime = Boolean.parseBoolean(cl.getArgs()[2]); shellState.getAccumuloClient().tableOperations().importDirectory(tableName, dir, failureDir, setTime); break; } default: { shellState.printException( new IllegalArgumentException(String.format("Expected 2 or 3 arguments. There %s %d.", args.length == 1 ? "was" : "were", args.length))); printHelp(shellState); status = 1; break; } } return status; }
ImportDirectoryCommand extends Command { @SuppressWarnings("deprecation") @Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException, AccumuloException, AccumuloSecurityException, TableNotFoundException { final String tableName = OptUtil.getTableOpt(cl, shellState); String[] args = cl.getArgs(); boolean setTime; String dir = args.length > 0 ? args[0] : ""; int status = 0; switch (args.length) { case 2: { setTime = Boolean.parseBoolean(cl.getArgs()[1]); shellState.getAccumuloClient().tableOperations().importDirectory(dir).to(tableName) .tableTime(setTime).load(); break; } case 3: { Shell.log.warn( "Deprecated since 2.0.0. New bulk import technique does not take a failure directory " + "as an argument."); String failureDir = args[1]; setTime = Boolean.parseBoolean(cl.getArgs()[2]); shellState.getAccumuloClient().tableOperations().importDirectory(tableName, dir, failureDir, setTime); break; } default: { shellState.printException( new IllegalArgumentException(String.format("Expected 2 or 3 arguments. There %s %d.", args.length == 1 ? "was" : "were", args.length))); printHelp(shellState); status = 1; break; } } return status; } }
ImportDirectoryCommand extends Command { @SuppressWarnings("deprecation") @Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException, AccumuloException, AccumuloSecurityException, TableNotFoundException { final String tableName = OptUtil.getTableOpt(cl, shellState); String[] args = cl.getArgs(); boolean setTime; String dir = args.length > 0 ? args[0] : ""; int status = 0; switch (args.length) { case 2: { setTime = Boolean.parseBoolean(cl.getArgs()[1]); shellState.getAccumuloClient().tableOperations().importDirectory(dir).to(tableName) .tableTime(setTime).load(); break; } case 3: { Shell.log.warn( "Deprecated since 2.0.0. New bulk import technique does not take a failure directory " + "as an argument."); String failureDir = args[1]; setTime = Boolean.parseBoolean(cl.getArgs()[2]); shellState.getAccumuloClient().tableOperations().importDirectory(tableName, dir, failureDir, setTime); break; } default: { shellState.printException( new IllegalArgumentException(String.format("Expected 2 or 3 arguments. There %s %d.", args.length == 1 ? "was" : "were", args.length))); printHelp(shellState); status = 1; break; } } return status; }  }
ImportDirectoryCommand extends Command { @SuppressWarnings("deprecation") @Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException, AccumuloException, AccumuloSecurityException, TableNotFoundException { final String tableName = OptUtil.getTableOpt(cl, shellState); String[] args = cl.getArgs(); boolean setTime; String dir = args.length > 0 ? args[0] : ""; int status = 0; switch (args.length) { case 2: { setTime = Boolean.parseBoolean(cl.getArgs()[1]); shellState.getAccumuloClient().tableOperations().importDirectory(dir).to(tableName) .tableTime(setTime).load(); break; } case 3: { Shell.log.warn( "Deprecated since 2.0.0. New bulk import technique does not take a failure directory " + "as an argument."); String failureDir = args[1]; setTime = Boolean.parseBoolean(cl.getArgs()[2]); shellState.getAccumuloClient().tableOperations().importDirectory(tableName, dir, failureDir, setTime); break; } default: { shellState.printException( new IllegalArgumentException(String.format("Expected 2 or 3 arguments. There %s %d.", args.length == 1 ? "was" : "were", args.length))); printHelp(shellState); status = 1; break; } } return status; }  @Override String description(); @SuppressWarnings("deprecation") @Override int execute(final String fullCommand, final CommandLine cl, final Shell shellState); @Override int numArgs(); @Override String usage(); @Override Options getOptions(); @Override void registerCompletion(final Token root,
      final Map<CompletionSet,Set<String>> completionSet); }
ImportDirectoryCommand extends Command { @SuppressWarnings("deprecation") @Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException, AccumuloException, AccumuloSecurityException, TableNotFoundException { final String tableName = OptUtil.getTableOpt(cl, shellState); String[] args = cl.getArgs(); boolean setTime; String dir = args.length > 0 ? args[0] : ""; int status = 0; switch (args.length) { case 2: { setTime = Boolean.parseBoolean(cl.getArgs()[1]); shellState.getAccumuloClient().tableOperations().importDirectory(dir).to(tableName) .tableTime(setTime).load(); break; } case 3: { Shell.log.warn( "Deprecated since 2.0.0. New bulk import technique does not take a failure directory " + "as an argument."); String failureDir = args[1]; setTime = Boolean.parseBoolean(cl.getArgs()[2]); shellState.getAccumuloClient().tableOperations().importDirectory(tableName, dir, failureDir, setTime); break; } default: { shellState.printException( new IllegalArgumentException(String.format("Expected 2 or 3 arguments. There %s %d.", args.length == 1 ? "was" : "were", args.length))); printHelp(shellState); status = 1; break; } } return status; }  @Override String description(); @SuppressWarnings("deprecation") @Override int execute(final String fullCommand, final CommandLine cl, final Shell shellState); @Override int numArgs(); @Override String usage(); @Override Options getOptions(); @Override void registerCompletion(final Token root,
      final Map<CompletionSet,Set<String>> completionSet);  }