You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2014/04/08 05:03:32 UTC

[36/53] [abbrv] ACCUMULO-1879 Move shell into new package and module

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/ImportDirectoryCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/ImportDirectoryCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/ImportDirectoryCommand.java
new file mode 100644
index 0000000..56c27c2
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/ImportDirectoryCommand.java
@@ -0,0 +1,58 @@
+/*
+ * 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.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.Shell.Command;
+import org.apache.commons.cli.CommandLine;
+
+public class ImportDirectoryCommand extends Command {
+  
+  @Override
+  public String description() {
+    return "bulk imports an entire directory of data files to the current table.  The boolean argument determines if accumulo sets the time.";
+  }
+  
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException, AccumuloException, AccumuloSecurityException,
+      TableNotFoundException {
+    shellState.checkTableState();
+    
+    String dir = cl.getArgs()[0];
+    String failureDir = cl.getArgs()[1];
+    final boolean setTime = Boolean.parseBoolean(cl.getArgs()[2]);
+
+    shellState.getConnector().tableOperations().importDirectory(shellState.getTableName(), dir, failureDir, setTime);
+    return 0;
+  }
+  
+  @Override
+  public int numArgs() {
+    return 3;
+  }
+  
+  @Override
+  public String usage() {
+    return getName() + " <directory> <failureDirectory> true|false";
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/ImportTableCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/ImportTableCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/ImportTableCommand.java
new file mode 100644
index 0000000..46c941f
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/ImportTableCommand.java
@@ -0,0 +1,51 @@
+/*
+ * 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.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.TableExistsException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.shell.Shell;
+import org.apache.accumulo.shell.Shell.Command;
+import org.apache.commons.cli.CommandLine;
+
+public class ImportTableCommand extends Command {
+  
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
+      TableExistsException {
+    
+    shellState.getConnector().tableOperations().importTable(cl.getArgs()[0], cl.getArgs()[1]);
+    return 0;
+  }
+  
+  @Override
+  public String usage() {
+    return getName() + " <table name> <import dir>";
+  }
+  
+  @Override
+  public String description() {
+    return "imports a table";
+  }
+  
+  @Override
+  public int numArgs() {
+    return 2;
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/InfoCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/InfoCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/InfoCommand.java
new file mode 100644
index 0000000..df5cfbb
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/InfoCommand.java
@@ -0,0 +1,19 @@
+/*
+ * 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;
+
+public class InfoCommand extends AboutCommand {}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/InsertCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/InsertCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/InsertCommand.java
new file mode 100644
index 0000000..19ae5b8
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/InsertCommand.java
@@ -0,0 +1,148 @@
+/*
+ * 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.Map.Entry;
+import java.util.Set;
+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.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.MutationsRejectedException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.client.security.SecurityErrorCode;
+import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.data.ConstraintViolationSummary;
+import org.apache.accumulo.core.data.KeyExtent;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.security.ColumnVisibility;
+import org.apache.accumulo.core.tabletserver.thrift.ConstraintViolationException;
+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.Options;
+import org.apache.hadoop.io.Text;
+
+public class InsertCommand extends Command {
+  private Option insertOptAuths, timestampOpt;
+  private Option timeoutOption;
+  
+  protected long getTimeout(final CommandLine cl) {
+    if (cl.hasOption(timeoutOption.getLongOpt())) {
+      return AccumuloConfiguration.getTimeInMillis(cl.getOptionValue(timeoutOption.getLongOpt()));
+    }
+    
+    return Long.MAX_VALUE;
+  }
+  
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException,
+      TableNotFoundException, IOException, ConstraintViolationException {
+    shellState.checkTableState();
+    
+    final Mutation m = new Mutation(new Text(cl.getArgs()[0].getBytes(Shell.CHARSET)));
+    final Text colf = new Text(cl.getArgs()[1].getBytes(Shell.CHARSET));
+    final Text colq = new Text(cl.getArgs()[2].getBytes(Shell.CHARSET));
+    final Value val = new Value(cl.getArgs()[3].getBytes(Shell.CHARSET));
+    
+    if (cl.hasOption(insertOptAuths.getOpt())) {
+      final ColumnVisibility le = new ColumnVisibility(cl.getOptionValue(insertOptAuths.getOpt()));
+      Shell.log.debug("Authorization label will be set to: " + le.toString());
+      
+      if (cl.hasOption(timestampOpt.getOpt()))
+        m.put(colf, colq, le, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt())), val);
+      else
+        m.put(colf, colq, le, val);
+    } else if (cl.hasOption(timestampOpt.getOpt()))
+      m.put(colf, colq, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt())), val);
+    else
+      m.put(colf, colq, val);
+    
+    final BatchWriter bw = shellState.getConnector().createBatchWriter(shellState.getTableName(),
+        new BatchWriterConfig().setMaxMemory(Math.max(m.estimatedMemoryUsed(), 1024)).setMaxWriteThreads(1).setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS));
+    bw.addMutation(m);
+    try {
+      bw.close();
+    } catch (MutationsRejectedException e) {
+      final ArrayList<String> lines = new ArrayList<String>();
+      if (e.getAuthorizationFailuresMap().isEmpty() == false) {
+        lines.add("	Authorization Failures:");
+      }
+      for (Entry<KeyExtent,Set<SecurityErrorCode>> entry : e.getAuthorizationFailuresMap().entrySet()) {
+        lines.add("		" + entry);
+      }
+      if (e.getConstraintViolationSummaries().isEmpty() == false) {
+        lines.add("	Constraint Failures:");
+      }
+      for (ConstraintViolationSummary cvs : e.getConstraintViolationSummaries()) {
+        lines.add("		" + cvs.toString());
+      }
+      
+      if (lines.size() == 0 || e.getUnknownExceptions() > 0) {
+        // must always print something
+        lines.add(" " + e.getClass().getName() + " : " + e.getMessage());
+        if (e.getCause() != null)
+          lines.add("   Caused by : " + e.getCause().getClass().getName() + " : " + e.getCause().getMessage());
+      }
+      
+      shellState.printLines(lines.iterator(), false);
+      
+      return 1;
+    }
+    return 0;
+  }
+  
+  @Override
+  public String description() {
+    return "inserts a record";
+  }
+  
+  @Override
+  public String usage() {
+    return getName() + " <row> <colfamily> <colqualifier> <value>";
+  }
+  
+  @Override
+  public Options getOptions() {
+    final Options o = new Options();
+    insertOptAuths = new Option("l", "visibility-label", true, "formatted visibility");
+    insertOptAuths.setArgName("expression");
+    o.addOption(insertOptAuths);
+    
+    timestampOpt = new Option("ts", "timestamp", true, "timestamp to use for insert");
+    timestampOpt.setArgName("timestamp");
+    o.addOption(timestampOpt);
+    
+    timeoutOption = new Option(null, "timeout", true,
+        "time before insert should fail if no data is written. If no unit is given assumes seconds.  Units d,h,m,s,and ms are supported.  e.g. 30s or 100ms");
+    timeoutOption.setArgName("timeout");
+    o.addOption(timeoutOption);
+    
+    return o;
+  }
+  
+  @Override
+  public int numArgs() {
+    return 4;
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/InterpreterCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/InterpreterCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/InterpreterCommand.java
new file mode 100644
index 0000000..9d79601
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/InterpreterCommand.java
@@ -0,0 +1,40 @@
+/*
+ * 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.core.conf.Property;
+import org.apache.accumulo.core.util.interpret.ScanInterpreter;
+import org.apache.accumulo.shell.Shell;
+
+/**
+ * 
+ */
+public class InterpreterCommand extends ShellPluginConfigurationCommand {
+  
+  public InterpreterCommand() {
+    super("interpreter", Property.TABLE_INTERPRETER_CLASS, "i");
+  }
+  
+  @Override
+  public String description() {
+    return "specifies a scan interpreter to interpret scan range and column arguments";
+  }
+  
+  public static Class<? extends ScanInterpreter> getCurrentInterpreter(final String tableName, final Shell shellState) {
+    return ShellPluginConfigurationCommand.getPluginClass(tableName, shellState, ScanInterpreter.class, Property.TABLE_INTERPRETER_CLASS);
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/ListCompactionsCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/ListCompactionsCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/ListCompactionsCommand.java
new file mode 100644
index 0000000..809ef8c
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/ListCompactionsCommand.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.ArrayList;
+import java.util.List;
+
+import org.apache.accumulo.core.client.admin.InstanceOperations;
+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.Options;
+
+public class ListCompactionsCommand extends Command {
+  
+  private Option tserverOption, disablePaginationOpt;
+  
+  @Override
+  public String description() {
+    return "lists what compactions are currently running in accumulo. See the accumulo.core.client.admin.ActiveCompaciton javadoc for more information about columns.";
+  }
+  
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    
+    List<String> tservers;
+    
+    final InstanceOperations instanceOps = shellState.getConnector().instanceOperations();
+    
+    final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt());
+    
+    if (cl.hasOption(tserverOption.getOpt())) {
+      tservers = new ArrayList<String>();
+      tservers.add(cl.getOptionValue(tserverOption.getOpt()));
+    } else {
+      tservers = instanceOps.getTabletServers();
+    }
+    
+    shellState.printLines(new ActiveCompactionIterator(tservers, instanceOps), paginate);
+    
+    return 0;
+  }
+  
+  @Override
+  public int numArgs() {
+    return 0;
+  }
+  
+  @Override
+  public Options getOptions() {
+    final Options opts = new Options();
+    
+    tserverOption = new Option("ts", "tabletServer", true, "tablet server to list compactions for");
+    tserverOption.setArgName("tablet server");
+    opts.addOption(tserverOption);
+    
+    disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output");
+    opts.addOption(disablePaginationOpt);
+    
+    return opts;
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/ListIterCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/ListIterCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/ListIterCommand.java
new file mode 100644
index 0000000..fcebd1f
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/ListIterCommand.java
@@ -0,0 +1,140 @@
+/*
+ * 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.EnumMap;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
+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 ListIterCommand extends Command {
+  private Option nameOpt, allScopesOpt;
+  private Map<IteratorScope,Option> scopeOpts;
+
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+
+    boolean tables = cl.hasOption(OptUtil.tableOpt().getOpt()) || !shellState.getTableName().isEmpty();
+    boolean namespaces = cl.hasOption(OptUtil.namespaceOpt().getOpt());
+
+    final Map<String,EnumSet<IteratorScope>> iterators;
+    if (namespaces) {
+      iterators = shellState.getConnector().namespaceOperations().listIterators(OptUtil.getNamespaceOpt(cl, shellState));
+    } else if (tables) {
+      iterators = shellState.getConnector().tableOperations().listIterators(OptUtil.getTableOpt(cl, shellState));
+    } else {
+      throw new IllegalArgumentException("No table or namespace specified");
+    }
+
+    if (cl.hasOption(nameOpt.getOpt())) {
+      final String name = cl.getOptionValue(nameOpt.getOpt());
+      if (!iterators.containsKey(name)) {
+        Shell.log.warn("no iterators found that match your criteria");
+        return 0;
+      }
+      final EnumSet<IteratorScope> scopes = iterators.get(name);
+      iterators.clear();
+      iterators.put(name, scopes);
+    }
+
+    final boolean allScopes = cl.hasOption(allScopesOpt.getOpt());
+    Set<IteratorScope> desiredScopes = new HashSet<IteratorScope>();
+    for (IteratorScope scope : IteratorScope.values()) {
+      if (allScopes || cl.hasOption(scopeOpts.get(scope).getOpt()))
+        desiredScopes.add(scope);
+    }
+    if (desiredScopes.isEmpty()) {
+      throw new IllegalArgumentException("You must select at least one scope to configure");
+    }
+    final StringBuilder sb = new StringBuilder("-\n");
+    for (Entry<String,EnumSet<IteratorScope>> entry : iterators.entrySet()) {
+      final String name = entry.getKey();
+      final EnumSet<IteratorScope> scopes = entry.getValue();
+      for (IteratorScope scope : scopes) {
+        if (desiredScopes.contains(scope)) {
+          IteratorSetting setting;
+          if (namespaces) {
+            setting = shellState.getConnector().namespaceOperations().getIteratorSetting(OptUtil.getNamespaceOpt(cl, shellState), name, scope);
+          } else if (tables) {
+            setting = shellState.getConnector().tableOperations().getIteratorSetting(OptUtil.getTableOpt(cl, shellState), name, scope);
+          } else {
+            throw new IllegalArgumentException("No table or namespace specified");
+          }
+          sb.append("-    Iterator ").append(setting.getName()).append(", ").append(scope).append(" scope options:\n");
+          sb.append("-        ").append("iteratorPriority").append(" = ").append(setting.getPriority()).append("\n");
+          sb.append("-        ").append("iteratorClassName").append(" = ").append(setting.getIteratorClass()).append("\n");
+          for (Entry<String,String> optEntry : setting.getOptions().entrySet()) {
+            sb.append("-        ").append(optEntry.getKey()).append(" = ").append(optEntry.getValue()).append("\n");
+          }
+        }
+      }
+    }
+    sb.append("-");
+    shellState.getReader().println(sb.toString());
+
+    return 0;
+  }
+
+  @Override
+  public String description() {
+    return "lists table-specific or namespace-specific iterators configured in this shell session";
+  }
+
+  @Override
+  public int numArgs() {
+    return 0;
+  }
+
+  @Override
+  public Options getOptions() {
+    final Options o = new Options();
+
+    nameOpt = new Option("n", "name", true, "iterator to list");
+    nameOpt.setArgName("itername");
+
+    allScopesOpt = new Option("all", "all-scopes", false, "list from all scopes");
+    o.addOption(allScopesOpt);
+    
+    scopeOpts = new EnumMap<IteratorScope,Option>(IteratorScope.class);
+    scopeOpts.put(IteratorScope.minc, new Option(IteratorScope.minc.name(), "minor-compaction", false, "list iterator for minor compaction scope"));
+    scopeOpts.put(IteratorScope.majc, new Option(IteratorScope.majc.name(), "major-compaction", false, "list iterator for major compaction scope"));
+    scopeOpts.put(IteratorScope.scan, new Option(IteratorScope.scan.name(), "scan-time", false, "list iterator for scan scope"));
+
+    OptionGroup grp = new OptionGroup();
+    grp.addOption(OptUtil.tableOpt("table to list the configured iterators on"));
+    grp.addOption(OptUtil.namespaceOpt("namespace to list the configured iterators on"));
+    o.addOptionGroup(grp);
+    o.addOption(nameOpt);
+
+    for (Option opt : scopeOpts.values()) {
+      o.addOption(opt);
+    }
+
+    return o;
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/ListScansCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/ListScansCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/ListScansCommand.java
new file mode 100644
index 0000000..598503e
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/ListScansCommand.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.ArrayList;
+import java.util.List;
+
+import org.apache.accumulo.core.client.admin.InstanceOperations;
+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.Options;
+
+public class ListScansCommand extends Command {
+  
+  private Option tserverOption, disablePaginationOpt;
+  
+  @Override
+  public String description() {
+    return "lists what scans are currently running in accumulo. See the accumulo.core.client.admin.ActiveScan javadoc for more information about columns.";
+  }
+  
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    
+    List<String> tservers;
+    
+    final InstanceOperations instanceOps = shellState.getConnector().instanceOperations();
+    
+    final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt());
+    
+    if (cl.hasOption(tserverOption.getOpt())) {
+      tservers = new ArrayList<String>();
+      tservers.add(cl.getOptionValue(tserverOption.getOpt()));
+    } else {
+      tservers = instanceOps.getTabletServers();
+    }
+    
+    shellState.printLines(new ActiveScanIterator(tservers, instanceOps), paginate);
+    
+    return 0;
+  }
+  
+  @Override
+  public int numArgs() {
+    return 0;
+  }
+  
+  @Override
+  public Options getOptions() {
+    final Options opts = new Options();
+    
+    tserverOption = new Option("ts", "tabletServer", true, "tablet server to list scans for");
+    tserverOption.setArgName("tablet server");
+    opts.addOption(tserverOption);
+    
+    disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output");
+    opts.addOption(disablePaginationOpt);
+    
+    return opts;
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/ListShellIterCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/ListShellIterCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/ListShellIterCommand.java
new file mode 100644
index 0000000..59f8f46
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/ListShellIterCommand.java
@@ -0,0 +1,105 @@
+/*
+ * 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.List;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.apache.accumulo.core.client.IteratorSetting;
+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.Options;
+
+/**
+ * 
+ */
+public class ListShellIterCommand extends Command {
+  
+  private Option nameOpt, profileOpt;
+
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    if (shellState.iteratorProfiles.size() == 0)
+      return 0;
+    
+    final StringBuilder sb = new StringBuilder();
+
+    String profile = null;
+    if (cl.hasOption(profileOpt.getOpt()))
+      profile = cl.getOptionValue(profileOpt.getOpt());
+
+    String name = null;
+    if (cl.hasOption(nameOpt.getOpt()))
+      name = cl.getOptionValue(nameOpt.getOpt());
+
+    Set<Entry<String,List<IteratorSetting>>> es = shellState.iteratorProfiles.entrySet();
+    for (Entry<String,List<IteratorSetting>> entry : es) {
+      if (profile != null && !profile.equals(entry.getKey()))
+        continue;
+
+      sb.append("-\n");
+      sb.append("- Profile : " + entry.getKey() + "\n");
+      for (IteratorSetting setting : entry.getValue()) {
+        if (name != null && !name.equals(setting.getName()))
+          continue;
+
+        sb.append("-    Iterator ").append(setting.getName()).append(", ").append(" options:\n");
+        sb.append("-        ").append("iteratorPriority").append(" = ").append(setting.getPriority()).append("\n");
+        sb.append("-        ").append("iteratorClassName").append(" = ").append(setting.getIteratorClass()).append("\n");
+        for (Entry<String,String> optEntry : setting.getOptions().entrySet()) {
+          sb.append("-        ").append(optEntry.getKey()).append(" = ").append(optEntry.getValue()).append("\n");
+        }
+      }
+    }
+    
+    if (sb.length() > 0) {
+      sb.append("-\n");
+    }
+
+    shellState.getReader().print(sb.toString());
+
+    return 0;
+  }
+  
+  public String description() {
+    return "lists iterators profiles configured in shell";
+  }
+  
+  @Override
+  public int numArgs() {
+    return 0;
+  }
+  
+  @Override
+  public Options getOptions() {
+    final Options o = new Options();
+    
+    profileOpt = new Option("pn", "profile", true, "iterator profile name");
+    profileOpt.setArgName("profile");
+
+    nameOpt = new Option("n", "name", true, "iterator to list");
+    nameOpt.setArgName("itername");
+    
+    o.addOption(profileOpt);
+    o.addOption(nameOpt);
+
+    return o;
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/MaxRowCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/MaxRowCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/MaxRowCommand.java
new file mode 100644
index 0000000..1794b57
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/MaxRowCommand.java
@@ -0,0 +1,55 @@
+/*
+ * 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.core.data.Range;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.util.interpret.ScanInterpreter;
+import org.apache.accumulo.shell.Shell;
+import org.apache.commons.cli.CommandLine;
+import org.apache.hadoop.io.Text;
+
+public class MaxRowCommand extends ScanCommand {
+  
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    final String tableName = OptUtil.getTableOpt(cl, shellState);
+    
+    final ScanInterpreter interpeter = getInterpreter(cl, tableName, shellState);
+    
+    final Range range = getRange(cl, interpeter);
+    final Authorizations auths = getAuths(cl, shellState);
+    final Text startRow = range.getStartKey() == null ? null : range.getStartKey().getRow();
+    final Text endRow = range.getEndKey() == null ? null : range.getEndKey().getRow();
+    
+    try {
+      final Text max = shellState.getConnector().tableOperations()
+          .getMaxRow(tableName, auths, startRow, range.isStartKeyInclusive(), endRow, range.isEndKeyInclusive());
+      if (max != null) {
+        shellState.getReader().println(max.toString());
+      }
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+    
+    return 0;
+  }
+  
+  @Override
+  public String description() {
+    return "finds the max row in a table within a given range";
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/MergeCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/MergeCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/MergeCommand.java
new file mode 100644
index 0000000..33d63fa
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/MergeCommand.java
@@ -0,0 +1,111 @@
+/*
+ * 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.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.util.Merge;
+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.Options;
+import org.apache.hadoop.io.Text;
+
+public class MergeCommand extends Command {
+  private Option verboseOpt, forceOpt, sizeOpt, allOpt;
+  
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    boolean verbose = shellState.isVerbose();
+    boolean force = false;
+    boolean all = false;
+    long size = -1;
+    final String tableName = OptUtil.getTableOpt(cl, shellState);
+    final Text startRow = OptUtil.getStartRow(cl);
+    final Text endRow = OptUtil.getEndRow(cl);
+    if (cl.hasOption(verboseOpt.getOpt())) {
+      verbose = true;
+    }
+    if (cl.hasOption(forceOpt.getOpt())) {
+      force = true;
+    }
+    if (cl.hasOption(allOpt.getOpt())) {
+      all = true;
+    }
+    if (cl.hasOption(sizeOpt.getOpt())) {
+      size = AccumuloConfiguration.getMemoryInBytes(cl.getOptionValue(sizeOpt.getOpt()));
+    }
+    if (startRow == null && endRow == null && size < 0 && !all) {
+      shellState.getReader().flush();
+      String line = shellState.getReader().readLine("Merge the entire table { " + tableName + " } into one tablet (yes|no)? ");
+      if (line == null)
+        return 0;
+      if (!line.equalsIgnoreCase("y") && !line.equalsIgnoreCase("yes"))
+        return 0;
+    }
+    if (size < 0) {
+      shellState.getConnector().tableOperations().merge(tableName, startRow, endRow);
+    } else {
+      final boolean finalVerbose = verbose;
+      final Merge merge = new Merge() {
+        protected void message(String fmt, Object... args) {
+          if (finalVerbose) {
+            try {
+              shellState.getReader().println(String.format(fmt, args));
+            } catch (IOException ex) {
+              throw new RuntimeException(ex);
+            }
+          }
+        }
+      };
+      merge.mergomatic(shellState.getConnector(), tableName, startRow, endRow, size, force);
+    }
+    return 0;
+  }
+  
+  @Override
+  public String description() {
+    return "merges tablets in a table";
+  }
+  
+  @Override
+  public int numArgs() {
+    return 0;
+  }
+  
+  @Override
+  public Options getOptions() {
+    final Options o = new Options();
+    verboseOpt = new Option("v", "verbose", false, "verbose output during merge");
+    sizeOpt = new Option("s", "size", true, "merge tablets to the given size over the entire table");
+    forceOpt = new Option("f", "force", false, "merge small tablets to large tablets, even if it goes over the given size");
+    allOpt = new Option("", "all", false, "allow an entire table to be merged into one tablet without prompting the user for confirmation");
+    Option startRowOpt = OptUtil.startRowOpt();
+    startRowOpt.setDescription("begin row (NOT inclusive)");
+    o.addOption(startRowOpt);
+    o.addOption(OptUtil.endRowOpt());
+    o.addOption(OptUtil.tableOpt("table to be merged"));
+    o.addOption(verboseOpt);
+    o.addOption(sizeOpt);
+    o.addOption(forceOpt);
+    o.addOption(allOpt);
+    return o;
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/NamespacePermissionsCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/NamespacePermissionsCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/NamespacePermissionsCommand.java
new file mode 100644
index 0000000..99ba6ad
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/NamespacePermissionsCommand.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.NamespacePermission;
+import org.apache.accumulo.shell.Shell;
+import org.apache.accumulo.shell.Shell.Command;
+import org.apache.commons.cli.CommandLine;
+
+public class NamespacePermissionsCommand extends Command {
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException {
+    for (String p : NamespacePermission.printableValues()) {
+      shellState.getReader().println(p);
+    }
+    return 0;
+  }
+
+  @Override
+  public String description() {
+    return "displays a list of valid namespace 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/NamespacesCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/NamespacesCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/NamespacesCommand.java
new file mode 100644
index 0000000..d822cf6
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/NamespacesCommand.java
@@ -0,0 +1,83 @@
+/*
+ * 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.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.impl.Namespaces;
+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.Options;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterators;
+
+public class NamespacesCommand extends Command {
+  private Option disablePaginationOpt, namespaceIdOption;
+
+  private static final String DEFAULT_NAMESPACE_DISPLAY_NAME = "\"\"";
+
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException {
+    Map<String,String> namespaces = new TreeMap<String,String>(shellState.getConnector().namespaceOperations().namespaceIdMap());
+
+    Iterator<String> it = Iterators.transform(namespaces.entrySet().iterator(), new Function<Entry<String,String>,String>() {
+      @Override
+      public String apply(Map.Entry<String,String> entry) {
+        String name = entry.getKey();
+        if (Namespaces.DEFAULT_NAMESPACE.equals(name))
+          name = DEFAULT_NAMESPACE_DISPLAY_NAME;
+        String id = entry.getValue();
+        if (cl.hasOption(namespaceIdOption.getOpt()))
+          return String.format(TablesCommand.NAME_AND_ID_FORMAT, name, id);
+        else
+          return name;
+      };
+    });
+
+    shellState.printLines(it, !cl.hasOption(disablePaginationOpt.getOpt()));
+    return 0;
+  }
+
+  @Override
+  public String description() {
+    return "displays a list of all existing namespaces";
+  }
+
+  @Override
+  public Options getOptions() {
+    final Options o = new Options();
+    namespaceIdOption = new Option("l", "list-ids", false, "display internal namespace ids along with the name");
+    o.addOption(namespaceIdOption);
+    disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output");
+    o.addOption(disablePaginationOpt);
+    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/NoTableCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/NoTableCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/NoTableCommand.java
new file mode 100644
index 0000000..7ff6358
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/NoTableCommand.java
@@ -0,0 +1,40 @@
+/*
+ * 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 NoTableCommand extends Command {
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    shellState.setTableName("");
+    
+    return 0;
+  }
+  
+  @Override
+  public String description() {
+    return "returns to a tableless shell state";
+  }
+  
+  @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/OfflineCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/OfflineCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/OfflineCommand.java
new file mode 100644
index 0000000..6ac397c
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/OfflineCommand.java
@@ -0,0 +1,61 @@
+/*
+ * 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.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.metadata.MetadataTable;
+import org.apache.accumulo.shell.Shell;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+
+public class OfflineCommand extends TableOperation {
+  
+  private boolean wait;
+  private Option waitOpt;
+  
+  @Override
+  public String description() {
+    return "starts the process of taking table offline";
+  }
+  
+  protected void doTableOp(final Shell shellState, final String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
+    if (tableName.equals(MetadataTable.NAME)) {
+      Shell.log.info("  You cannot take the " + MetadataTable.NAME + " offline.");
+    } else {
+      shellState.getConnector().tableOperations().offline(tableName, wait);
+      Shell.log.info("Offline of table " + tableName + (wait ? " completed." : " initiated..."));
+    }
+  }
+  
+  
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    wait = cl.hasOption(waitOpt.getLongOpt());
+    return super.execute(fullCommand, cl, shellState);
+  }
+  
+  @Override
+  public Options getOptions() {
+    final Options opts = super.getOptions();
+    waitOpt = new Option("w", "wait", false, "wait for offline to finish");
+    opts.addOption(waitOpt); 
+    return opts;
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/OnlineCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/OnlineCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/OnlineCommand.java
new file mode 100644
index 0000000..ace069f
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/OnlineCommand.java
@@ -0,0 +1,61 @@
+/*
+ * 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.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.metadata.RootTable;
+import org.apache.accumulo.shell.Shell;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+
+public class OnlineCommand extends TableOperation {
+  
+  private boolean wait;
+  private Option waitOpt;
+  
+  @Override
+  public String description() {
+    return "starts the process of putting a table online";
+  }
+  
+  @Override
+  protected void doTableOp(final Shell shellState, final String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
+    if (tableName.equals(RootTable.NAME)) {
+      Shell.log.info("  The " + RootTable.NAME + " is always online.");
+    } else {
+      shellState.getConnector().tableOperations().online(tableName, wait);
+      Shell.log.info("Online of table " + tableName + (wait ? " completed." : " initiated..."));
+    }
+  }
+  
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    wait = cl.hasOption(waitOpt.getLongOpt());
+    return super.execute(fullCommand, cl, shellState);
+  }
+  
+  @Override
+  public Options getOptions() {
+    final Options opts = super.getOptions();
+    waitOpt = new Option("w", "wait", false, "wait for online to finish");
+    opts.addOption(waitOpt); 
+    return opts;
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/OptUtil.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/OptUtil.java b/shell/src/main/java/org/apache/accumulo/shell/commands/OptUtil.java
new file mode 100644
index 0000000..6243761
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/OptUtil.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.io.UnsupportedEncodingException;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.NamespaceNotFoundException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.shell.Shell;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionGroup;
+import org.apache.hadoop.io.Text;
+
+public abstract class OptUtil {
+  public static final String START_ROW_OPT = "b";
+  public static final String END_ROW_OPT = "e";
+
+  public static String getTableOpt(final CommandLine cl, final Shell shellState) throws TableNotFoundException {
+    String tableName;
+
+    if (cl.hasOption(Shell.tableOption)) {
+      tableName = cl.getOptionValue(Shell.tableOption);
+      if (!shellState.getConnector().tableOperations().exists(tableName)) {
+        throw new TableNotFoundException(tableName, tableName, "specified table that doesn't exist");
+      }
+    } else {
+      shellState.checkTableState();
+      tableName = shellState.getTableName();
+    }
+
+    return tableName;
+  }
+
+  public static String getNamespaceOpt(final CommandLine cl, final Shell shellState) throws NamespaceNotFoundException, AccumuloException,
+      AccumuloSecurityException {
+    String namespace = null;
+    if (cl.hasOption(Shell.namespaceOption)) {
+      namespace = cl.getOptionValue(Shell.namespaceOption);
+      if (!shellState.getConnector().namespaceOperations().exists(namespace)) {
+        throw new NamespaceNotFoundException(namespace, namespace, "specified namespace that doesn't exist");
+      }
+    } else {
+      throw new NamespaceNotFoundException(null, null, "no namespace specified");
+    }
+    return namespace;
+  }
+
+  public static Option tableOpt() {
+    return tableOpt("tableName");
+  }
+
+  public static Option tableOpt(final String description) {
+    final Option tableOpt = new Option(Shell.tableOption, "table", true, description);
+    tableOpt.setArgName("table");
+    tableOpt.setRequired(false);
+    return tableOpt;
+  }
+
+  public static Option namespaceOpt() {
+    return namespaceOpt("namespace");
+  }
+
+  public static Option namespaceOpt(final String description) {
+    final Option namespaceOpt = new Option(Shell.namespaceOption, "namespace", true, description);
+    namespaceOpt.setArgName("namespace");
+    namespaceOpt.setRequired(false);
+    return namespaceOpt;
+  }
+
+  public static enum AdlOpt {
+    ADD("a"), DELETE("d"), LIST("l");
+
+    public final String opt;
+
+    private AdlOpt(String opt) {
+      this.opt = opt;
+    }
+  }
+
+  public static AdlOpt getAldOpt(final CommandLine cl) {
+    if (cl.hasOption(AdlOpt.ADD.opt)) {
+      return AdlOpt.ADD;
+    } else if (cl.hasOption(AdlOpt.DELETE.opt)) {
+      return AdlOpt.DELETE;
+    } else {
+      return AdlOpt.LIST;
+    }
+  }
+
+  public static OptionGroup addListDeleteGroup(final String name) {
+    final Option addOpt = new Option(AdlOpt.ADD.opt, "add", false, "add " + name);
+    final Option deleteOpt = new Option(AdlOpt.DELETE.opt, "delete", false, "delete " + name);
+    final Option listOpt = new Option(AdlOpt.LIST.opt, "list", false, "list " + name + "(s)");
+    final OptionGroup og = new OptionGroup();
+    og.addOption(addOpt);
+    og.addOption(deleteOpt);
+    og.addOption(listOpt);
+    og.setRequired(true);
+    return og;
+  }
+
+  public static Option startRowOpt() {
+    final Option o = new Option(START_ROW_OPT, "begin-row", true, "begin row (inclusive)");
+    o.setArgName("begin-row");
+    return o;
+  }
+
+  public static Option endRowOpt() {
+    final Option o = new Option(END_ROW_OPT, "end-row", true, "end row (inclusive)");
+    o.setArgName("end-row");
+    return o;
+  }
+
+  public static Text getStartRow(final CommandLine cl) throws UnsupportedEncodingException {
+    if (cl.hasOption(START_ROW_OPT)) {
+      return new Text(cl.getOptionValue(START_ROW_OPT).getBytes(Shell.CHARSET));
+    } else {
+      return null;
+    }
+  }
+
+  public static Text getEndRow(final CommandLine cl) throws UnsupportedEncodingException {
+    if (cl.hasOption(END_ROW_OPT)) {
+      return new Text(cl.getOptionValue(END_ROW_OPT).getBytes(Shell.CHARSET));
+    } else {
+      return null;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/PasswdCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/PasswdCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/PasswdCommand.java
new file mode 100644
index 0000000..c1ef990
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/PasswdCommand.java
@@ -0,0 +1,96 @@
+/*
+ * 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.nio.charset.StandardCharsets;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode;
+import org.apache.accumulo.core.client.security.tokens.PasswordToken;
+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.Options;
+
+public class PasswdCommand extends Command {
+  private Option userOpt;
+  
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException {
+    final String currentUser = shellState.getConnector().whoami();
+    final String user = cl.getOptionValue(userOpt.getOpt(), currentUser);
+    
+    String password = null;
+    String passwordConfirm = null;
+    String oldPassword = null;
+    
+    oldPassword = shellState.readMaskedLine("Enter current password for '" + currentUser + "': ", '*');
+    if (oldPassword == null) {
+      shellState.getReader().println();
+      return 0;
+    } // user canceled
+    
+    if (!shellState.getConnector().securityOperations().authenticateUser(currentUser, new PasswordToken(oldPassword)))
+      throw new AccumuloSecurityException(user, SecurityErrorCode.BAD_CREDENTIALS);
+    
+    password = shellState.readMaskedLine("Enter new password for '" + user + "': ", '*');
+    if (password == null) {
+      shellState.getReader().println();
+      return 0;
+    } // user canceled
+    passwordConfirm = shellState.readMaskedLine("Please confirm new password for '" + user + "': ", '*');
+    if (passwordConfirm == null) {
+      shellState.getReader().println();
+      return 0;
+    } // user canceled
+    
+    if (!password.equals(passwordConfirm)) {
+      throw new IllegalArgumentException("Passwords do not match");
+    }
+    byte[] pass = password.getBytes(StandardCharsets.UTF_8);
+    shellState.getConnector().securityOperations().changeLocalUserPassword(user, new PasswordToken(pass));
+    // update the current credentials if the password changed was for
+    // the current user
+    if (shellState.getConnector().whoami().equals(user)) {
+      shellState.updateUser(user, new PasswordToken(pass));
+    }
+    Shell.log.debug("Changed password for user " + user);
+    return 0;
+  }
+  
+  @Override
+  public String description() {
+    return "changes a user's password";
+  }
+  
+  @Override
+  public Options getOptions() {
+    final Options o = new Options();
+    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/PingCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/PingCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/PingCommand.java
new file mode 100644
index 0000000..ef7a9e4
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/PingCommand.java
@@ -0,0 +1,82 @@
+/*
+ * 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.ArrayList;
+import java.util.List;
+
+import org.apache.accumulo.core.client.admin.InstanceOperations;
+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.Options;
+
+/**
+ * 
+ */
+public class PingCommand extends Command {
+  
+  private Option tserverOption, disablePaginationOpt;
+  
+  @Override
+  public String description() {
+    return "ping tablet servers";
+  }
+  
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    
+    List<String> tservers;
+    
+    final InstanceOperations instanceOps = shellState.getConnector().instanceOperations();
+    
+    final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt());
+    
+    if (cl.hasOption(tserverOption.getOpt())) {
+      tservers = new ArrayList<String>();
+      tservers.add(cl.getOptionValue(tserverOption.getOpt()));
+    } else {
+      tservers = instanceOps.getTabletServers();
+    }
+    
+    shellState.printLines(new PingIterator(tservers, instanceOps), paginate);
+    
+    return 0;
+  }
+  
+  @Override
+  public int numArgs() {
+    return 0;
+  }
+  
+  @Override
+  public Options getOptions() {
+    final Options opts = new Options();
+    
+    tserverOption = new Option("ts", "tabletServer", true, "tablet server to ping");
+    tserverOption.setArgName("tablet server");
+    opts.addOption(tserverOption);
+    
+    disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output");
+    opts.addOption(disablePaginationOpt);
+    
+    return opts;
+  }
+  
+}
+

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/PingIterator.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/PingIterator.java b/shell/src/main/java/org/apache/accumulo/shell/commands/PingIterator.java
new file mode 100644
index 0000000..e414ed4
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/PingIterator.java
@@ -0,0 +1,58 @@
+/*
+ * 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.List;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.admin.InstanceOperations;
+
+class PingIterator implements Iterator<String> {
+  
+  private Iterator<String> iter;
+  private InstanceOperations instanceOps;
+
+  PingIterator(List<String> tservers, InstanceOperations instanceOps) {
+    iter = tservers.iterator();
+    this.instanceOps = instanceOps;
+  }
+  
+  @Override
+  public boolean hasNext() {
+    return iter.hasNext();
+  }
+  
+  @Override
+  public String next() {
+    String tserver = iter.next();
+    
+    try {
+      instanceOps.ping(tserver);
+    } catch (AccumuloException e) {
+      return tserver + " ERROR " + e.getMessage();
+    }
+    
+    return tserver + " OK";
+  }
+  
+  @Override
+  public void remove() {
+    throw new UnsupportedOperationException();
+  }
+  
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/QuestionCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/QuestionCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/QuestionCommand.java
new file mode 100644
index 0000000..ae6b0a1
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/QuestionCommand.java
@@ -0,0 +1,24 @@
+/*
+ * 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;
+
+public class QuestionCommand extends HelpCommand {
+  @Override
+  public String getName() {
+    return "?";
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/QuitCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/QuitCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/QuitCommand.java
new file mode 100644
index 0000000..3ad2274
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/QuitCommand.java
@@ -0,0 +1,19 @@
+/*
+ * 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;
+
+public class QuitCommand extends ExitCommand {}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/QuotedStringTokenizer.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/QuotedStringTokenizer.java b/shell/src/main/java/org/apache/accumulo/shell/commands/QuotedStringTokenizer.java
new file mode 100644
index 0000000..ecc51eb
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/QuotedStringTokenizer.java
@@ -0,0 +1,141 @@
+/*
+ * 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.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.apache.accumulo.core.util.BadArgumentException;
+import org.apache.accumulo.shell.Shell;
+
+/**
+ * A basic tokenizer for generating tokens from a string. It understands quoted strings and escaped quote characters.
+ * 
+ * You can use the escape sequence '\' to escape single quotes, double quotes, and spaces only, in addition to the escape character itself.
+ * 
+ * The behavior is the same for single and double quoted strings. (i.e. '\'' is the same as "\'")
+ */
+
+public class QuotedStringTokenizer implements Iterable<String> {
+  private ArrayList<String> tokens;
+  private String input;
+  
+  public QuotedStringTokenizer(final String t) throws BadArgumentException {
+    tokens = new ArrayList<String>();
+    this.input = t;
+    try {
+      createTokens();
+    } catch (UnsupportedEncodingException e) {
+      throw new IllegalArgumentException(e.getMessage());
+    }
+  }
+  
+  public String[] getTokens() {
+    return tokens.toArray(new String[tokens.size()]);
+  }
+  
+  private void createTokens() throws BadArgumentException, UnsupportedEncodingException {
+    boolean inQuote = false;
+    boolean inEscapeSequence = false;
+    String hexChars = null;
+    char inQuoteChar = '"';
+    
+    final byte[] token = new byte[input.length()];
+    int tokenLength = 0;
+    final byte[] inputBytes = input.getBytes(StandardCharsets.UTF_8);
+    for (int i = 0; i < input.length(); ++i) {
+      final char ch = input.charAt(i);
+      
+      // if I ended up in an escape sequence, check for valid escapable character, and add it as a literal
+      if (inEscapeSequence) {
+        inEscapeSequence = false;
+        if (ch == 'x') {
+          hexChars = "";
+        } else if (ch == ' ' || ch == '\'' || ch == '"' || ch == '\\') {
+          token[tokenLength++] = inputBytes[i];
+        } else {
+          throw new BadArgumentException("can only escape single quotes, double quotes, the space character, the backslash, and hex input", input, i);
+        }
+      }
+      // in a hex escape sequence
+      else if (hexChars != null) {
+        final int digit = Character.digit(ch, 16);
+        if (digit < 0) {
+          throw new BadArgumentException("expected hex character", input, i);
+        }
+        hexChars += ch;
+        if (hexChars.length() == 2) {
+          byte b;
+          try {
+            b = (byte) (0xff & Short.parseShort(hexChars, 16));
+            if (!Character.isValidCodePoint(0xff & b))
+              throw new NumberFormatException();
+          } catch (NumberFormatException e) {
+            throw new BadArgumentException("unsupported non-ascii character", input, i);
+          }
+          token[tokenLength++] = b;
+          hexChars = null;
+        }
+      }
+      // in a quote, either end the quote, start escape, or continue a token
+      else if (inQuote) {
+        if (ch == inQuoteChar) {
+          inQuote = false;
+          tokens.add(new String(token, 0, tokenLength, Shell.CHARSET));
+          tokenLength = 0;
+        } else if (ch == '\\') {
+          inEscapeSequence = true;
+        } else {
+          token[tokenLength++] = inputBytes[i];
+        }
+      }
+      // not in a quote, either enter a quote, end a token, start escape, or continue a token
+      else {
+        if (ch == '\'' || ch == '"') {
+          if (tokenLength > 0) {
+            tokens.add(new String(token, 0, tokenLength, Shell.CHARSET));
+            tokenLength = 0;
+          }
+          inQuote = true;
+          inQuoteChar = ch;
+        } else if (ch == ' ' && tokenLength > 0) {
+          tokens.add(new String(token, 0, tokenLength, Shell.CHARSET));
+          tokenLength = 0;
+        } else if (ch == '\\') {
+          inEscapeSequence = true;
+        } else if (ch != ' ') {
+          token[tokenLength++] = inputBytes[i];
+        }
+      }
+    }
+    if (inQuote) {
+      throw new BadArgumentException("missing terminating quote", input, input.length());
+    } else if (inEscapeSequence || hexChars != null) {
+      throw new BadArgumentException("escape sequence not complete", input, input.length());
+    }
+    if (tokenLength > 0) {
+      tokens.add(new String(token, 0, tokenLength, Shell.CHARSET));
+    }
+  }
+  
+  @Override
+  public Iterator<String> iterator() {
+    return tokens.iterator();
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/RenameNamespaceCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/RenameNamespaceCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/RenameNamespaceCommand.java
new file mode 100644
index 0000000..f456a30
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/RenameNamespaceCommand.java
@@ -0,0 +1,79 @@
+/*
+ * 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.List;
+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.NamespaceExistsException;
+import org.apache.accumulo.core.client.NamespaceNotFoundException;
+import org.apache.accumulo.core.client.TableExistsException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.client.impl.Namespaces;
+import org.apache.accumulo.core.client.impl.Tables;
+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 RenameNamespaceCommand extends Command {
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException,
+      TableNotFoundException, TableExistsException, NamespaceNotFoundException, NamespaceExistsException {
+    String old = cl.getArgs()[0];
+    String newer = cl.getArgs()[1];
+    boolean resetContext = false;
+    String currentTableId = "";
+    if (!(shellState.getTableName() == null) && !shellState.getTableName().isEmpty()) {
+      String namespaceId = Namespaces.getNamespaceId(shellState.getInstance(), old);
+      List<String> tableIds = Namespaces.getTableIds(shellState.getInstance(), namespaceId);
+      currentTableId = Tables.getTableId(shellState.getInstance(), shellState.getTableName());
+      resetContext = tableIds.contains(currentTableId);
+    }
+
+    shellState.getConnector().namespaceOperations().rename(old, newer);
+
+    if (resetContext) {
+      shellState.setTableName(Tables.getTableName(shellState.getInstance(), currentTableId));
+    }
+
+    return 0;
+  }
+
+  @Override
+  public String usage() {
+    return getName() + " <current namespace> <new namespace>";
+  }
+
+  @Override
+  public String description() {
+    return "renames a namespace";
+  }
+
+  @Override
+  public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> special) {
+    registerCompletionForNamespaces(root, special);
+  }
+
+  @Override
+  public int numArgs() {
+    return 2;
+  }
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/shell/src/main/java/org/apache/accumulo/shell/commands/RenameTableCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/RenameTableCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/RenameTableCommand.java
new file mode 100644
index 0000000..a810320
--- /dev/null
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/RenameTableCommand.java
@@ -0,0 +1,62 @@
+/*
+ * 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.TableExistsException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.client.impl.Tables;
+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 RenameTableCommand extends Command {
+  @Override
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException,
+      TableNotFoundException, TableExistsException {
+    shellState.getConnector().tableOperations().rename(cl.getArgs()[0], cl.getArgs()[1]);
+    if (shellState.getTableName().equals(Tables.qualified(cl.getArgs()[0]))) {
+      shellState.setTableName(cl.getArgs()[1]);
+    }
+    return 0;
+  }
+
+  @Override
+  public String usage() {
+    return getName() + " <current table name> <new table name>";
+  }
+
+  @Override
+  public String description() {
+    return "renames a table";
+  }
+
+  @Override
+  public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> completionSet) {
+    registerCompletionForTables(root, completionSet);
+  }
+
+  @Override
+  public int numArgs() {
+    return 2;
+  }
+}