accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From md...@apache.org
Subject [16/27] ACCUMULO-1879 Move shell into new package and module
Date Tue, 08 Apr 2014 00:37:19 GMT
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/RevokeCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/RevokeCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/RevokeCommand.java
new file mode 100644
index 0000000..373c0b0
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/RevokeCommand.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.shell.commands;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.accumulo.core.security.NamespacePermission;
+import org.apache.accumulo.core.security.SystemPermission;
+import org.apache.accumulo.core.security.TablePermission;
+import org.apache.accumulo.core.util.BadArgumentException;
+import org.apache.accumulo.shell.Shell;
+import org.apache.accumulo.shell.Token;
+import org.apache.accumulo.shell.Shell.Command;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
+
+public class RevokeCommand extends TableOperation {
+  {
+    disableUnflaggedTableOptions();
+  }
+
+  private Option systemOpt, userOpt;
+  private String user;
+  private String[] permission;
+
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    user = cl.hasOption(userOpt.getOpt()) ? cl.getOptionValue(userOpt.getOpt()) : shellState.getConnector().whoami();
+
+    permission = cl.getArgs()[0].split("\\.", 2);
+    if (cl.hasOption(systemOpt.getOpt()) && permission[0].equalsIgnoreCase("System")) {
+      try {
+        shellState.getConnector().securityOperations().revokeSystemPermission(user, SystemPermission.valueOf(permission[1]));
+        Shell.log.debug("Revoked from " + user + " the " + permission[1] + " permission");
+      } catch (IllegalArgumentException e) {
+        throw new BadArgumentException("No such system permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
+      }
+    } else if (permission[0].equalsIgnoreCase("Table")) {
+      super.execute(fullCommand, cl, shellState);
+    } else if (permission[0].equalsIgnoreCase("Namespace")) {
+      if (cl.hasOption(optNamespace.getOpt())) {
+        try {
+          shellState.getConnector().securityOperations()
+              .revokeNamespacePermission(user, cl.getOptionValue(optNamespace.getOpt()), NamespacePermission.valueOf(permission[1]));
+        } catch (IllegalArgumentException e) {
+          throw new BadArgumentException("No such namespace permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
+        }
+      } else {
+        throw new BadArgumentException("No namespace specified to apply permission to", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
+      }
+    } else {
+      throw new BadArgumentException("Unrecognized permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
+    }
+    return 0;
+  }
+
+  @Override
+  protected void doTableOp(final Shell shellState, final String tableName) throws Exception {
+    try {
+      shellState.getConnector().securityOperations().revokeTablePermission(user, tableName, TablePermission.valueOf(permission[1]));
+      Shell.log.debug("Revoked from " + user + " the " + permission[1] + " permission on table " + tableName);
+    } catch (IllegalArgumentException e) {
+      throw new IllegalArgumentException("No such table permission", e);
+    }
+  }
+
+  @Override
+  public String description() {
+    return "revokes system or table permissions from a user";
+  }
+
+  @Override
+  public String usage() {
+    return getName() + " <permission>";
+  }
+
+  @Override
+  public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> completionSet) {
+    final Token cmd = new Token(getName());
+    cmd.addSubcommand(new Token(TablePermission.printableValues()));
+    cmd.addSubcommand(new Token(SystemPermission.printableValues()));
+    cmd.addSubcommand(new Token(NamespacePermission.printableValues()));
+    root.addSubcommand(cmd);
+  }
+
+  @Override
+  public Options getOptions() {
+    super.getOptions();
+    final Options o = new Options();
+
+    final OptionGroup group = new OptionGroup();
+
+    systemOpt = new Option("s", "system", false, "revoke a system permission");
+
+    optNamespace = new Option(Shell.namespaceOption, "namespace", true, "name of a namespace to operate on");
+    optNamespace.setArgName("namespace");
+
+    group.addOption(systemOpt);
+    group.addOption(optTableName);
+    group.addOption(optTablePattern);
+    group.addOption(optNamespace);
+
+    o.addOptionGroup(group);
+    userOpt = new Option(Shell.userOption, "user", true, "user to operate on");
+    userOpt.setArgName("username");
+    userOpt.setRequired(true);
+    o.addOption(userOpt);
+
+    return o;
+  }
+
+  @Override
+  public int numArgs() {
+    return 1;
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/ScanCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/ScanCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/ScanCommand.java
new file mode 100644
index 0000000..37a33a4
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/ScanCommand.java
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.shell.commands;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.ScannerBase;
+import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.util.format.BinaryFormatter;
+import org.apache.accumulo.core.util.format.Formatter;
+import org.apache.accumulo.core.util.interpret.DefaultScanInterpreter;
+import org.apache.accumulo.core.util.interpret.ScanInterpreter;
+import org.apache.accumulo.shell.Shell;
+import org.apache.accumulo.shell.Shell.Command;
+import org.apache.accumulo.shell.Shell.PrintFile;
+import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.hadoop.io.Text;
+
+public class ScanCommand extends Command {
+  
+  private Option scanOptAuths, scanOptRow, scanOptColumns, disablePaginationOpt, showFewOpt, formatterOpt, interpreterOpt, formatterInterpeterOpt,
+      outputFileOpt;
+  
+  protected Option timestampOpt;
+  private Option optStartRowExclusive;
+  private Option optEndRowExclusive;
+  private Option timeoutOption;
+  private Option profileOpt;
+  
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    final PrintFile printFile = getOutputFile(cl);
+    final String tableName = OptUtil.getTableOpt(cl, shellState);
+    
+    final Class<? extends Formatter> formatter = getFormatter(cl, tableName, shellState);
+    final ScanInterpreter interpeter = getInterpreter(cl, tableName, shellState);
+    
+    // handle first argument, if present, the authorizations list to
+    // scan with
+    final Authorizations auths = getAuths(cl, shellState);
+    final Scanner scanner = shellState.getConnector().createScanner(tableName, auths);
+    
+    // handle session-specific scan iterators
+    addScanIterators(shellState, cl, scanner, tableName);
+    
+    // handle remaining optional arguments
+    scanner.setRange(getRange(cl, interpeter));
+    
+    // handle columns
+    fetchColumns(cl, scanner, interpeter);
+    
+    // set timeout
+    scanner.setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS);
+    
+    // output the records
+    if (cl.hasOption(showFewOpt.getOpt())) {
+      final String showLength = cl.getOptionValue(showFewOpt.getOpt());
+      try {
+        final int length = Integer.parseInt(showLength);
+        if (length < 1) {
+          throw new IllegalArgumentException();
+        }
+        BinaryFormatter.getlength(length);
+        printBinaryRecords(cl, shellState, scanner, printFile);
+      } catch (NumberFormatException nfe) {
+        shellState.getReader().println("Arg must be an integer.");
+      } catch (IllegalArgumentException iae) {
+        shellState.getReader().println("Arg must be greater than one.");
+      }
+      
+    } else {
+      printRecords(cl, shellState, scanner, formatter, printFile);
+    }
+    if (printFile != null) {
+      printFile.close();
+    }
+    
+    return 0;
+  }
+  
+  protected long getTimeout(final CommandLine cl) {
+    if (cl.hasOption(timeoutOption.getLongOpt())) {
+      return AccumuloConfiguration.getTimeInMillis(cl.getOptionValue(timeoutOption.getLongOpt()));
+    }
+    
+    return Long.MAX_VALUE;
+  }
+  
+  protected void addScanIterators(final Shell shellState, CommandLine cl, final Scanner scanner, final String tableName) {
+    
+    List<IteratorSetting> tableScanIterators;
+    if (cl.hasOption(profileOpt.getOpt())) {
+      String profile = cl.getOptionValue(profileOpt.getOpt());
+      tableScanIterators = shellState.iteratorProfiles.get(profile);
+      
+      if (tableScanIterators == null) {
+        throw new IllegalArgumentException("Profile " + profile + " does not exist");
+      }
+    } else {
+      tableScanIterators = shellState.scanIteratorOptions.get(tableName);
+      if (tableScanIterators == null) {
+        Shell.log.debug("Found no scan iterators to set");
+        return;
+      }
+    }
+    
+    Shell.log.debug("Found " + tableScanIterators.size() + " scan iterators to set");
+    
+    for (IteratorSetting setting : tableScanIterators) {
+      Shell.log.debug("Setting scan iterator " + setting.getName() + " at priority " + setting.getPriority() + " using class name "
+          + setting.getIteratorClass());
+      for (Entry<String,String> option : setting.getOptions().entrySet()) {
+        Shell.log.debug("Setting option for " + setting.getName() + ": " + option.getKey() + "=" + option.getValue());
+      }
+      scanner.addScanIterator(setting);
+    }
+  }
+  
+  protected void printRecords(final CommandLine cl, final Shell shellState, final Iterable<Entry<Key,Value>> scanner, final Class<? extends Formatter> formatter)
+      throws IOException {
+    printRecords(cl, shellState, scanner, formatter, null);
+  }
+  
+  protected void printRecords(final CommandLine cl, final Shell shellState, final Iterable<Entry<Key,Value>> scanner,
+      final Class<? extends Formatter> formatter, PrintFile outFile) throws IOException {
+    if (outFile == null) {
+      shellState.printRecords(scanner, cl.hasOption(timestampOpt.getOpt()), !cl.hasOption(disablePaginationOpt.getOpt()), formatter);
+    } else {
+      shellState.printRecords(scanner, cl.hasOption(timestampOpt.getOpt()), !cl.hasOption(disablePaginationOpt.getOpt()), formatter, outFile);
+    }
+  }
+  
+  protected void printBinaryRecords(final CommandLine cl, final Shell shellState, final Iterable<Entry<Key,Value>> scanner) throws IOException {
+    printBinaryRecords(cl, shellState, scanner, null);
+  }
+  
+  protected void printBinaryRecords(final CommandLine cl, final Shell shellState, final Iterable<Entry<Key,Value>> scanner, PrintFile outFile)
+      throws IOException {
+    if (outFile == null) {
+      shellState.printBinaryRecords(scanner, cl.hasOption(timestampOpt.getOpt()), !cl.hasOption(disablePaginationOpt.getOpt()));
+    } else {
+      shellState.printBinaryRecords(scanner, cl.hasOption(timestampOpt.getOpt()), !cl.hasOption(disablePaginationOpt.getOpt()), outFile);
+    }
+  }
+  
+  protected ScanInterpreter getInterpreter(final CommandLine cl, final String tableName, final Shell shellState) throws Exception {
+    
+    Class<? extends ScanInterpreter> clazz = null;
+    try {
+      if (cl.hasOption(interpreterOpt.getOpt())) {
+        clazz = AccumuloVFSClassLoader.loadClass(cl.getOptionValue(interpreterOpt.getOpt()), ScanInterpreter.class);
+      } else if (cl.hasOption(formatterInterpeterOpt.getOpt())) {
+        clazz = AccumuloVFSClassLoader.loadClass(cl.getOptionValue(formatterInterpeterOpt.getOpt()), ScanInterpreter.class);
+      }
+    } catch (ClassNotFoundException e) {
+      shellState.getReader().println("Interpreter class could not be loaded.\n" + e.getMessage());
+    }
+    
+    if (clazz == null)
+      clazz = InterpreterCommand.getCurrentInterpreter(tableName, shellState);
+    
+    if (clazz == null)
+      clazz = DefaultScanInterpreter.class;
+    
+    return clazz.newInstance();
+  }
+  
+  protected Class<? extends Formatter> getFormatter(final CommandLine cl, final String tableName, final Shell shellState) throws IOException {
+    
+    try {
+      if (cl.hasOption(formatterOpt.getOpt())) {
+        return AccumuloVFSClassLoader.loadClass(cl.getOptionValue(formatterOpt.getOpt()), Formatter.class);
+        
+      } else if (cl.hasOption(formatterInterpeterOpt.getOpt())) {
+        return AccumuloVFSClassLoader.loadClass(cl.getOptionValue(formatterInterpeterOpt.getOpt()), Formatter.class);
+      }
+    } catch (ClassNotFoundException e) {
+      shellState.getReader().println("Formatter class could not be loaded.\n" + e.getMessage());
+    }
+    
+    return shellState.getFormatter(tableName);
+  }
+  
+  protected void fetchColumns(final CommandLine cl, final ScannerBase scanner, final ScanInterpreter formatter) throws UnsupportedEncodingException {
+    if (cl.hasOption(scanOptColumns.getOpt())) {
+      for (String a : cl.getOptionValue(scanOptColumns.getOpt()).split(",")) {
+        final String sa[] = a.split(":", 2);
+        if (sa.length == 1) {
+          scanner.fetchColumnFamily(formatter.interpretColumnFamily(new Text(a.getBytes(Shell.CHARSET))));
+        } else {
+          scanner.fetchColumn(formatter.interpretColumnFamily(new Text(sa[0].getBytes(Shell.CHARSET))),
+              formatter.interpretColumnQualifier(new Text(sa[1].getBytes(Shell.CHARSET))));
+        }
+      }
+    }
+  }
+  
+  protected Range getRange(final CommandLine cl, final ScanInterpreter formatter) throws UnsupportedEncodingException {
+    if ((cl.hasOption(OptUtil.START_ROW_OPT) || cl.hasOption(OptUtil.END_ROW_OPT)) && cl.hasOption(scanOptRow.getOpt())) {
+      // did not see a way to make commons cli do this check... it has mutually exclusive options but does not support the or
+      throw new IllegalArgumentException("Options -" + scanOptRow.getOpt() + " AND (-" + OptUtil.START_ROW_OPT + " OR -" + OptUtil.END_ROW_OPT
+          + ") are mutally exclusive ");
+    }
+    
+    if (cl.hasOption(scanOptRow.getOpt())) {
+      return new Range(formatter.interpretRow(new Text(cl.getOptionValue(scanOptRow.getOpt()).getBytes(Shell.CHARSET))));
+    } else {
+      Text startRow = OptUtil.getStartRow(cl);
+      if (startRow != null)
+        startRow = formatter.interpretBeginRow(startRow);
+      Text endRow = OptUtil.getEndRow(cl);
+      if (endRow != null)
+        endRow = formatter.interpretEndRow(endRow);
+      final boolean startInclusive = !cl.hasOption(optStartRowExclusive.getOpt());
+      final boolean endInclusive = !cl.hasOption(optEndRowExclusive.getOpt());
+      return new Range(startRow, startInclusive, endRow, endInclusive);
+    }
+  }
+  
+  protected Authorizations getAuths(final CommandLine cl, final Shell shellState) throws AccumuloSecurityException, AccumuloException {
+    final String user = shellState.getConnector().whoami();
+    Authorizations auths = shellState.getConnector().securityOperations().getUserAuthorizations(user);
+    if (cl.hasOption(scanOptAuths.getOpt())) {
+      auths = ScanCommand.parseAuthorizations(cl.getOptionValue(scanOptAuths.getOpt()));
+    }
+    return auths;
+  }
+  
+  static Authorizations parseAuthorizations(final String field) {
+    if (field == null || field.isEmpty()) {
+      return Authorizations.EMPTY;
+    }
+    return new Authorizations(field.split(","));
+  }
+  
+  @Override
+  public String description() {
+    return "scans the table, and displays the resulting records";
+  }
+  
+  @Override
+  public Options getOptions() {
+    final Options o = new Options();
+    
+    scanOptAuths = new Option("s", "scan-authorizations", true, "scan authorizations (all user auths are used if this argument is not specified)");
+    optStartRowExclusive = new Option("be", "begin-exclusive", false, "make start row exclusive (by default it's inclusive)");
+    optStartRowExclusive.setArgName("begin-exclusive");
+    optEndRowExclusive = new Option("ee", "end-exclusive", false, "make end row exclusive (by default it's inclusive)");
+    optEndRowExclusive.setArgName("end-exclusive");
+    scanOptRow = new Option("r", "row", true, "row to scan");
+    scanOptColumns = new Option("c", "columns", true, "comma-separated columns");
+    timestampOpt = new Option("st", "show-timestamps", false, "display timestamps");
+    disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output");
+    showFewOpt = new Option("f", "show few", true, "show only a specified number of characters");
+    formatterOpt = new Option("fm", "formatter", true, "fully qualified name of the formatter class to use");
+    interpreterOpt = new Option("i", "interpreter", true, "fully qualified name of the interpreter class to use");
+    formatterInterpeterOpt = new Option("fi", "fmt-interpreter", true, "fully qualified name of a class that is a formatter and interpreter");
+    timeoutOption = new Option(null, "timeout", true,
+        "time before scan should fail if no data is returned. If no unit is given assumes seconds.  Units d,h,m,s,and ms are supported.  e.g. 30s or 100ms");
+    outputFileOpt = new Option("o", "output", true, "local file to write the scan output to");
+    
+    scanOptAuths.setArgName("comma-separated-authorizations");
+    scanOptRow.setArgName("row");
+    scanOptColumns.setArgName("<columnfamily>[:<columnqualifier>]{,<columnfamily>[:<columnqualifier>]}");
+    showFewOpt.setRequired(false);
+    showFewOpt.setArgName("int");
+    formatterOpt.setArgName("className");
+    timeoutOption.setArgName("timeout");
+    outputFileOpt.setArgName("file");
+    
+    profileOpt = new Option("pn", "profile", true, "iterator profile name");
+    profileOpt.setArgName("profile");
+    
+    o.addOption(scanOptAuths);
+    o.addOption(scanOptRow);
+    o.addOption(OptUtil.startRowOpt());
+    o.addOption(OptUtil.endRowOpt());
+    o.addOption(optStartRowExclusive);
+    o.addOption(optEndRowExclusive);
+    o.addOption(scanOptColumns);
+    o.addOption(timestampOpt);
+    o.addOption(disablePaginationOpt);
+    o.addOption(OptUtil.tableOpt("table to be scanned"));
+    o.addOption(showFewOpt);
+    o.addOption(formatterOpt);
+    o.addOption(interpreterOpt);
+    o.addOption(formatterInterpeterOpt);
+    o.addOption(timeoutOption);
+    o.addOption(outputFileOpt);
+    o.addOption(profileOpt);
+    
+    return o;
+  }
+  
+  @Override
+  public int numArgs() {
+    return 0;
+  }
+  
+  protected PrintFile getOutputFile(final CommandLine cl) throws FileNotFoundException {
+    final String outputFile = cl.getOptionValue(outputFileOpt.getOpt());
+    return (outputFile == null ? null : new PrintFile(outputFile));
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/ScriptCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/ScriptCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/ScriptCommand.java
new file mode 100644
index 0000000..9bd91cc
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/ScriptCommand.java
@@ -0,0 +1,290 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.shell.commands;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.script.Bindings;
+import javax.script.Compilable;
+import javax.script.CompiledScript;
+import javax.script.Invocable;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineFactory;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+import javax.script.SimpleScriptContext;
+
+import org.apache.accumulo.shell.Shell;
+import org.apache.accumulo.shell.Shell.Command;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
+
+public class ScriptCommand extends Command {
+  
+  // Command to allow user to run scripts, see JSR-223
+  // http://www.oracle.com/technetwork/articles/javase/scripting-140262.html
+  
+  protected Option list, engine, script, file, args, out, function, object;
+  private static final String DEFAULT_ENGINE = "rhino";
+  
+  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
+
+    boolean invoke = false;
+    ScriptEngineManager mgr = new ScriptEngineManager();
+    
+    if (cl.hasOption(list.getOpt())) {
+      listJSREngineInfo(mgr, shellState);
+    } else if (cl.hasOption(file.getOpt()) || cl.hasOption(script.getOpt())) {
+      String engineName = DEFAULT_ENGINE;
+      if (cl.hasOption(engine.getOpt())) {
+        engineName = cl.getOptionValue(engine.getOpt());
+      }
+      ScriptEngine engine = mgr.getEngineByName(engineName);
+      if (null == engine) {
+        shellState.printException(new Exception(engineName + " not found"));
+        return 1;
+      }
+      
+      if (cl.hasOption(object.getOpt()) || cl.hasOption(function.getOpt())) {
+        if (!(engine instanceof Invocable)) {
+          shellState.printException(new Exception(engineName + " does not support invoking functions or methods"));
+          return 1;
+        }
+        invoke = true;
+      }
+      
+      ScriptContext ctx = new SimpleScriptContext();
+      
+      // Put the following objects into the context so that they
+      // are available to the scripts
+      // TODO: What else should go in here?
+      Bindings b = engine.getBindings(ScriptContext.ENGINE_SCOPE);
+      b.put("connection", shellState.getConnector());
+      
+      List<Object> argValues = new ArrayList<Object>();
+      if (cl.hasOption(args.getOpt())) {
+        String[] argList = cl.getOptionValue(args.getOpt()).split(",");
+        for (String arg : argList) {
+          String[] parts = arg.split("=");
+          if (parts.length == 0) {
+            continue;
+          } else if (parts.length == 1) {
+            b.put(parts[0], null);
+            argValues.add(null);
+          } else if (parts.length == 2) {
+            b.put(parts[0], parts[1]);
+            argValues.add(parts[1]);
+          }
+        }
+      }
+      ctx.setBindings(b, ScriptContext.ENGINE_SCOPE);
+      Object[] argArray = argValues.toArray(new Object[argValues.size()]);
+      
+      Writer writer = null;
+      if (cl.hasOption(out.getOpt())) {
+        File f = new File(cl.getOptionValue(out.getOpt()));
+        writer = new FileWriter(f);
+        ctx.setWriter(writer);
+      }
+      
+      if (cl.hasOption(file.getOpt())) {
+        File f = new File(cl.getOptionValue(file.getOpt()));
+        if (!f.exists()) {
+          if (null != writer) {
+            writer.close();
+          }
+          shellState.printException(new Exception(f.getAbsolutePath() + " not found"));
+          return 1;
+        }
+        Reader reader = new FileReader(f);
+        try {
+          engine.eval(reader, ctx);
+          if (invoke) {
+            this.invokeFunctionOrMethod(shellState, engine, cl, argArray);
+          }
+        } catch (ScriptException ex) {
+          shellState.printException(ex);
+          return 1;
+        } finally {
+          reader.close();
+          if (null != writer) {
+            writer.close();
+          }
+        }
+      } else if (cl.hasOption(script.getOpt())) {
+        String inlineScript = cl.getOptionValue(script.getOpt());
+        try {
+          if (engine instanceof Compilable) {
+            Compilable compiledEng = (Compilable) engine;
+            CompiledScript script = compiledEng.compile(inlineScript);
+            script.eval(ctx);
+            if (invoke) {
+              this.invokeFunctionOrMethod(shellState, engine, cl, argArray);
+            }
+          } else {
+            engine.eval(inlineScript, ctx);
+            if (invoke) {
+              this.invokeFunctionOrMethod(shellState, engine, cl, argArray);
+            }
+          }
+        } catch (ScriptException ex) {
+          shellState.printException(ex);
+          return 1;
+        } finally {
+          if (null != writer) {
+            writer.close();
+          }
+        }
+      }
+      if (null != writer) {
+        writer.close();
+      }
+      
+    } else {
+      printHelp(shellState);
+    }
+    return 0;
+  }
+  
+  public String description() {
+    return "execute JSR-223 scripts";
+  }
+  
+  public int numArgs() {
+    return 0;
+  }
+  
+  @Override
+  public String getName() {
+    return "script";
+  }
+  
+  @Override
+  public Options getOptions() {
+    final Options o = new Options();
+    
+    engine = new Option("e", "engine", false, "engine name, defaults to JDK default (Rhino)");
+    engine.setArgName("engineName");
+    engine.setArgs(1);
+    engine.setRequired(false);
+    o.addOption(engine);
+    
+    OptionGroup inputGroup = new OptionGroup();
+    list = new Option("l", "list", false, "list available script engines");
+    inputGroup.addOption(list);
+
+    script = new Option("s", "script", true, "use inline script");
+    script.setArgName("script text");
+    script.setArgs(1);
+    script.setRequired(false);
+    inputGroup.addOption(script);
+    
+    file = new Option("f", "file", true, "use script file");
+    file.setArgName("fileName");
+    file.setArgs(1);
+    file.setRequired(false);
+    
+    inputGroup.addOption(file);
+    inputGroup.setRequired(true);
+    o.addOptionGroup(inputGroup);
+    
+    OptionGroup invokeGroup = new OptionGroup();
+    object = new Option("obj", "object", true, "name of object");
+    object.setArgs(1);
+    object.setArgName("objectName:methodName");
+    object.setRequired(false);
+    invokeGroup.addOption(object);
+    
+    function = new Option("fx", "function", true, "invoke a script function");
+    function.setArgName("functionName");
+    function.setArgs(1);
+    function.setRequired(false);
+    invokeGroup.addOption(function);
+    invokeGroup.setRequired(false);
+    o.addOptionGroup(invokeGroup);
+    
+    args = new Option("a", "args", true, "comma separated list of key=value arguments");
+    args.setArgName("property1=value1,propert2=value2,...");
+    args.setArgs(Option.UNLIMITED_VALUES);
+    args.setRequired(false);
+    o.addOption(args);
+    
+    out = new Option("o", "output", true, "output file");
+    out.setArgName("fileName");
+    out.setArgs(1);
+    out.setRequired(false);
+    o.addOption(out);
+    
+    return o;
+  }
+  
+  private void listJSREngineInfo(ScriptEngineManager mgr, Shell shellState) throws IOException {
+    List<ScriptEngineFactory> factories = mgr.getEngineFactories();
+    Set<String> lines = new TreeSet<String>();
+    for (ScriptEngineFactory factory : factories) {
+      lines.add("ScriptEngineFactory Info");
+      String engName = factory.getEngineName();
+      String engVersion = factory.getEngineVersion();
+      String langName = factory.getLanguageName();
+      String langVersion = factory.getLanguageVersion();
+      lines.add("\tScript Engine: " + engName + " (" + engVersion + ")");
+      List<String> engNames = factory.getNames();
+      for (String name : engNames) {
+        lines.add("\tEngine Alias: " + name);
+      }
+      lines.add("\tLanguage: " + langName + " (" + langVersion + ")");
+    }
+    shellState.printLines(lines.iterator(), true);
+    
+  }
+  
+  private void invokeFunctionOrMethod(Shell shellState, ScriptEngine engine, CommandLine cl, Object[] args) {
+    try {
+      Invocable inv = (Invocable) engine;
+      if (cl.hasOption(function.getOpt())) {
+        inv.invokeFunction(cl.getOptionValue(function.getOpt()), args);
+      } else if (cl.hasOption(object.getOpt())) {
+        String objectMethod = cl.getOptionValue(object.getOpt());
+        String[] parts = objectMethod.split(":");
+        if (!(parts.length == 2)) {
+          shellState.printException(new Exception("Object and Method must be supplied"));
+          return;
+        }
+        String objectName = parts[0];
+        String methodName = parts[1];
+        Object obj = engine.get(objectName);
+        inv.invokeMethod(obj, methodName, args);
+        
+      }
+    } catch (Exception e) {
+      shellState.printException(e);
+    }
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/SetAuthsCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/SetAuthsCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/SetAuthsCommand.java
new file mode 100644
index 0000000..cc99cbb
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/SetAuthsCommand.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.shell.commands;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.shell.Shell;
+import org.apache.accumulo.shell.Token;
+import org.apache.accumulo.shell.Shell.Command;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
+
+public class SetAuthsCommand extends Command {
+  private Option userOpt;
+  private Option scanOptAuths;
+  private Option clearOptAuths;
+  
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException {
+    final String user = cl.getOptionValue(userOpt.getOpt(), shellState.getConnector().whoami());
+    final String scanOpts = cl.hasOption(clearOptAuths.getOpt()) ? null : cl.getOptionValue(scanOptAuths.getOpt());
+    shellState.getConnector().securityOperations().changeUserAuthorizations(user, ScanCommand.parseAuthorizations(scanOpts));
+    Shell.log.debug("Changed record-level authorizations for user " + user);
+    return 0;
+  }
+  
+  @Override
+  public String description() {
+    return "sets the maximum scan authorizations for a user";
+  }
+  
+  @Override
+  public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> completionSet) {
+    registerCompletionForUsers(root, completionSet);
+  }
+  
+  @Override
+  public Options getOptions() {
+    final Options o = new Options();
+    final OptionGroup setOrClear = new OptionGroup();
+    scanOptAuths = new Option("s", "scan-authorizations", true, "scan authorizations to set");
+    scanOptAuths.setArgName("comma-separated-authorizations");
+    setOrClear.addOption(scanOptAuths);
+    clearOptAuths = new Option("c", "clear-authorizations", false, "clear the scan authorizations");
+    setOrClear.addOption(clearOptAuths);
+    setOrClear.setRequired(true);
+    o.addOptionGroup(setOrClear);
+    userOpt = new Option(Shell.userOption, "user", true, "user to operate on");
+    userOpt.setArgName("user");
+    o.addOption(userOpt);
+    return o;
+  }
+  
+  @Override
+  public int numArgs() {
+    return 0;
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/SetGroupsCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/SetGroupsCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/SetGroupsCommand.java
new file mode 100644
index 0000000..fc8b06e
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/SetGroupsCommand.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.shell.commands;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.accumulo.shell.Shell;
+import org.apache.accumulo.shell.Shell.Command;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Options;
+import org.apache.hadoop.io.Text;
+
+public class SetGroupsCommand extends Command {
+  @Override
+  public String description() {
+    return "sets the locality groups for a given table (for binary or commas, use Java API)";
+  }
+  
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    final String tableName = OptUtil.getTableOpt(cl, shellState);
+    
+    final HashMap<String,Set<Text>> groups = new HashMap<String,Set<Text>>();
+    
+    for (String arg : cl.getArgs()) {
+      final String sa[] = arg.split("=", 2);
+      if (sa.length < 2) {
+        throw new IllegalArgumentException("Missing '='");
+      }
+      final String group = sa[0];
+      final HashSet<Text> colFams = new HashSet<Text>();
+      
+      for (String family : sa[1].split(",")) {
+        colFams.add(new Text(family.getBytes(Shell.CHARSET)));
+      }
+      
+      groups.put(group, colFams);
+    }
+    
+    shellState.getConnector().tableOperations().setLocalityGroups(tableName, groups);
+    
+    return 0;
+  }
+  
+  @Override
+  public int numArgs() {
+    return Shell.NO_FIXED_ARG_LENGTH_CHECK;
+  }
+  
+  @Override
+  public String usage() {
+    return getName() + " <group>=<col fam>{,<col fam>}{ <group>=<col fam>{,<col fam>}}";
+  }
+  
+  @Override
+  public Options getOptions() {
+    final Options opts = new Options();
+    opts.addOption(OptUtil.tableOpt("table to fetch locality groups for"));
+    return opts;
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/SetIterCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/SetIterCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/SetIterCommand.java
new file mode 100644
index 0000000..a398b3a
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/SetIterCommand.java
@@ -0,0 +1,453 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.shell.commands;
+
+import java.io.IOException;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import jline.console.ConsoleReader;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.NamespaceNotFoundException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
+import org.apache.accumulo.core.iterators.OptionDescriber;
+import org.apache.accumulo.core.iterators.OptionDescriber.IteratorOptions;
+import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
+import org.apache.accumulo.core.iterators.user.AgeOffFilter;
+import org.apache.accumulo.core.iterators.user.RegExFilter;
+import org.apache.accumulo.core.iterators.user.ReqVisFilter;
+import org.apache.accumulo.core.iterators.user.VersioningIterator;
+import org.apache.accumulo.shell.Shell;
+import org.apache.accumulo.shell.ShellCommandException;
+import org.apache.accumulo.shell.Shell.Command;
+import org.apache.accumulo.shell.ShellCommandException.ErrorCode;
+import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
+import org.apache.accumulo.start.classloader.vfs.ContextManager;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.vfs2.FileSystemException;
+
+public class SetIterCommand extends Command {
+
+  private Option allScopeOpt, mincScopeOpt, majcScopeOpt, scanScopeOpt, nameOpt, priorityOpt;
+  private Option aggTypeOpt, ageoffTypeOpt, regexTypeOpt, versionTypeOpt, reqvisTypeOpt, classnameTypeOpt;
+
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException,
+      TableNotFoundException, IOException, ShellCommandException {
+
+    boolean tables = cl.hasOption(OptUtil.tableOpt().getOpt()) || !shellState.getTableName().isEmpty();
+    boolean namespaces = cl.hasOption(OptUtil.namespaceOpt().getOpt());
+
+    final int priority = Integer.parseInt(cl.getOptionValue(priorityOpt.getOpt()));
+
+    final Map<String,String> options = new HashMap<String,String>();
+    String classname = cl.getOptionValue(classnameTypeOpt.getOpt());
+    if (cl.hasOption(aggTypeOpt.getOpt())) {
+      Shell.log.warn("aggregators are deprecated");
+      @SuppressWarnings("deprecation")
+      String deprecatedClassName = org.apache.accumulo.core.iterators.AggregatingIterator.class.getName();
+      classname = deprecatedClassName;
+    } else if (cl.hasOption(regexTypeOpt.getOpt())) {
+      classname = RegExFilter.class.getName();
+    } else if (cl.hasOption(ageoffTypeOpt.getOpt())) {
+      classname = AgeOffFilter.class.getName();
+    } else if (cl.hasOption(versionTypeOpt.getOpt())) {
+      classname = VersioningIterator.class.getName();
+    } else if (cl.hasOption(reqvisTypeOpt.getOpt())) {
+      classname = ReqVisFilter.class.getName();
+    }
+
+    ClassLoader classloader = getClassLoader(cl, shellState);
+
+    // Get the iterator options, with potentially a name provided by the OptionDescriber impl or through user input
+    String configuredName = setUpOptions(classloader, shellState.getReader(), classname, options);
+
+    // Try to get the name provided by the setiter command
+    String name = cl.getOptionValue(nameOpt.getOpt(), null);
+    
+    // Cannot continue if no name is provided
+    if (null == name && null == configuredName) {
+      throw new IllegalArgumentException("No provided or default name for iterator");
+    } else if (null == name) {
+      // Fall back to the name from OptionDescriber or user input if none is provided on setiter option
+      name = configuredName;
+    }
+
+    if (namespaces) {
+      try {
+        setNamespaceProperties(cl, shellState, priority, options, classname, name);
+      } catch (NamespaceNotFoundException e) {
+        throw new IllegalArgumentException(e);
+      }
+    } else if (tables) {
+      setTableProperties(cl, shellState, priority, options, classname, name);
+    } else {
+      throw new IllegalArgumentException("No table or namespace specified");
+    }
+    return 0;
+  }
+
+  private ClassLoader getClassLoader(final CommandLine cl, final Shell shellState) throws AccumuloException, TableNotFoundException, AccumuloSecurityException,
+      IOException, FileSystemException {
+
+    boolean tables = cl.hasOption(OptUtil.tableOpt().getOpt()) || !shellState.getTableName().isEmpty();
+    boolean namespaces = cl.hasOption(OptUtil.namespaceOpt().getOpt());
+
+    String classpath = null;
+    Iterable<Entry<String,String>> tableProps;
+
+    if (namespaces) {
+      try {
+        tableProps = shellState.getConnector().namespaceOperations().getProperties(OptUtil.getNamespaceOpt(cl, shellState));
+      } catch (NamespaceNotFoundException e) {
+        throw new IllegalArgumentException(e);
+      }
+    } else if (tables) {
+      tableProps = shellState.getConnector().tableOperations().getProperties(OptUtil.getTableOpt(cl, shellState));
+    } else {
+      throw new IllegalArgumentException("No table or namespace specified");
+    }
+    for (Entry<String,String> entry : tableProps) {
+      if (entry.getKey().equals(Property.TABLE_CLASSPATH.getKey())) {
+        classpath = entry.getValue();
+      }
+    }
+
+    ClassLoader classloader;
+
+    if (classpath != null && !classpath.equals("")) {
+      shellState.getConnector().instanceOperations().getSystemConfiguration().get(Property.VFS_CONTEXT_CLASSPATH_PROPERTY.getKey() + classpath);
+
+      try {
+        AccumuloVFSClassLoader.getContextManager().setContextConfig(new ContextManager.DefaultContextsConfig(new Iterable<Map.Entry<String,String>>() {
+          @Override
+          public Iterator<Entry<String,String>> iterator() {
+            try {
+              return shellState.getConnector().instanceOperations().getSystemConfiguration().entrySet().iterator();
+            } catch (AccumuloException e) {
+              throw new RuntimeException(e);
+            } catch (AccumuloSecurityException e) {
+              throw new RuntimeException(e);
+            }
+          }
+        }));
+      } catch (IllegalStateException ise) {}
+
+      classloader = AccumuloVFSClassLoader.getContextManager().getClassLoader(classpath);
+    } else {
+      classloader = AccumuloVFSClassLoader.getClassLoader();
+    }
+    return classloader;
+  }
+
+  protected void setTableProperties(final CommandLine cl, final Shell shellState, final int priority, final Map<String,String> options, final String classname,
+      final String name) throws AccumuloException, AccumuloSecurityException, ShellCommandException, TableNotFoundException {
+    // remove empty values
+
+    final String tableName = OptUtil.getTableOpt(cl, shellState);
+
+    if (!shellState.getConnector().tableOperations().testClassLoad(tableName, classname, SortedKeyValueIterator.class.getName())) {
+      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Servers are unable to load " + classname + " as type "
+          + SortedKeyValueIterator.class.getName());
+    }
+
+    final String aggregatorClass = options.get("aggregatorClass");
+    @SuppressWarnings("deprecation")
+    String deprecatedAggregatorClassName = org.apache.accumulo.core.iterators.aggregation.Aggregator.class.getName();
+    if (aggregatorClass != null && !shellState.getConnector().tableOperations().testClassLoad(tableName, aggregatorClass, deprecatedAggregatorClassName)) {
+      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Servers are unable to load " + aggregatorClass + " as type "
+          + deprecatedAggregatorClassName);
+    }
+
+    for (Iterator<Entry<String,String>> i = options.entrySet().iterator(); i.hasNext();) {
+      final Entry<String,String> entry = i.next();
+      if (entry.getValue() == null || entry.getValue().isEmpty()) {
+        i.remove();
+      }
+    }
+    final EnumSet<IteratorScope> scopes = EnumSet.noneOf(IteratorScope.class);
+    if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(mincScopeOpt.getOpt())) {
+      scopes.add(IteratorScope.minc);
+    }
+    if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(majcScopeOpt.getOpt())) {
+      scopes.add(IteratorScope.majc);
+    }
+    if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(scanScopeOpt.getOpt())) {
+      scopes.add(IteratorScope.scan);
+    }
+    if (scopes.isEmpty()) {
+      throw new IllegalArgumentException("You must select at least one scope to configure");
+    }
+    final IteratorSetting setting = new IteratorSetting(priority, name, classname, options);
+    shellState.getConnector().tableOperations().attachIterator(tableName, setting, scopes);
+  }
+
+  protected void setNamespaceProperties(final CommandLine cl, final Shell shellState, final int priority, final Map<String,String> options,
+      final String classname, final String name) throws AccumuloException, AccumuloSecurityException, ShellCommandException, NamespaceNotFoundException {
+    // remove empty values
+
+    final String namespace = OptUtil.getNamespaceOpt(cl, shellState);
+
+    if (!shellState.getConnector().namespaceOperations().testClassLoad(namespace, classname, SortedKeyValueIterator.class.getName())) {
+      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Servers are unable to load " + classname + " as type "
+          + SortedKeyValueIterator.class.getName());
+    }
+
+    final String aggregatorClass = options.get("aggregatorClass");
+    @SuppressWarnings("deprecation")
+    String deprecatedAggregatorClassName = org.apache.accumulo.core.iterators.aggregation.Aggregator.class.getName();
+    if (aggregatorClass != null && !shellState.getConnector().namespaceOperations().testClassLoad(namespace, aggregatorClass, deprecatedAggregatorClassName)) {
+      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Servers are unable to load " + aggregatorClass + " as type "
+          + deprecatedAggregatorClassName);
+    }
+
+    for (Iterator<Entry<String,String>> i = options.entrySet().iterator(); i.hasNext();) {
+      final Entry<String,String> entry = i.next();
+      if (entry.getValue() == null || entry.getValue().isEmpty()) {
+        i.remove();
+      }
+    }
+    final EnumSet<IteratorScope> scopes = EnumSet.noneOf(IteratorScope.class);
+    if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(mincScopeOpt.getOpt())) {
+      scopes.add(IteratorScope.minc);
+    }
+    if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(majcScopeOpt.getOpt())) {
+      scopes.add(IteratorScope.majc);
+    }
+    if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(scanScopeOpt.getOpt())) {
+      scopes.add(IteratorScope.scan);
+    }
+    if (scopes.isEmpty()) {
+      throw new IllegalArgumentException("You must select at least one scope to configure");
+    }
+    final IteratorSetting setting = new IteratorSetting(priority, name, classname, options);
+    shellState.getConnector().namespaceOperations().attachIterator(namespace, setting, scopes);
+  }
+
+  private static String setUpOptions(ClassLoader classloader, final ConsoleReader reader, final String className, final Map<String,String> options)
+      throws IOException, ShellCommandException {
+    String input;
+    @SuppressWarnings("rawtypes")
+    SortedKeyValueIterator untypedInstance;
+    @SuppressWarnings("rawtypes")
+    Class<? extends SortedKeyValueIterator> clazz;
+    try {
+      clazz = classloader.loadClass(className).asSubclass(SortedKeyValueIterator.class);
+      untypedInstance = clazz.newInstance();
+    } catch (ClassNotFoundException e) {
+      StringBuilder msg = new StringBuilder("Unable to load ").append(className);
+      if (className.indexOf('.') < 0) {
+        msg.append("; did you use a fully qualified package name?");
+      } else {
+        msg.append("; class not found.");
+      }
+      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, msg.toString());
+    } catch (InstantiationException e) {
+      throw new IllegalArgumentException(e.getMessage());
+    } catch (IllegalAccessException e) {
+      throw new IllegalArgumentException(e.getMessage());
+    } catch (ClassCastException e) {
+      StringBuilder msg = new StringBuilder(50);
+      msg.append(className).append(" loaded successfully but does not implement SortedKeyValueIterator.");
+      msg.append(" This class cannot be used with this command.");
+      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, msg.toString());
+    }
+
+    @SuppressWarnings("unchecked")
+    SortedKeyValueIterator<Key,Value> skvi = (SortedKeyValueIterator<Key,Value>) untypedInstance;
+    OptionDescriber iterOptions = null;
+    if (OptionDescriber.class.isAssignableFrom(skvi.getClass())) {
+      iterOptions = (OptionDescriber) skvi;
+    }
+
+    String iteratorName;
+    if (null != iterOptions) {
+      final IteratorOptions itopts = iterOptions.describeOptions();
+      iteratorName = itopts.getName();
+      
+      if (iteratorName == null) {
+        throw new IllegalArgumentException(className + " described its default distinguishing name as null");
+      }
+      String shortClassName = className;
+      if (className.contains(".")) {
+        shortClassName = className.substring(className.lastIndexOf('.') + 1);
+      }
+      final Map<String,String> localOptions = new HashMap<String,String>();
+      do {
+        // clean up the overall options that caused things to fail
+        for (String key : localOptions.keySet()) {
+          options.remove(key);
+        }
+        localOptions.clear();
+  
+        reader.println(itopts.getDescription());
+  
+        String prompt;
+        if (itopts.getNamedOptions() != null) {
+          for (Entry<String,String> e : itopts.getNamedOptions().entrySet()) {
+            prompt = Shell.repeat("-", 10) + "> set " + shortClassName + " parameter " + e.getKey() + ", " + e.getValue() + ": ";
+            reader.flush();
+            input = reader.readLine(prompt);
+            if (input == null) {
+              reader.println();
+              throw new IOException("Input stream closed");
+            }
+            // Places all Parameters and Values into the LocalOptions, even if the value is "".
+            // This allows us to check for "" values when setting the iterators and allows us to remove
+            // the parameter and value from the table property.
+            localOptions.put(e.getKey(), input);
+          }
+        }
+  
+        if (itopts.getUnnamedOptionDescriptions() != null) {
+          for (String desc : itopts.getUnnamedOptionDescriptions()) {
+            reader.println(Shell.repeat("-", 10) + "> entering options: " + desc);
+            input = "start";
+            prompt = Shell.repeat("-", 10) + "> set " + shortClassName + " option (<name> <value>, hit enter to skip): ";
+            while (true) {
+              reader.flush();
+              input = reader.readLine(prompt);
+              if (input == null) {
+                reader.println();
+                throw new IOException("Input stream closed");
+              } else {
+                input = new String(input);
+              }
+  
+              if (input.length() == 0)
+                break;
+  
+              String[] sa = input.split(" ", 2);
+              localOptions.put(sa[0], sa[1]);
+            }
+          }
+        }
+  
+        options.putAll(localOptions);
+        if (!iterOptions.validateOptions(options))
+          reader.println("invalid options for " + clazz.getName());
+  
+      } while (!iterOptions.validateOptions(options));
+    } else {
+      reader.flush();
+      reader.println("The iterator class does not implement OptionDescriber. Consider this for better iterator configuration using this setiter command.");
+      iteratorName = reader.readLine("Name for iterator (enter to skip): ");
+      if (null == iteratorName) {
+        reader.println();
+        throw new IOException("Input stream closed");
+      } else if (StringUtils.isWhitespace(iteratorName)) {
+        // Treat whitespace or empty string as no name provided
+        iteratorName = null;
+      }
+      
+      reader.flush();
+      reader.println("Optional, configure name-value options for iterator:");
+      String prompt = Shell.repeat("-", 10) + "> set option (<name> <value>, hit enter to skip): ";
+      final HashMap<String,String> localOptions = new HashMap<String,String>();
+      
+      while (true) {
+        reader.flush();
+        input = reader.readLine(prompt);
+        if (input == null) {
+          reader.println();
+          throw new IOException("Input stream closed");
+        } else if (StringUtils.isWhitespace(input)) {
+          break;
+        } 
+
+        String[] sa = input.split(" ", 2);
+        localOptions.put(sa[0], sa[1]);
+      }
+      
+      options.putAll(localOptions);
+    }
+    
+    return iteratorName;
+  }
+
+  @Override
+  public String description() {
+    return "sets a table-specific or namespace-specific iterator";
+  }
+
+  @Override
+  public Options getOptions() {
+    final Options o = new Options();
+
+    priorityOpt = new Option("p", "priority", true, "the order in which the iterator is applied");
+    priorityOpt.setArgName("pri");
+    priorityOpt.setRequired(true);
+
+    nameOpt = new Option("n", "name", true, "iterator to set");
+    nameOpt.setArgName("itername");
+
+    allScopeOpt = new Option("all", "all-scopes", false, "applied at scan time, minor and major compactions");
+    mincScopeOpt = new Option(IteratorScope.minc.name(), "minor-compaction", false, "applied at minor compaction");
+    majcScopeOpt = new Option(IteratorScope.majc.name(), "major-compaction", false, "applied at major compaction");
+    scanScopeOpt = new Option(IteratorScope.scan.name(), "scan-time", false, "applied at scan time");
+
+    final OptionGroup typeGroup = new OptionGroup();
+    classnameTypeOpt = new Option("class", "class-name", true, "a java class that implements SortedKeyValueIterator");
+    classnameTypeOpt.setArgName("name");
+    aggTypeOpt = new Option("agg", "aggregator", false, "an aggregating type");
+    regexTypeOpt = new Option("regex", "regular-expression", false, "a regex matching iterator");
+    versionTypeOpt = new Option("vers", "version", false, "a versioning iterator");
+    reqvisTypeOpt = new Option("reqvis", "require-visibility", false, "an iterator that omits entries with empty visibilities");
+    ageoffTypeOpt = new Option("ageoff", "ageoff", false, "an aging off iterator");
+
+    typeGroup.addOption(classnameTypeOpt);
+    typeGroup.addOption(aggTypeOpt);
+    typeGroup.addOption(regexTypeOpt);
+    typeGroup.addOption(versionTypeOpt);
+    typeGroup.addOption(reqvisTypeOpt);
+    typeGroup.addOption(ageoffTypeOpt);
+    typeGroup.setRequired(true);
+
+    final OptionGroup tableGroup = new OptionGroup();
+    tableGroup.addOption(OptUtil.tableOpt("table to configure iterators on"));
+    tableGroup.addOption(OptUtil.namespaceOpt("namespace to configure iterators on"));
+
+    o.addOption(priorityOpt);
+    o.addOption(nameOpt);
+    o.addOption(allScopeOpt);
+    o.addOption(mincScopeOpt);
+    o.addOption(majcScopeOpt);
+    o.addOption(scanScopeOpt);
+    o.addOptionGroup(typeGroup);
+    o.addOptionGroup(tableGroup);
+    return o;
+  }
+
+  @Override
+  public int numArgs() {
+    return 0;
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/SetScanIterCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/SetScanIterCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/SetScanIterCommand.java
new file mode 100644
index 0000000..3ae42dd
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/SetScanIterCommand.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.shell.commands;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
+import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.shell.Shell;
+import org.apache.accumulo.shell.ShellCommandException;
+import org.apache.accumulo.shell.ShellCommandException.ErrorCode;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
+
+public class SetScanIterCommand extends SetIterCommand {
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
+      IOException, ShellCommandException {
+    Shell.log.warn("Deprecated, use " + new SetShellIterCommand().getName());
+    return super.execute(fullCommand, cl, shellState);
+  }
+  
+  @Override
+  protected void setTableProperties(final CommandLine cl, final Shell shellState, final int priority, final Map<String,String> options, final String classname,
+      final String name) throws AccumuloException, AccumuloSecurityException, ShellCommandException, TableNotFoundException {
+    
+    final String tableName = OptUtil.getTableOpt(cl, shellState);
+
+    // instead of setting table properties, just put the options in a list to use at scan time
+    Class<?> loadClass;
+    try {
+      loadClass = getClass().getClassLoader().loadClass(classname);
+    } catch (ClassNotFoundException e) {
+      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Unable to load " + classname);
+    }
+    try {
+      loadClass.asSubclass(SortedKeyValueIterator.class);
+    } catch (ClassCastException ex) {
+      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Unable to load " + classname  + " as type "
+          + SortedKeyValueIterator.class.getName());
+    }
+    
+    for (Iterator<Entry<String,String>> i = options.entrySet().iterator(); i.hasNext();) {
+      final Entry<String,String> entry = i.next();
+      if (entry.getValue() == null || entry.getValue().isEmpty()) {
+        i.remove();
+      }
+    }
+
+    List<IteratorSetting> tableScanIterators = shellState.scanIteratorOptions.get(tableName);
+    if (tableScanIterators == null) {
+      tableScanIterators = new ArrayList<IteratorSetting>();
+      shellState.scanIteratorOptions.put(tableName, tableScanIterators);
+    }
+    final IteratorSetting setting = new IteratorSetting(priority, name, classname);
+    setting.addOptions(options);
+    
+    // initialize a scanner to ensure the new setting does not conflict with existing settings
+    final String user = shellState.getConnector().whoami();
+    final Authorizations auths = shellState.getConnector().securityOperations().getUserAuthorizations(user);
+    final Scanner scanner = shellState.getConnector().createScanner(tableName, auths);
+    for (IteratorSetting s : tableScanIterators) {
+      scanner.addScanIterator(s);
+    }
+    scanner.addScanIterator(setting);
+    
+    // if no exception has been thrown, it's safe to add it to the list
+    tableScanIterators.add(setting);
+    Shell.log.debug("Scan iterators :" + shellState.scanIteratorOptions.get(tableName));
+  }
+  
+  @Override
+  public String description() {
+    return "sets a table-specific scan iterator for this shell session";
+  }
+  
+  @Override
+  public Options getOptions() {
+    // Remove the options that specify which type of iterator this is, since
+    // they are all scan iterators with this command.
+    final HashSet<OptionGroup> groups = new HashSet<OptionGroup>();
+    final Options parentOptions = super.getOptions();
+    final Options modifiedOptions = new Options();
+    for (Iterator<?> it = parentOptions.getOptions().iterator(); it.hasNext();) {
+      Option o = (Option) it.next();
+      if (!IteratorScope.majc.name().equals(o.getOpt()) && !IteratorScope.minc.name().equals(o.getOpt()) && !IteratorScope.scan.name().equals(o.getOpt())) {
+        modifiedOptions.addOption(o);
+        OptionGroup group = parentOptions.getOptionGroup(o);
+        if (group != null)
+          groups.add(group);
+      }
+    }
+    for (OptionGroup group : groups) {
+      modifiedOptions.addOptionGroup(group);
+    }
+    return modifiedOptions;
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/SetShellIterCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/SetShellIterCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/SetShellIterCommand.java
new file mode 100644
index 0000000..c7fea56
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/SetShellIterCommand.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.shell.commands;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
+import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
+import org.apache.accumulo.shell.Shell;
+import org.apache.accumulo.shell.ShellCommandException;
+import org.apache.accumulo.shell.ShellCommandException.ErrorCode;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
+
+public class SetShellIterCommand extends SetIterCommand {
+  private Option profileOpt;
+
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException,
+      TableNotFoundException, IOException, ShellCommandException {
+    return super.execute(fullCommand, cl, shellState);
+  }
+  
+  @Override
+  protected void setTableProperties(final CommandLine cl, final Shell shellState, final int priority, final Map<String,String> options, final String classname,
+      final String name) throws AccumuloException, AccumuloSecurityException, ShellCommandException, TableNotFoundException {
+    // instead of setting table properties, just put the options in a list to use at scan time
+    
+    String profile = cl.getOptionValue(profileOpt.getOpt());
+
+    // instead of setting table properties, just put the options in a list to use at scan time
+    Class<?> loadClass;
+    try {
+      loadClass = getClass().getClassLoader().loadClass(classname);
+    } catch (ClassNotFoundException e) {
+      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Unable to load " + classname);
+    }
+    try {
+      loadClass.asSubclass(SortedKeyValueIterator.class);
+    } catch (ClassCastException ex) {
+      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "xUnable to load " + classname  + " as type "
+          + SortedKeyValueIterator.class.getName());
+    }
+    
+    for (Iterator<Entry<String,String>> i = options.entrySet().iterator(); i.hasNext();) {
+      final Entry<String,String> entry = i.next();
+      if (entry.getValue() == null || entry.getValue().isEmpty()) {
+        i.remove();
+      }
+    }
+
+    List<IteratorSetting> tableScanIterators = shellState.iteratorProfiles.get(profile);
+    if (tableScanIterators == null) {
+      tableScanIterators = new ArrayList<IteratorSetting>();
+      shellState.iteratorProfiles.put(profile, tableScanIterators);
+    }
+    final IteratorSetting setting = new IteratorSetting(priority, name, classname);
+    setting.addOptions(options);
+
+    Iterator<IteratorSetting> iter = tableScanIterators.iterator();
+    while (iter.hasNext()) {
+      if (iter.next().getName().equals(name)) {
+        iter.remove();
+      }
+    }
+
+    tableScanIterators.add(setting);
+  }
+  
+  @Override
+  public String description() {
+    return "adds an iterator to a profile for this shell session";
+  }
+  
+  @Override
+  public Options getOptions() {
+    // Remove the options that specify which type of iterator this is, since
+    // they are all scan iterators with this command.
+    final HashSet<OptionGroup> groups = new HashSet<OptionGroup>();
+    final Options parentOptions = super.getOptions();
+    final Options modifiedOptions = new Options();
+    for (Iterator<?> it = parentOptions.getOptions().iterator(); it.hasNext();) {
+      Option o = (Option) it.next();
+      if (!IteratorScope.majc.name().equals(o.getOpt()) && !IteratorScope.minc.name().equals(o.getOpt()) && !IteratorScope.scan.name().equals(o.getOpt())
+          && !"table".equals(o.getLongOpt())) {
+        modifiedOptions.addOption(o);
+        OptionGroup group = parentOptions.getOptionGroup(o);
+        if (group != null)
+          groups.add(group);
+      }
+    }
+    for (OptionGroup group : groups) {
+      modifiedOptions.addOptionGroup(group);
+    }
+    
+    profileOpt = new Option("pn", "profile", true, "iterator profile name");
+    profileOpt.setRequired(true);
+    profileOpt.setArgName("profile");
+    
+    modifiedOptions.addOption(profileOpt);
+
+    return modifiedOptions;
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/ShellPluginConfigurationCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/ShellPluginConfigurationCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/ShellPluginConfigurationCommand.java
new file mode 100644
index 0000000..45d48e7
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/ShellPluginConfigurationCommand.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.shell.commands;
+
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.shell.Shell;
+import org.apache.accumulo.shell.Shell.Command;
+import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.commons.cli.Options;
+import org.apache.log4j.Logger;
+
+public abstract class ShellPluginConfigurationCommand extends Command {
+  private Option removePluginOption, pluginClassOption, listPluginOption;
+  
+  private String pluginType;
+  
+  private Property tableProp;
+  
+  private String classOpt;
+  
+  ShellPluginConfigurationCommand(final String typeName, final Property tableProp, final String classOpt) {
+    this.pluginType = typeName;
+    this.tableProp = tableProp;
+    this.classOpt = classOpt;
+  }
+
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    final String tableName = OptUtil.getTableOpt(cl, shellState);
+    
+    if (cl.hasOption(removePluginOption.getOpt())) {
+      // Remove the property
+      removePlugin(cl, shellState, tableName);
+      
+      shellState.getReader().println("Removed "+pluginType+" on " + tableName);
+    } else if (cl.hasOption(listPluginOption.getOpt())) {
+      // Get the options for this table
+      final Iterator<Entry<String,String>> iter = shellState.getConnector().tableOperations().getProperties(tableName).iterator();
+      
+      while (iter.hasNext()) {
+        Entry<String,String> ent = iter.next();
+        
+        // List all parameters with the property name
+        if (ent.getKey().startsWith(tableProp.toString())) {
+          shellState.getReader().println(ent.getKey() + ": " + ent.getValue());
+        }
+      }
+    } else {
+      // Set the plugin with the provided options
+      String className = cl.getOptionValue(pluginClassOption.getOpt());
+      
+      // Set the plugin property on the table
+      setPlugin(cl, shellState, tableName, className);
+    }
+    
+    return 0;
+  }
+
+  protected void setPlugin(final CommandLine cl, final Shell shellState, final String tableName, final String className) throws AccumuloException, AccumuloSecurityException {
+    shellState.getConnector().tableOperations().setProperty(tableName, tableProp.toString(), className);
+  }
+  
+  protected void removePlugin(final CommandLine cl, final Shell shellState, final String tableName) throws AccumuloException, AccumuloSecurityException {
+    shellState.getConnector().tableOperations().removeProperty(tableName, tableProp.toString());
+  }
+  
+  public static <T> Class<? extends T> getPluginClass(final String tableName, final Shell shellState, final Class<T> clazz, final Property pluginProp) {
+    Iterator<Entry<String,String>> props;
+    try {
+      props = shellState.getConnector().tableOperations().getProperties(tableName).iterator();
+    } catch (AccumuloException e) {
+      return null;
+    } catch (TableNotFoundException e) {
+      return null;
+    }
+    
+    while (props.hasNext()) {
+      final Entry<String,String> ent = props.next();
+      if (ent.getKey().equals(pluginProp.toString())) {
+        Class<? extends T> pluginClazz;
+        try {
+          pluginClazz = AccumuloVFSClassLoader.loadClass(ent.getValue(), clazz);
+        } catch (ClassNotFoundException e) {
+          Logger.getLogger(ShellPluginConfigurationCommand.class).warn("Class not found" + e.getMessage());
+          return null;
+        }
+        
+        return pluginClazz;
+      }
+    }
+    
+    return null;
+  }
+  
+  @Override
+  public Options getOptions() {
+    final Options o = new Options();
+    final OptionGroup actionGroup = new OptionGroup();
+    
+    pluginClassOption = new Option(classOpt, pluginType, true, "fully qualified name of the " + pluginType + " class to use");
+    pluginClassOption.setArgName("className");
+    
+    // Action to take: apply (default), remove, list
+    removePluginOption = new Option("r", "remove", false, "remove the current "+pluginType+"");
+    listPluginOption = new Option("l", "list", false, "display the current "+pluginType+"");
+    
+    actionGroup.addOption(pluginClassOption);
+    actionGroup.addOption(removePluginOption);
+    actionGroup.addOption(listPluginOption);
+    actionGroup.setRequired(true);
+    
+    o.addOptionGroup(actionGroup);
+    o.addOption(OptUtil.tableOpt("table to set the "+pluginType+" on"));
+    
+    return o;
+  }
+  
+  @Override
+  public int numArgs() {
+    return 0;
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/SleepCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/SleepCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/SleepCommand.java
new file mode 100644
index 0000000..1f7ed5d
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/SleepCommand.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.shell.commands;
+
+import org.apache.accumulo.shell.Shell;
+import org.apache.accumulo.shell.Shell.Command;
+import org.apache.commons.cli.CommandLine;
+
+public class SleepCommand extends Command {
+  
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    final double secs = Double.parseDouble(cl.getArgs()[0]);
+    Thread.sleep((long) (secs * 1000));
+    return 0;
+  }
+  
+  @Override
+  public String description() {
+    return "sleeps for the given number of seconds";
+  }
+  
+  @Override
+  public int numArgs() {
+    return 1;
+  }
+  
+  @Override
+  public String usage() {
+    return getName() + " <seconds>";
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/SystemPermissionsCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/SystemPermissionsCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/SystemPermissionsCommand.java
new file mode 100644
index 0000000..7cf4584
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/SystemPermissionsCommand.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.shell.commands;
+
+import java.io.IOException;
+
+import org.apache.accumulo.core.security.SystemPermission;
+import org.apache.accumulo.shell.Shell;
+import org.apache.accumulo.shell.Shell.Command;
+import org.apache.commons.cli.CommandLine;
+
+public class SystemPermissionsCommand extends Command {
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException {
+    for (String p : SystemPermission.printableValues()) {
+      shellState.getReader().println(p);
+    }
+    return 0;
+  }
+  
+  @Override
+  public String description() {
+    return "displays a list of valid system permissions";
+  }
+  
+  @Override
+  public int numArgs() {
+    return 0;
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/TableCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/TableCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/TableCommand.java
new file mode 100644
index 0000000..6a563ab
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/TableCommand.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.shell.commands;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.shell.Shell;
+import org.apache.accumulo.shell.Token;
+import org.apache.accumulo.shell.Shell.Command;
+import org.apache.commons.cli.CommandLine;
+
+public class TableCommand extends Command {
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
+    final String tableName = cl.getArgs()[0];
+    if (!shellState.getConnector().tableOperations().exists(tableName)) {
+      throw new TableNotFoundException(null, tableName, null);
+    }
+    shellState.setTableName(tableName);
+    return 0;
+  }
+  
+  @Override
+  public String description() {
+    return "switches to the specified table";
+  }
+  
+  @Override
+  public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> special) {
+    registerCompletionForTables(root, special);
+  }
+  
+  @Override
+  public String usage() {
+    return getName() + " <tableName>";
+  }
+  
+  @Override
+  public int numArgs() {
+    return 1;
+  }
+}


Mime
View raw message