This is an automated email from the ASF dual-hosted git repository.

edcoleman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit d2803b5cdf024c78ddde9e899ff7470f0f44d03d
Merge: 6ae7ddb 2d0091d
Author: Ed Coleman <d...@etcoleman.com>
AuthorDate: Thu Aug 15 16:01:35 2019 -0400

    Merge branch '1.9' into 2.0

 .../shell/commands/ImportDirectoryCommand.java     |  26 +++--
 .../shell/commands/ImportDirectoryCommandTest.java | 130 +++++++++++++++++++++
 .../org/apache/accumulo/test/ShellServerIT.java    |  62 ++++++++++
 3 files changed, 210 insertions(+), 8 deletions(-)

diff --cc 
shell/src/main/java/org/apache/accumulo/shell/commands/ImportDirectoryCommand.java
index cbee631,dc92293..ac5a30f
--- 
a/shell/src/main/java/org/apache/accumulo/shell/commands/ImportDirectoryCommand.java
+++ 
b/shell/src/main/java/org/apache/accumulo/shell/commands/ImportDirectoryCommand.java
@@@ -29,43 -30,24 +30,45 @@@ public class ImportDirectoryCommand ext
  
    @Override
    public String description() {
-     return "bulk imports an entire directory of data files to the current"
-         + " table. The boolean argument determines if accumulo sets the time. 
"
-         + "Passing 3 arguments will use the old bulk import.  The new bulk 
import only takes 2 "
-         + "arguments: <directory> true|false";
+     return "bulk imports an entire directory of data files into an existing 
table."
+         + " The table is either passed with the -t tablename opt, or into to 
the current"
 -        + " table if the -t option is not provided. The boolean argument 
determines if accumulo sets the time.";
++        + " table if the -t option is not provided. The boolean argument 
determines if accumulo"
++        + " sets the time. Passing 3 arguments will use the old bulk import.  
The new bulk"
++        + " import only takes 2 arguments: <directory> true|false";
    }
  
 +  @SuppressWarnings("deprecation")
    @Override
    public int execute(final String fullCommand, final CommandLine cl, final 
Shell shellState)
        throws IOException, AccumuloException, AccumuloSecurityException, 
TableNotFoundException {
-     shellState.checkTableState();
+ 
+     final String tableName = OptUtil.getTableOpt(cl, shellState);
  
 -    String dir = cl.getArgs()[0];
 -    String failureDir = cl.getArgs()[1];
 +    String[] args = cl.getArgs();
 +    String dir = args[0];
 +    boolean setTime;
  
 -    final boolean setTime = Boolean.parseBoolean(cl.getArgs()[2]);
 -
 -    shellState.getConnector().tableOperations().importDirectory(tableName, 
dir, failureDir,
 -        setTime);
 +    // new bulk import only takes 2 args
 +    if (args.length == 2) {
 +      setTime = Boolean.parseBoolean(cl.getArgs()[1]);
 +      shellState.getAccumuloClient().tableOperations().importDirectory(dir)
-           .to(shellState.getTableName()).tableTime(setTime).load();
++          .to(tableName).tableTime(setTime).load();
 +    } else if (args.length == 3) {
 +      // warn using deprecated bulk import
 +      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(shellState.getTableName(),
++      
shellState.getAccumuloClient().tableOperations().importDirectory(tableName,
 +          dir, failureDir, setTime);
 +      return 0;
 +    } else {
 +      shellState.printException(
 +          new IllegalArgumentException(String.format("Expected 2 or 3 
arguments. There %s %d.",
 +              args.length == 1 ? "was" : "were", args.length)));
 +      printHelp(shellState);
 +    }
  
      return 0;
    }
@@@ -77,7 -60,14 +80,14 @@@
  
    @Override
    public String usage() {
-     return getName() + " <directory> [failureDirectory] true|false";
 -    return getName() + "[-t tablename] <directory> <failureDirectory> 
true|false";
++    return getName() + "[-t tablename] <directory> [failureDirectory] 
true|false";
+   }
+ 
+   @Override
+   public Options getOptions() {
+     final Options opts = super.getOptions();
+     opts.addOption(OptUtil.tableOpt("name of the table to import files 
into"));
+     return opts;
    }
  
  }

Reply via email to