accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [5/6] git commit: Merge branch '1.5' into 1.6
Date Fri, 10 Oct 2014 18:20:44 GMT
Merge branch '1.5' into 1.6

Conflicts:
	core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/5029a442
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/5029a442
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/5029a442

Branch: refs/heads/1.6
Commit: 5029a4422259727bbb7038c1dd6808a84bea2c17
Parents: e7dc536 e18aacd
Author: Josh Elser <elserj@apache.org>
Authored: Fri Oct 10 14:20:14 2014 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Fri Oct 10 14:20:14 2014 -0400

----------------------------------------------------------------------
 core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/5029a442/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
----------------------------------------------------------------------
diff --cc core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
index 6043df3,a2834ff..7775567
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
@@@ -236,97 -212,102 +236,97 @@@ public class Shell extends ShellOption
      this.reader = reader;
      this.writer = writer;
    }
 -  
 +
    // Not for client use
    public boolean config(String... args) {
 -    
 -    CommandLine cl;
 +    ShellOptionsJC options = new ShellOptionsJC();
 +    JCommander jc = new JCommander();
 +
 +    jc.setProgramName("accumulo shell");
 +    jc.addObject(options);
      try {
 -      cl = new BasicParser().parse(opts, args);
 -      if (cl.getArgs().length > 0)
 -        throw new ParseException("Unrecognized arguments: " + cl.getArgList());
 -      
 -      if (cl.hasOption(helpOpt.getOpt())) {
 -        configError = true;
 -        printHelp("shell", SHELL_DESCRIPTION, opts);
 -        return true;
 -      }
 -      
 -      setDebugging(cl.hasOption(debugOption.getLongOpt()));
 -      authTimeout = Integer.parseInt(cl.getOptionValue(authTimeoutOpt.getLongOpt(), DEFAULT_AUTH_TIMEOUT))
* 60 * 1000l;
 -      disableAuthTimeout = cl.hasOption(disableAuthTimeoutOpt.getLongOpt());
 -      
 -      if (cl.hasOption(zooKeeperInstance.getOpt()) && cl.getOptionValues(zooKeeperInstance.getOpt()).length
!= 2)
 -        throw new MissingArgumentException(zooKeeperInstance);
 -      
 -    } catch (Exception e) {
 +      jc.parse(args);
 +    } catch (ParameterException e) {
        configError = true;
 -      printException(e);
 -      printHelp("shell", SHELL_DESCRIPTION, opts);
 +    }
 +
 +    if (options.isHelpEnabled()) {
 +      configError = true;
 +    }
 +
 +    if (!configError && options.getUnrecognizedOptions() != null) {
 +      configError = true;
 +      logError("Unrecognized Options: " + options.getUnrecognizedOptions().toString());
 +    }
 +
 +    if (configError) {
 +      jc.usage();
        return true;
      }
 -    
 +
 +    setDebugging(options.isDebugEnabled());
-     authTimeout = options.getAuthTimeout() * 60 * 1000; // convert minutes to milliseconds
++    authTimeout = options.getAuthTimeout() * 60 * 1000l; // convert minutes to milliseconds
 +    disableAuthTimeout = options.isAuthTimeoutDisabled();
 +
      // get the options that were parsed
 -    String sysUser = System.getProperty("user.name");
 -    if (sysUser == null)
 -      sysUser = "root";
 -    String user = cl.getOptionValue(usernameOption.getOpt(), sysUser);
 -    
 -    String passw = cl.getOptionValue(passwOption.getOpt(), null);
 -    tabCompletion = !cl.hasOption(tabCompleteOption.getLongOpt());
 -    String[] loginOptions = cl.getOptionValues(loginOption.getOpt());
 -    
 +    String user = options.getUsername();
 +    String password = options.getPassword();
 +
 +    tabCompletion = !options.isTabCompletionDisabled();
 +
      // Use a fake (Mock), ZK, or HdfsZK Accumulo instance
 -    setInstance(cl);
 -    
 +    setInstance(options);
 +
 +    // AuthenticationToken options
 +    token = options.getAuthenticationToken();
 +    Map<String,String> loginOptions = options.getTokenProperties();
 +
      // process default parameters if unspecified
      try {
 -      if (loginOptions != null && !cl.hasOption(tokenOption.getOpt()))
 -        throw new IllegalArgumentException("Must supply '-" + tokenOption.getOpt() + "'
option with '-" + loginOption.getOpt() + "' option");
 -      
 -      if (loginOptions == null && cl.hasOption(tokenOption.getOpt()))
 -        throw new IllegalArgumentException("Must supply '-" + loginOption.getOpt() + "'
option with '-" + tokenOption.getOpt() + "' option");
 -      
 -      if (passw != null && cl.hasOption(tokenOption.getOpt()))
 -        throw new IllegalArgumentException("Can not supply '-" + passwOption.getOpt() +
"' option with '-" + tokenOption.getOpt() + "' option");
 -      
 -      if (user == null)
 -        throw new MissingArgumentException(usernameOption);
 -      
 -      if (loginOptions != null && cl.hasOption(tokenOption.getOpt())) {
 -        Properties props = new Properties();
 -        for (String loginOption : loginOptions)
 -          for (String lo : loginOption.split(",")) {
 -            String[] split = lo.split("=");
 -            props.put(split[0], split[1]);
 -          }
 -        
 -        this.token = Class.forName(cl.getOptionValue(tokenOption.getOpt())).asSubclass(AuthenticationToken.class).newInstance();
 -        this.token.init(props);
 -      }
 -      
 -      if (!cl.hasOption(fakeOption.getLongOpt())) {
 -        DistributedTrace.enable(instance, new ZooReader(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut()),
"shell", InetAddress.getLocalHost()
 -            .getHostName());
 +      boolean hasToken = (token != null);
 +      boolean hasTokenOptions = !loginOptions.isEmpty();
 +
 +      if (hasToken && password != null) {
 +        throw new ParameterException("Can not supply '--pass' option with '--tokenClass'
option");
        }
 -      
 +
        Runtime.getRuntime().addShutdownHook(new Thread() {
          @Override
 -        public void start() {
 -          reader.getTerminal().enableEcho();
 +        public void run() {
 +          reader.getTerminal().setEchoEnabled(true);
          }
        });
 -      
 -      if (passw != null) {
 -        this.token = new PasswordToken(passw);
 +
 +      // Need either both a token and options, or neither, but not just one.
 +      if (hasToken != hasTokenOptions) {
 +        throw new ParameterException("Must supply either both or neither of '--tokenClass'
and '--tokenProperty'");
 +      } else if (hasToken) { // implied hasTokenOptions
 +        // Fully qualified name so we don't shadow java.util.Properties
 +        org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties props;
 +        // and line wrap it because the package name is so long
 +        props = new org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties();
 +
 +        props.putAllStrings(loginOptions);
 +        token.init(props);
 +      } else {
 +        // Read password if the user explicitly asked for it, or didn't specify anything
at all
 +        if ("stdin".equals(password) || password == null) {
 +          password = reader.readLine("Password: ", '*');
 +        }
 +
 +        if (password == null) {
 +          // User cancel, e.g. Ctrl-D pressed
 +          throw new ParameterException("No password or token option supplied");
 +        } else {
 +          this.token = new PasswordToken(password);
 +        }
        }
 -      
 -      if (this.token == null) {
 -        passw = readMaskedLine("Password: ", '*');
 -        if (passw != null)
 -          this.token = new PasswordToken(passw);
 +
 +      if (!options.isFake()) {
 +        ZooReader zr = new ZooReader(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut());
 +        DistributedTrace.enable(instance, zr, "shell", InetAddress.getLocalHost().getHostName());
        }
 -      
 -      if (this.token == null) {
 -        reader.printNewline();
 -        throw new MissingArgumentException("No password or token option supplied");
 -      } // user canceled
 -      
 +
        this.setTableName("");
        this.principal = user;
        connector = instance.getConnector(this.principal, token);


Mime
View raw message