accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vi...@apache.org
Subject svn commit: r1391754 [6/11] - in /accumulo/branches/ACCUMULO-259: ./ assemble/ conf/ conf/examples/1GB/native-standalone/ conf/examples/1GB/standalone/ conf/examples/2GB/native-standalone/ conf/examples/2GB/standalone/ conf/examples/3GB/native-standalo...
Date Sat, 29 Sep 2012 05:43:13 GMT
Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteCommand.java Sat Sep 29 05:42:59 2012
@@ -17,11 +17,14 @@
 package org.apache.accumulo.core.util.shell.commands;
 
 import java.io.IOException;
+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.TableNotFoundException;
+import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.security.ColumnVisibility;
 import org.apache.accumulo.core.tabletserver.thrift.ConstraintViolationException;
@@ -34,27 +37,38 @@ import org.apache.hadoop.io.Text;
 
 public class DeleteCommand extends Command {
   private Option deleteOptAuths, timestampOpt;
+  private Option timeoutOption;
   
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
+  protected long getTimeout(final CommandLine cl) {
+    if (cl.hasOption(timeoutOption.getLongOpt())) {
+      return AccumuloConfiguration.getTimeInMillis(cl.getOptionValue(timeoutOption.getLongOpt()));
+    }
+    
+    return Long.MAX_VALUE;
+  }
+  
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
       IOException, ConstraintViolationException {
     shellState.checkTableState();
     
-    Mutation m = new Mutation(new Text(cl.getArgs()[0].getBytes(Shell.CHARSET)));
-    Text colf = new Text(cl.getArgs()[1].getBytes(Shell.CHARSET));
-    Text colq = new Text(cl.getArgs()[2].getBytes(Shell.CHARSET));
+    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));
     
     if (cl.hasOption(deleteOptAuths.getOpt())) {
-      ColumnVisibility le = new ColumnVisibility(cl.getOptionValue(deleteOptAuths.getOpt()));
-      if (cl.hasOption(timestampOpt.getOpt()))
+      final ColumnVisibility le = new ColumnVisibility(cl.getOptionValue(deleteOptAuths.getOpt()));
+      if (cl.hasOption(timestampOpt.getOpt())) {
         m.putDelete(colf, colq, le, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt())));
-      else
+      } else {
         m.putDelete(colf, colq, le);
-    } else if (cl.hasOption(timestampOpt.getOpt()))
+      }
+    } else if (cl.hasOption(timestampOpt.getOpt())) {
       m.putDelete(colf, colq, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt())));
-    else
+    } else {
       m.putDelete(colf, colq);
-    
-    BatchWriter bw = shellState.getConnector().createBatchWriter(shellState.getTableName(), m.estimatedMemoryUsed() + 0L, 0L, 1);
+    }
+    final BatchWriter bw = shellState.getConnector().createBatchWriter(shellState.getTableName(),
+        new BatchWriterConfig().setMaxMemory(m.estimatedMemoryUsed()).setMaxWriteThreads(1).setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS));
     bw.addMutation(m);
     bw.close();
     return 0;
@@ -72,7 +86,7 @@ public class DeleteCommand extends Comma
   
   @Override
   public Options getOptions() {
-    Options o = new Options();
+    final Options o = new Options();
     
     deleteOptAuths = new Option("l", "visibility-label", true, "formatted visibility");
     deleteOptAuths.setArgName("expression");
@@ -82,6 +96,11 @@ public class DeleteCommand extends Comma
     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;
   }
   

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java Sat Sep 29 05:42:59 2012
@@ -28,24 +28,28 @@ import org.apache.commons.cli.Options;
 public class DeleteIterCommand extends Command {
   private Option mincScopeOpt, majcScopeOpt, scanScopeOpt, nameOpt;
   
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
-    String tableName = OptUtil.getTableOpt(cl, shellState);
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    final String tableName = OptUtil.getTableOpt(cl, shellState);
     
-    String name = cl.getOptionValue(nameOpt.getOpt());
+    final String name = cl.getOptionValue(nameOpt.getOpt());
     if (!shellState.getConnector().tableOperations().listIterators(tableName).containsKey(name)) {
       Shell.log.warn("no iterators found that match your criteria");
       return 0;
     }
     
-    EnumSet<IteratorScope> scopes = EnumSet.noneOf(IteratorScope.class);
-    if (cl.hasOption(mincScopeOpt.getOpt()))
+    final EnumSet<IteratorScope> scopes = EnumSet.noneOf(IteratorScope.class);
+    if (cl.hasOption(mincScopeOpt.getOpt())) {
       scopes.add(IteratorScope.minc);
-    if (cl.hasOption(majcScopeOpt.getOpt()))
+    }
+    if (cl.hasOption(majcScopeOpt.getOpt())) {
       scopes.add(IteratorScope.majc);
-    if (cl.hasOption(scanScopeOpt.getOpt()))
+    }
+    if (cl.hasOption(scanScopeOpt.getOpt())) {
       scopes.add(IteratorScope.scan);
-    if (scopes.isEmpty())
+    }
+    if (scopes.isEmpty()) {
       throw new IllegalArgumentException("You must select at least one scope to configure");
+    }
     shellState.getConnector().tableOperations().removeIterator(tableName, name, scopes);
     return 0;
   }
@@ -56,7 +60,7 @@ public class DeleteIterCommand extends C
   }
   
   public Options getOptions() {
-    Options o = new Options();
+    final Options o = new Options();
     
     nameOpt = new Option("n", "name", true, "iterator to delete");
     nameOpt.setArgName("itername");

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteManyCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteManyCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteManyCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteManyCommand.java Sat Sep 29 05:42:59 2012
@@ -16,45 +16,47 @@
  */
 package org.apache.accumulo.core.util.shell.commands;
 
-import java.io.IOException;
+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.IteratorSetting;
 import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.iterators.SortedKeyIterator;
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.util.format.DeleterFormatter;
+import org.apache.accumulo.core.util.interpret.ScanInterpreter;
 import org.apache.accumulo.core.util.shell.Shell;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.Option;
 import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
 
 public class DeleteManyCommand extends ScanCommand {
   private Option forceOpt;
   
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
-      IOException, ParseException {
-    String tableName = OptUtil.getTableOpt(cl, shellState);
+  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);
+
     // handle first argument, if present, the authorizations list to
     // scan with
-    Authorizations auths = getAuths(cl, shellState);
+    final Authorizations auths = getAuths(cl, shellState);
     final Scanner scanner = shellState.getConnector().createScanner(tableName, auths);
     
     scanner.addScanIterator(new IteratorSetting(Integer.MAX_VALUE, "NOVALUE", SortedKeyIterator.class));
     
     // handle remaining optional arguments
-    scanner.setRange(getRange(cl));
+    scanner.setRange(getRange(cl, interpeter));
     
+    scanner.setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS);
+
     // handle columns
-    fetchColumns(cl, scanner);
+    fetchColumns(cl, scanner, interpeter);
     
     // output / delete the records
-    BatchWriter writer = shellState.getConnector().createBatchWriter(tableName, 1024 * 1024, 1000L, 4);
+    final BatchWriter writer = shellState.getConnector()
+        .createBatchWriter(tableName, new BatchWriterConfig().setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS));
     shellState.printLines(new DeleterFormatter(writer, scanner, cl.hasOption(timestampOpt.getOpt()), shellState, cl.hasOption(forceOpt.getOpt())), false);
     
     return 0;
@@ -68,7 +70,7 @@ public class DeleteManyCommand extends S
   @Override
   public Options getOptions() {
     forceOpt = new Option("f", "force", false, "force deletion without prompting");
-    Options opts = super.getOptions();
+    final Options opts = super.getOptions();
     opts.addOption(forceOpt);
     opts.addOption(OptUtil.tableOpt("table to delete entries from"));
     return opts;

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteRowsCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteRowsCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteRowsCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteRowsCommand.java Sat Sep 29 05:42:59 2012
@@ -27,10 +27,10 @@ public class DeleteRowsCommand extends C
   private Option forceOpt;
   
   @Override
-  public int execute(String fullCommand, CommandLine cl, final Shell shellState) throws Exception {
-    String tableName = OptUtil.getTableOpt(cl, shellState);
-    Text startRow = OptUtil.getStartRow(cl);
-    Text endRow = OptUtil.getEndRow(cl);
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    final String tableName = OptUtil.getTableOpt(cl, shellState);
+    final Text startRow = OptUtil.getStartRow(cl);
+    final Text endRow = OptUtil.getEndRow(cl);
     if (!cl.hasOption(forceOpt.getOpt()) && (startRow == null || endRow == null)) {
       shellState.getReader().printString("Not deleting unbounded range. Specify both ends, or use --force\n");
       return 1;
@@ -51,7 +51,7 @@ public class DeleteRowsCommand extends C
   
   @Override
   public Options getOptions() {
-    Options o = new Options();
+    final Options o = new Options();
     forceOpt = new Option("f", "force", false, "delete data even if start or end are not specified");
     o.addOption(OptUtil.startRowOpt());
     o.addOption(OptUtil.endRowOpt());

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteScanIterCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteScanIterCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteScanIterCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteScanIterCommand.java Sat Sep 29 05:42:59 2012
@@ -31,18 +31,19 @@ public class DeleteScanIterCommand exten
   private Option nameOpt, allOpt;
   
   @Override
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
-    String tableName = OptUtil.getTableOpt(cl, shellState);
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    final String tableName = OptUtil.getTableOpt(cl, shellState);
     
     if (cl.hasOption(allOpt.getOpt())) {
-      List<IteratorSetting> tableScanIterators = shellState.scanIteratorOptions.remove(tableName);
-      if (tableScanIterators == null)
+      final List<IteratorSetting> tableScanIterators = shellState.scanIteratorOptions.remove(tableName);
+      if (tableScanIterators == null) {
         Shell.log.info("No scan iterators set on table " + tableName);
-      else
+      } else {
         Shell.log.info("Removed the following scan iterators from table " + tableName + ":" + tableScanIterators);
+      }
     } else if (cl.hasOption(nameOpt.getOpt())) {
-      String name = cl.getOptionValue(nameOpt.getOpt());
-      List<IteratorSetting> tableScanIterators = shellState.scanIteratorOptions.get(tableName);
+      final String name = cl.getOptionValue(nameOpt.getOpt());
+      final List<IteratorSetting> tableScanIterators = shellState.scanIteratorOptions.get(tableName);
       if (tableScanIterators != null) {
         boolean found = false;
         for (Iterator<IteratorSetting> iter = tableScanIterators.iterator(); iter.hasNext();) {
@@ -52,12 +53,13 @@ public class DeleteScanIterCommand exten
             break;
           }
         }
-        if (!found)
+        if (!found) {
           Shell.log.info("No iterator named " + name + " found for table " + tableName);
-        else {
+        } else {
           Shell.log.info("Removed scan iterator " + name + " from table " + tableName + " (" + shellState.scanIteratorOptions.get(tableName).size() + " left)");
-          if (shellState.scanIteratorOptions.get(tableName).size() == 0)
+          if (shellState.scanIteratorOptions.get(tableName).size() == 0) {
             shellState.scanIteratorOptions.remove(tableName);
+          }
         }
       } else {
         Shell.log.info("No iterator named " + name + " found for table " + tableName);
@@ -74,7 +76,7 @@ public class DeleteScanIterCommand exten
   
   @Override
   public Options getOptions() {
-    Options o = new Options();
+    final Options o = new Options();
     
     OptionGroup nameGroup = new OptionGroup();
     

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteTableCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteTableCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteTableCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteTableCommand.java Sat Sep 29 05:42:59 2012
@@ -24,11 +24,12 @@ import org.apache.commons.cli.Options;
 public class DeleteTableCommand extends TableOperation {
   private Option forceOpt;
   
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
-    if (cl.hasOption(forceOpt.getOpt()))
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    if (cl.hasOption(forceOpt.getOpt())) {
       super.force();
-    else
+    } else {
       super.noForce();
+    }
     return super.execute(fullCommand, cl, shellState);
   }
   
@@ -38,17 +39,18 @@ public class DeleteTableCommand extends 
   }
   
   @Override
-  protected void doTableOp(Shell shellState, String tableName) throws Exception {
+  protected void doTableOp(final Shell shellState, final String tableName) throws Exception {
     shellState.getConnector().tableOperations().delete(tableName);
     shellState.getReader().printString("Table: [" + tableName + "] has been deleted. \n");
-    if (shellState.getTableName().equals(tableName))
+    if (shellState.getTableName().equals(tableName)) {
       shellState.setTableName("");
+    }
   }
   
   @Override
   public Options getOptions() {
     forceOpt = new Option("f", "force", false, "force deletion without prompting");
-    Options opts = super.getOptions();
+    final Options opts = super.getOptions();
     
     opts.addOption(forceOpt);
     return opts;

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DropUserCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DropUserCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DropUserCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DropUserCommand.java Sat Sep 29 05:42:59 2012
@@ -29,10 +29,11 @@ import org.apache.commons.cli.CommandLin
 
 public class DropUserCommand extends Command {
   @Override
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException {
-    String user = cl.getArgs()[0];
-    if (shellState.getConnector().whoami().equals(user))
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException {
+    final String user = cl.getArgs()[0];
+    if (shellState.getConnector().whoami().equals(user)) {
       throw new BadArgumentException("You cannot delete yourself", fullCommand, fullCommand.indexOf(user));
+    }
     shellState.getConnector().securityOperations().dropUser(user);
     Shell.log.debug("Deleted user " + user);
     return 0;
@@ -49,7 +50,7 @@ public class DropUserCommand extends Com
   }
   
   @Override
-  public void registerCompletion(Token root, Map<Command.CompletionSet,Set<String>> completionSet) {
+  public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> completionSet) {
     registerCompletionForUsers(root, completionSet);
   }
   

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/EGrepCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/EGrepCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/EGrepCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/EGrepCommand.java Sat Sep 29 05:42:59 2012
@@ -24,11 +24,11 @@ import org.apache.accumulo.core.iterator
 
 public class EGrepCommand extends GrepCommand {
   @Override
-  protected void setUpIterator(int prio, String name, String term, BatchScanner scanner) throws IOException {
-    if (prio < 0)
+  protected void setUpIterator(final int prio, final String name, final String term, final BatchScanner scanner) throws IOException {
+    if (prio < 0) {
       throw new IllegalArgumentException("Priority < 0 " + prio);
-    
-    IteratorSetting si = new IteratorSetting(prio, name, RegExFilter.class);
+    }
+    final IteratorSetting si = new IteratorSetting(prio, name, RegExFilter.class);
     RegExFilter.setRegexs(si, term, term, term, term, true);
     scanner.addScanIterator(si);
   }

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/EscapeTokenizer.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/EscapeTokenizer.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/EscapeTokenizer.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/EscapeTokenizer.java Sat Sep 29 05:42:59 2012
@@ -36,16 +36,16 @@ public class EscapeTokenizer implements 
   
   private List<String> tokens;
   
-  public EscapeTokenizer(String line, String delimeters) {
+  public EscapeTokenizer(final String line, final String delimeters) {
     this.tokens = new ArrayList<String>();
     preprocess(line, delimeters);
   }
   
-  private void preprocess(String line, String delimeters) {
-    StringTokenizer st = new StringTokenizer(line, delimeters, true);
+  private void preprocess(final String line, final String delimeters) {
+    final StringTokenizer st = new StringTokenizer(line, delimeters, true);
     boolean inEscape = false;
     String current = "", prev = "";
-    List<String> toks = new ArrayList<String>();
+    final List<String> toks = new ArrayList<String>();
     
     while (st.hasMoreTokens()) {
       current = st.nextToken();
@@ -54,20 +54,23 @@ public class EscapeTokenizer implements 
         inEscape = false;
       } else {
         inEscape = current.endsWith("\\");
-        if (inEscape)
+        if (inEscape) {
           prev = current.substring(0, current.length() - 1);
-        else {
+        } else {
           if (current.length() == 1 && delimeters.contains(current)) {
-            if (!prev.isEmpty())
+            if (!prev.isEmpty()) {
               toks.add(prev);
-          } else
+            }
+          } else {
             toks.add(prev + current);
+          }
           prev = "";
         }
       }
     }
-    if (!prev.isEmpty())
+    if (!prev.isEmpty()) {
       toks.add(prev);
+    }
     this.tokens = toks;
   }
   

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExecfileCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExecfileCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExecfileCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExecfileCommand.java Sat Sep 29 05:42:59 2012
@@ -17,6 +17,7 @@
 package org.apache.accumulo.core.util.shell.commands;
 
 import java.io.File;
+import java.util.Scanner;
 
 import org.apache.accumulo.core.util.shell.Shell;
 import org.apache.accumulo.core.util.shell.Shell.Command;
@@ -33,10 +34,11 @@ public class ExecfileCommand extends Com
   }
   
   @Override
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
-    java.util.Scanner scanner = new java.util.Scanner(new File(cl.getArgs()[0]));
-    while (scanner.hasNextLine())
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    Scanner scanner = new Scanner(new File(cl.getArgs()[0]));
+    while (scanner.hasNextLine()) {
       shellState.execCommand(scanner.nextLine(), true, cl.hasOption(verboseOption.getOpt()));
+    }
     return 0;
   }
   
@@ -52,7 +54,7 @@ public class ExecfileCommand extends Com
   
   @Override
   public Options getOptions() {
-    Options opts = new Options();
+    final Options opts = new Options();
     verboseOption = new Option("v", "verbose", false, "display command prompt as commands are executed");
     opts.addOption(verboseOption);
     return opts;

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExitCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExitCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExitCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExitCommand.java Sat Sep 29 05:42:59 2012
@@ -22,7 +22,7 @@ import org.apache.commons.cli.CommandLin
 
 public class ExitCommand extends Command {
   @Override
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) {
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) {
     shellState.setExit(true);
     return 0;
   }

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FlushCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FlushCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FlushCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FlushCommand.java Sat Sep 29 05:42:59 2012
@@ -38,7 +38,7 @@ public class FlushCommand extends TableO
     return "flushes a tables data that is currently in memory to disk";
   }
   
-  protected void doTableOp(Shell shellState, String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
+  protected void doTableOp(final Shell shellState, final String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
     shellState.getConnector().tableOperations().flush(tableName, startRow, endRow, wait);
     Shell.log.info("Flush of table " + tableName + (wait ? " completed." : " initiated..."));
     if (tableName.equals(Constants.METADATA_TABLE_NAME)) {
@@ -50,7 +50,7 @@ public class FlushCommand extends TableO
   }
   
   @Override
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
     wait = cl.hasOption(waitOpt.getLongOpt());
     startRow = OptUtil.getStartRow(cl);
     endRow = OptUtil.getEndRow(cl);
@@ -59,7 +59,7 @@ public class FlushCommand extends TableO
   
   @Override
   public Options getOptions() {
-    Options opts = super.getOptions();
+    final Options opts = super.getOptions();
     waitOpt = new Option("w", "wait", false, "wait for flush to finish");
     opts.addOption(waitOpt);
     opts.addOption(OptUtil.startRowOpt());

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FormatterCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FormatterCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FormatterCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FormatterCommand.java Sat Sep 29 05:42:59 2012
@@ -16,114 +16,54 @@
  */
 package org.apache.accumulo.core.util.shell.commands;
 
-import java.util.Iterator;
-import java.util.Map.Entry;
-
 import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.util.format.Formatter;
 import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.Command;
-import org.apache.accumulo.start.classloader.AccumuloClassLoader;
 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 FormatterCommand extends Command {
-  private Option removeFormatterOption, formatterClassOption, listClassOption;
+public class FormatterCommand extends ShellPluginConfigurationCommand {
   
+  private Option interpeterOption;
+
+  public FormatterCommand() {
+    super("formatter", Property.TABLE_FORMATTER_CLASS, "f");
+  }
+
   @Override
   public String description() {
     return "specifies a formatter to use for displaying table entries";
   }
-  
-  @Override
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
-    String tableName = OptUtil.getTableOpt(cl, shellState);
-    
-    if (cl.hasOption(removeFormatterOption.getOpt())) {
-      // Remove the property
-      shellState.getConnector().tableOperations().removeProperty(tableName, Property.TABLE_FORMATTER_CLASS.toString());
-      
-      shellState.getReader().printString("Removed formatter on " + tableName + "\n");
-    } else if (cl.hasOption(listClassOption.getOpt())) {
-      // Get the options for this table
-      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(Property.TABLE_FORMATTER_CLASS.toString())) {
-          shellState.getReader().printString(ent.getKey() + ": " + ent.getValue() + "\n");
-        }
-      }
-    } else {
-      // Set the formatter with the provided options
-      String className = cl.getOptionValue(formatterClassOption.getOpt());
-      
-      // Set the formatter property on the table
-      shellState.getConnector().tableOperations().setProperty(tableName, Property.TABLE_FORMATTER_CLASS.toString(), className);
-    }
-    
-    return 0;
-  }
-  
-  public static Class<? extends Formatter> getCurrentFormatter(String tableName, Shell shellState) {
-    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()) {
-      Entry<String,String> ent = props.next();
-      if (ent.getKey().equals(Property.TABLE_FORMATTER_CLASS.toString())) {
-        Class<? extends Formatter> formatter;
-        try {
-          formatter = AccumuloClassLoader.loadClass(ent.getValue(), Formatter.class);
-        } catch (ClassNotFoundException e) {
-          return null;
-        }
-        
-        return formatter;
-      }
-    }
-    
-    return null;
+
+  public static Class<? extends Formatter> getCurrentFormatter(final String tableName, final Shell shellState) {
+    return ShellPluginConfigurationCommand.getPluginClass(tableName, shellState, Formatter.class, Property.TABLE_FORMATTER_CLASS);
   }
   
   @Override
   public Options getOptions() {
-    Options o = new Options();
-    OptionGroup actionGroup = new OptionGroup();
-    
-    formatterClassOption = new Option("f", "formatter", true, "fully qualified name of the formatter class to use");
-    formatterClassOption.setArgName("className");
+    final Options options = super.getOptions();
     
-    // Action to take: apply (default), remove, list
-    removeFormatterOption = new Option("r", "remove", false, "remove the current formatter");
-    listClassOption = new Option("l", "list", false, "display the current formatter");
+    interpeterOption = new Option("i", "interpeter", false, "configure class as interpreter also");
     
-    actionGroup.addOption(formatterClassOption);
-    actionGroup.addOption(removeFormatterOption);
-    actionGroup.addOption(listClassOption);
-    actionGroup.setRequired(true);
+    options.addOption(interpeterOption);
     
-    o.addOptionGroup(actionGroup);
-    o.addOption(OptUtil.tableOpt("table to set the formatter on"));
-    
-    return o;
+    return options;
   }
   
-  @Override
-  public int numArgs() {
-    return 0;
+  protected void setPlugin(final CommandLine cl, final Shell shellState, final String tableName, final String className) throws AccumuloException, AccumuloSecurityException {
+    super.setPlugin(cl, shellState, tableName, className);
+    if (cl.hasOption(interpeterOption.getOpt())) {
+      shellState.getConnector().tableOperations().setProperty(tableName, Property.TABLE_INTERPRETER_CLASS.toString(), className);
+    }
   }
   
+  protected void removePlugin(final CommandLine cl, final Shell shellState, final String tableName) throws AccumuloException, AccumuloSecurityException {
+    super.removePlugin(cl, shellState, tableName);
+    if (cl.hasOption(interpeterOption.getOpt())) {
+      shellState.getConnector().tableOperations().removeProperty(tableName, Property.TABLE_INTERPRETER_CLASS.toString());
+    }
+  }
 }

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java Sat Sep 29 05:42:59 2012
@@ -30,8 +30,8 @@ public class GetAuthsCommand extends Com
   private Option userOpt;
   
   @Override
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException {
-    String user = cl.getOptionValue(userOpt.getOpt(), shellState.getConnector().whoami());
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException {
+    final String user = cl.getOptionValue(userOpt.getOpt(), shellState.getConnector().whoami());
     shellState.getReader().printString(shellState.getConnector().securityOperations().getUserAuthorizations(user) + "\n");
     return 0;
   }
@@ -43,7 +43,7 @@ public class GetAuthsCommand extends Com
   
   @Override
   public Options getOptions() {
-    Options o = new Options();
+    final Options o = new Options();
     userOpt = new Option(Shell.userOption, "user", true, "user to operate on");
     userOpt.setArgName("user");
     o.addOption(userOpt);

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetGroupsCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetGroupsCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetGroupsCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetGroupsCommand.java Sat Sep 29 05:42:59 2012
@@ -30,14 +30,14 @@ import org.apache.hadoop.io.Text;
 public class GetGroupsCommand extends Command {
   
   @Override
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
-    String tableName = OptUtil.getTableOpt(cl, shellState);
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    final String tableName = OptUtil.getTableOpt(cl, shellState);
     
-    Map<String,Set<Text>> groups = shellState.getConnector().tableOperations().getLocalityGroups(tableName);
+    final Map<String,Set<Text>> groups = shellState.getConnector().tableOperations().getLocalityGroups(tableName);
     
-    for (Entry<String,Set<Text>> entry : groups.entrySet())
+    for (Entry<String,Set<Text>> entry : groups.entrySet()) {
       shellState.getReader().printString(entry.getKey() + "=" + LocalityGroupUtil.encodeColumnFamilies(entry.getValue()) + "\n");
-    
+    }
     return 0;
   }
   
@@ -53,7 +53,7 @@ public class GetGroupsCommand extends Co
   
   @Override
   public Options getOptions() {
-    Options opts = new Options();
+    final Options opts = new Options();
     opts.addOption(OptUtil.tableOpt("table to fetch locality groups from"));
     return opts;
   }

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java Sat Sep 29 05:42:59 2012
@@ -31,7 +31,6 @@ import org.apache.accumulo.core.data.Key
 import org.apache.accumulo.core.data.KeyExtent;
 import org.apache.accumulo.core.data.Range;
 import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.util.ColumnFQ;
 import org.apache.accumulo.core.util.TextUtil;
 import org.apache.accumulo.core.util.format.BinaryFormatter;
 import org.apache.accumulo.core.util.shell.Shell;
@@ -50,9 +49,9 @@ public class GetSplitsCommand extends Co
   private Option outputFileOpt, maxSplitsOpt, base64Opt, verboseOpt;
   
   @Override
-  public int execute(String fullCommand, CommandLine cl, final Shell shellState) throws IOException, AccumuloException, AccumuloSecurityException,
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException, AccumuloException, AccumuloSecurityException,
       TableNotFoundException {
-    String tableName = OptUtil.getTableOpt(cl, shellState);
+    final String tableName = OptUtil.getTableOpt(cl, shellState);
     
     final String outputFile = cl.getOptionValue(outputFileOpt.getOpt());
     final String m = cl.getOptionValue(maxSplitsOpt.getOpt());
@@ -60,7 +59,7 @@ public class GetSplitsCommand extends Co
     final boolean encode = cl.hasOption(base64Opt.getOpt());
     final boolean verbose = cl.hasOption(verboseOpt.getOpt());
     
-    PrintLine p = outputFile == null ? new PrintShell(shellState.getReader()) : new PrintFile(outputFile);
+    final PrintLine p = outputFile == null ? new PrintShell(shellState.getReader()) : new PrintFile(outputFile);
     
     try {
       if (!verbose) {
@@ -70,7 +69,7 @@ public class GetSplitsCommand extends Co
         }
       } else {
         final Scanner scanner = shellState.getConnector().createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS);
-        ColumnFQ.fetch(scanner, Constants.METADATA_PREV_ROW_COLUMN);
+        Constants.METADATA_PREV_ROW_COLUMN.fetch(scanner);
         final Text start = new Text(shellState.getConnector().tableOperations().tableIdMap().get(tableName));
         final Text end = new Text(start);
         end.append(new byte[] {'<'}, 0, 1);
@@ -95,14 +94,15 @@ public class GetSplitsCommand extends Co
     return 0;
   }
   
-  private static String encode(boolean encode, Text text) {
-    if (text == null)
+  private static String encode(final boolean encode, final Text text) {
+    if (text == null) {
       return null;
+    }
     BinaryFormatter.getlength(text.getLength());
     return encode ? new String(Base64.encodeBase64(TextUtil.getBytes(text))) : BinaryFormatter.appendText(new StringBuilder(), text).toString();
   }
   
-  private static String obscuredTabletName(KeyExtent extent) {
+  private static String obscuredTabletName(final KeyExtent extent) {
     MessageDigest digester;
     try {
       digester = MessageDigest.getInstance("MD5");
@@ -127,7 +127,7 @@ public class GetSplitsCommand extends Co
   
   @Override
   public Options getOptions() {
-    Options opts = new Options();
+    final Options opts = new Options();
     
     outputFileOpt = new Option("o", "output", true, "local file to write the splits to");
     outputFileOpt.setArgName("file");

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrantCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrantCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrantCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrantCommand.java Sat Sep 29 05:42:59 2012
@@ -40,7 +40,7 @@ public class GrantCommand extends TableO
   private String[] permission;
   
   @Override
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
+  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);
@@ -60,7 +60,7 @@ public class GrantCommand extends TableO
   }
   
   @Override
-  protected void doTableOp(Shell shellState, String tableName) throws Exception {
+  protected void doTableOp(final Shell shellState, final String tableName) throws Exception {
     try {
       shellState.getConnector().securityOperations().grantTablePermission(user, tableName, TablePermission.valueOf(permission[1]));
       Shell.log.debug("Granted " + user + " the " + permission[1] + " permission on table " + tableName);
@@ -80,8 +80,8 @@ public class GrantCommand extends TableO
   }
   
   @Override
-  public void registerCompletion(Token root, Map<Command.CompletionSet,Set<String>> completionSet) {
-    Token cmd = new Token(getName());
+  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()));
     root.addSubcommand(cmd);
@@ -90,9 +90,9 @@ public class GrantCommand extends TableO
   @Override
   public Options getOptions() {
     super.getOptions();
-    Options o = new Options();
+    final Options o = new Options();
     
-    OptionGroup group = new OptionGroup();
+    final OptionGroup group = new OptionGroup();
     
     systemOpt = new Option("s", "system", false, "grant a system permission");
     

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrepCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrepCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrepCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrepCommand.java Sat Sep 29 05:42:59 2012
@@ -18,14 +18,14 @@ package org.apache.accumulo.core.util.sh
 
 import java.io.IOException;
 import java.util.Collections;
+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.BatchScanner;
 import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.iterators.user.GrepIterator;
 import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.util.format.Formatter;
+import org.apache.accumulo.core.util.interpret.ScanInterpreter;
 import org.apache.accumulo.core.util.shell.Shell;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.MissingArgumentException;
@@ -36,33 +36,37 @@ public class GrepCommand extends ScanCom
   
   private Option numThreadsOpt;
   
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
-      IOException, MissingArgumentException {
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
     
-    String tableName = OptUtil.getTableOpt(cl, shellState);
+    final String tableName = OptUtil.getTableOpt(cl, shellState);
     
-    if (cl.getArgList().isEmpty())
+    if (cl.getArgList().isEmpty()) {
       throw new MissingArgumentException("No terms specified");
-    
+    }
+    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
     int numThreads = 20;
     if (cl.hasOption(numThreadsOpt.getOpt())) {
       numThreads = Integer.parseInt(cl.getOptionValue(numThreadsOpt.getOpt()));
     }
-    Authorizations auths = getAuths(cl, shellState);
-    BatchScanner scanner = shellState.getConnector().createBatchScanner(tableName, auths, numThreads);
-    scanner.setRanges(Collections.singletonList(getRange(cl)));
+    final Authorizations auths = getAuths(cl, shellState);
+    final BatchScanner scanner = shellState.getConnector().createBatchScanner(tableName, auths, numThreads);
+    scanner.setRanges(Collections.singletonList(getRange(cl, interpeter)));
     
-    for (int i = 0; i < cl.getArgs().length; i++)
+    scanner.setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS);
+
+    for (int i = 0; i < cl.getArgs().length; i++) {
       setUpIterator(Integer.MAX_VALUE - cl.getArgs().length + i, "grep" + i, cl.getArgs()[i], scanner);
-    
+    }    
     try {
       // handle columns
-      fetchColumns(cl, scanner);
+      fetchColumns(cl, scanner, interpeter);
       
       // output the records
-      printRecords(cl, shellState, scanner);
+      printRecords(cl, shellState, scanner, formatter);
     } finally {
       scanner.close();
     }
@@ -70,11 +74,11 @@ public class GrepCommand extends ScanCom
     return 0;
   }
   
-  protected void setUpIterator(int prio, String name, String term, BatchScanner scanner) throws IOException {
-    if (prio < 0)
+  protected void setUpIterator(final int prio, final String name, final String term, final BatchScanner scanner) throws IOException {
+    if (prio < 0) {
       throw new IllegalArgumentException("Priority < 0 " + prio);
-    
-    IteratorSetting grep = new IteratorSetting(prio, name, GrepIterator.class);
+    }    
+    final IteratorSetting grep = new IteratorSetting(prio, name, GrepIterator.class);
     GrepIterator.setTerm(grep, term);
     scanner.addScanIterator(grep);
   }
@@ -86,7 +90,7 @@ public class GrepCommand extends ScanCom
   
   @Override
   public Options getOptions() {
-    Options opts = super.getOptions();
+    final Options opts = super.getOptions();
     numThreadsOpt = new Option("nt", "num-threads", true, "number of threads to use");
     opts.addOption(numThreadsOpt);
     return opts;

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java Sat Sep 29 05:42:59 2012
@@ -34,26 +34,29 @@ public class HelpCommand extends Command
   private Option disablePaginationOpt;
   private Option noWrapOpt;
   
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws ShellCommandException, IOException {
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws ShellCommandException, IOException {
     int numColumns = shellState.getReader().getTermwidth();
-    if (cl.hasOption(noWrapOpt.getOpt()))
+    if (cl.hasOption(noWrapOpt.getOpt())) {
       numColumns = Integer.MAX_VALUE;
-    
+    }
     // print help summary
     if (cl.getArgs().length == 0) {
       int i = 0;
-      for (String cmd : shellState.commandFactory.keySet())
+      for (String cmd : shellState.commandFactory.keySet()) {
         i = Math.max(i, cmd.length());
-      if (numColumns < 40)
+      }
+      if (numColumns < 40) {
         throw new IllegalArgumentException("numColumns must be at least 40 (was " + numColumns + ")");
-      ArrayList<String> output = new ArrayList<String>();
+      }
+      final ArrayList<String> output = new ArrayList<String>();
       for (Entry<String,Command[]> cmdGroup : shellState.commandGrouping.entrySet()) {
         output.add(cmdGroup.getKey());
         for (Command c : cmdGroup.getValue()) {
           String n = c.getName();
           String s = c.description();
-          if (s == null)
+          if (s == null) {
             s = "";
+          }
           int beginIndex = 0;
           int endIndex = s.length();
           while (beginIndex < endIndex && s.charAt(beginIndex) == ' ')
@@ -73,8 +76,9 @@ public class HelpCommand extends Command
             }
             n = "";
             endIndex = s.length();
-            while (beginIndex < endIndex && s.charAt(beginIndex) == ' ')
+            while (beginIndex < endIndex && s.charAt(beginIndex) == ' ') {
               beginIndex++;
+            }
           }
           output.add(String.format("%-" + i + "s  %s  %s", n, dash, s.substring(beginIndex, endIndex)));
         }
@@ -85,11 +89,12 @@ public class HelpCommand extends Command
     
     // print help for every command on command line
     for (String cmd : cl.getArgs()) {
-      Command c = shellState.commandFactory.get(cmd);
-      if (c == null)
+      final Command c = shellState.commandFactory.get(cmd);
+      if (c == null) {
         shellState.getReader().printString(String.format("Unknown command \"%s\".  Enter \"help\" for a list possible commands.\n", cmd));
-      else
+      } else {
         c.printHelp(shellState, numColumns);
+      }
     }
     return 0;
   }
@@ -98,13 +103,13 @@ public class HelpCommand extends Command
     return "provides information about the available commands";
   }
   
-  public void registerCompletion(Token root, Map<Command.CompletionSet,Set<String>> special) {
+  public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> special) {
     registerCompletionForCommands(root, special);
   }
   
   @Override
   public Options getOptions() {
-    Options o = new Options();
+    final Options o = new Options();
     disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output");
     o.addOption(disablePaginationOpt);
     noWrapOpt = new Option("nw", "no-wrap", false, "disable wrapping of output");

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java Sat Sep 29 05:42:59 2012
@@ -35,7 +35,7 @@ public class HiddenCommand extends Comma
   }
   
   @Override
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
     if (rand.nextInt(10) == 0) {
       shellState.getReader().beep();
       shellState.getReader().printNewline();
@@ -44,9 +44,9 @@ public class HiddenCommand extends Comma
               + "ICAvICB8Xy58Xy4gIFwKICAvIC98ICAgICAgfFwgXAogfCB8IHwgfFwvfCB8IHwgfAogfF98IHwgfCAgfCB8IHxffAogICAgIC8gIF9fICBcCiAgICAvICAv"
               + "ICBcICBcCiAgIC8gIC8gICAgXCAgXF8KIHwvICAvICAgICAgXCB8IHwKIHxfXy8gICAgICAgIFx8X3wK").getBytes())));
       shellState.getReader().printNewline();
-    } else
+    } else {
       throw new ShellCommandException(ErrorCode.UNRECOGNIZED_COMMAND, getName());
-    
+    }
     return 0;
   }
   
@@ -57,6 +57,6 @@ public class HiddenCommand extends Comma
   
   @Override
   public String getName() {
-    return new String("accvmvlo");
+    return "accvmvlo";
   }
 }

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HistoryCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HistoryCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HistoryCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HistoryCommand.java Sat Sep 29 05:42:59 2012
@@ -34,17 +34,17 @@ public class HistoryCommand extends Comm
   private Option clearHist;
   
   @Override
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
     
-    String histDir = System.getenv("HOME") + "/.accumulo";
+    final String histDir = System.getenv("HOME") + "/.accumulo";
     int counter = 0;
     
     if (cl.hasOption(clearHist.getOpt())) {
       
       try {
         
-        FileWriter outFile = new FileWriter(histDir + "/shell_history.txt");
-        PrintWriter out = new PrintWriter(outFile);
+        final FileWriter outFile = new FileWriter(histDir + "/shell_history.txt");
+        final PrintWriter out = new PrintWriter(outFile);
         out.close();
         
       } catch (IOException e) {
@@ -55,7 +55,7 @@ public class HistoryCommand extends Comm
     
     else {
       try {
-        BufferedReader in = new BufferedReader(new FileReader(histDir + "/shell_history.txt"));
+        final BufferedReader in = new BufferedReader(new FileReader(histDir + "/shell_history.txt"));
         String Line;
         try {
           Line = in.readLine();
@@ -90,7 +90,7 @@ public class HistoryCommand extends Comm
   
   @Override
   public Options getOptions() {
-    Options o = new Options();
+    final Options o = new Options();
     
     clearHist = new Option("c", "clear", false, "clear history file");
     clearHist.setRequired(false);

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ImportDirectoryCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ImportDirectoryCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ImportDirectoryCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ImportDirectoryCommand.java Sat Sep 29 05:42:59 2012
@@ -37,18 +37,19 @@ public class ImportDirectoryCommand exte
   }
   
   @Override
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws IOException, AccumuloException, AccumuloSecurityException,
+  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];
-    boolean setTime = Boolean.parseBoolean(cl.getArgs()[2]);
+    final boolean setTime = Boolean.parseBoolean(cl.getArgs()[2]);
     
-    FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
-    FileStatus failStatus = fs.getFileStatus(new Path(failureDir));
-    if (failStatus == null || !failStatus.isDir() || fs.listStatus(new Path(failureDir)).length != 0)
+    final FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
+    final FileStatus failStatus = fs.getFileStatus(new Path(failureDir));
+    if (failStatus == null || !failStatus.isDir() || fs.listStatus(new Path(failureDir)).length != 0) {
       throw new AccumuloException(failureDir + " is not an empty directory");
+    }
     shellState.getConnector().tableOperations().importDirectory(shellState.getTableName(), dir, failureDir, setTime);
     return 0;
   }

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InsertCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InsertCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InsertCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InsertCommand.java Sat Sep 29 05:42:59 2012
@@ -18,12 +18,15 @@ package org.apache.accumulo.core.util.sh
 
 import java.io.IOException;
 import java.util.ArrayList;
+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.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.data.ConstraintViolationSummary;
 import org.apache.accumulo.core.data.KeyExtent;
 import org.apache.accumulo.core.data.Mutation;
@@ -39,18 +42,27 @@ import org.apache.hadoop.io.Text;
 
 public class InsertCommand extends Command {
   private Option insertOptAuths, timestampOpt;
+  private Option timeoutOption;
   
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
+  protected long getTimeout(final CommandLine cl) {
+    if (cl.hasOption(timeoutOption.getLongOpt())) {
+      return AccumuloConfiguration.getTimeInMillis(cl.getOptionValue(timeoutOption.getLongOpt()));
+    }
+    
+    return Long.MAX_VALUE;
+  }
+
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
       IOException, ConstraintViolationException {
     shellState.checkTableState();
     
-    Mutation m = new Mutation(new Text(cl.getArgs()[0].getBytes(Shell.CHARSET)));
-    Text colf = new Text(cl.getArgs()[1].getBytes(Shell.CHARSET));
-    Text colq = new Text(cl.getArgs()[2].getBytes(Shell.CHARSET));
-    Value val = new Value(cl.getArgs()[3].getBytes(Shell.CHARSET));
+    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())) {
-      ColumnVisibility le = new ColumnVisibility(cl.getOptionValue(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()))
@@ -62,22 +74,33 @@ public class InsertCommand extends Comma
     else
       m.put(colf, colq, val);
     
-    BatchWriter bw = shellState.getConnector().createBatchWriter(shellState.getTableName(), m.estimatedMemoryUsed() + 0L, 0L, 1);
+    final BatchWriter bw = shellState.getConnector().createBatchWriter(shellState.getTableName(),
+        new BatchWriterConfig().setMaxMemory(m.estimatedMemoryUsed()).setMaxWriteThreads(1).setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS));
     bw.addMutation(m);
     try {
       bw.close();
     } catch (MutationsRejectedException e) {
-      ArrayList<String> lines = new ArrayList<String>();
-      if (e.getAuthorizationFailures().isEmpty() == false)
+      final ArrayList<String> lines = new ArrayList<String>();
+      if (e.getAuthorizationFailures().isEmpty() == false) {
         lines.add("	Authorization Failures:");
+      }
       for (KeyExtent extent : e.getAuthorizationFailures()) {
         lines.add("		" + extent);
       }
-      if (e.getConstraintViolationSummaries().isEmpty() == false)
+      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 0;
@@ -95,7 +118,7 @@ public class InsertCommand extends Comma
   
   @Override
   public Options getOptions() {
-    Options o = new Options();
+    final Options o = new Options();
     insertOptAuths = new Option("l", "visibility-label", true, "formatted visibility");
     insertOptAuths.setArgName("expression");
     o.addOption(insertOptAuths);
@@ -104,6 +127,11 @@ public class InsertCommand extends Comma
     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;
   }
   

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java Sat Sep 29 05:42:59 2012
@@ -34,18 +34,18 @@ public class ListIterCommand extends Com
   private Map<IteratorScope,Option> scopeOpts;
   
   @Override
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
-    String tableName = OptUtil.getTableOpt(cl, shellState);
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+    final String tableName = OptUtil.getTableOpt(cl, shellState);
     
-    Map<String,EnumSet<IteratorScope>> iterators = shellState.getConnector().tableOperations().listIterators(tableName);
+    final Map<String,EnumSet<IteratorScope>> iterators = shellState.getConnector().tableOperations().listIterators(tableName);
     
     if (cl.hasOption(nameOpt.getOpt())) {
-      String name = cl.getOptionValue(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;
       }
-      EnumSet<IteratorScope> scopes = iterators.get(name);
+      final EnumSet<IteratorScope> scopes = iterators.get(name);
       iterators.clear();
       iterators.put(name, scopes);
     }
@@ -55,10 +55,10 @@ public class ListIterCommand extends Com
       if (cl.hasOption(scopeOpts.get(scope).getOpt()))
         hasScope = true;
     }
-    if (!hasScope)
+    if (!hasScope) {
       throw new IllegalArgumentException("You must select at least one scope to configure");
-    
-    StringBuilder sb = new StringBuilder("-\n");
+    }    
+    final StringBuilder sb = new StringBuilder("-\n");
     for (String name : iterators.keySet()) {
       for (IteratorScope scope : iterators.get(name)) {
         if (cl.hasOption(scopeOpts.get(scope).getOpt())) {
@@ -89,7 +89,7 @@ public class ListIterCommand extends Com
   
   @Override
   public Options getOptions() {
-    Options o = new Options();
+    final Options o = new Options();
     
     nameOpt = new Option("n", "name", true, "iterator to list");
     nameOpt.setArgName("itername");

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListScansCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListScansCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListScansCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListScansCommand.java Sat Sep 29 05:42:59 2012
@@ -36,13 +36,13 @@ public class ListScansCommand extends Co
   }
   
   @Override
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
     
     List<String> tservers;
     
-    InstanceOperations instanceOps = shellState.getConnector().instanceOperations();
+    final InstanceOperations instanceOps = shellState.getConnector().instanceOperations();
     
-    boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt());
+    final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt());
     
     if (cl.hasOption(tserverOption.getOpt())) {
       tservers = new ArrayList<String>();
@@ -63,7 +63,7 @@ public class ListScansCommand extends Co
   
   @Override
   public Options getOptions() {
-    Options opts = new Options();
+    final Options opts = new Options();
     
     tserverOption = new Option("ts", "tabletServer", true, "tablet server to list scans for");
     tserverOption.setArgName("tablet server");

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MaxRowCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MaxRowCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MaxRowCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MaxRowCommand.java Sat Sep 29 05:42:59 2012
@@ -16,33 +16,31 @@
  */
 package org.apache.accumulo.core.util.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.core.data.Range;
 import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.core.util.interpret.ScanInterpreter;
 import org.apache.accumulo.core.util.shell.Shell;
 import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.ParseException;
 import org.apache.hadoop.io.Text;
 
 public class MaxRowCommand extends ScanCommand {
   
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
-      IOException, ParseException {
-    String tableName = OptUtil.getTableOpt(cl, shellState);
-    Range range = getRange(cl);
-    Authorizations auths = getAuths(cl, shellState);
-    Text startRow = range.getStartKey() == null ? null : range.getStartKey().getRow();
-    Text endRow = range.getEndKey() == null ? null : range.getEndKey().getRow();
+  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 {
-      Text max = shellState.getConnector().tableOperations()
+      final Text max = shellState.getConnector().tableOperations()
           .getMaxRow(tableName, auths, startRow, range.isStartKeyInclusive(), endRow, range.isEndKeyInclusive());
-      if (max != null)
+      if (max != null) {
         shellState.getReader().printString(max.toString() + "\n");
+      }
     } catch (Exception e) {
       e.printStackTrace();
     }

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java Sat Sep 29 05:42:59 2012
@@ -31,25 +31,27 @@ public class MergeCommand extends Comman
   private Option verboseOpt, forceOpt, sizeOpt;
   
   @Override
-  public int execute(String fullCommand, CommandLine cl, final Shell shellState) throws Exception {
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
     boolean verbose = shellState.isVerbose();
     boolean force = false;
     long size = -1;
-    String tableName = OptUtil.getTableOpt(cl, shellState);
-    Text startRow = OptUtil.getStartRow(cl);
-    Text endRow = OptUtil.getEndRow(cl);
-    if (cl.hasOption(verboseOpt.getOpt()))
+    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()))
+    }
+    if (cl.hasOption(forceOpt.getOpt())) {
       force = true;
+    }
     if (cl.hasOption(sizeOpt.getOpt())) {
       size = AccumuloConfiguration.getMemoryInBytes(cl.getOptionValue(sizeOpt.getOpt()));
     }
-    if (size < 0)
+    if (size < 0) {
       shellState.getConnector().tableOperations().merge(tableName, startRow, endRow);
-    else {
+    } else {
       final boolean finalVerbose = verbose;
-      Merge merge = new Merge() {
+      final Merge merge = new Merge() {
         protected void message(String fmt, Object... args) {
           if (finalVerbose) {
             try {
@@ -78,7 +80,7 @@ public class MergeCommand extends Comman
   
   @Override
   public Options getOptions() {
-    Options o = new Options();
+    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");

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NoTableCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NoTableCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NoTableCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NoTableCommand.java Sat Sep 29 05:42:59 2012
@@ -22,7 +22,7 @@ import org.apache.commons.cli.CommandLin
 
 public class NoTableCommand extends Command {
   @Override
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
+  public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
     shellState.setTableName("");
     
     return 0;

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OfflineCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OfflineCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OfflineCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OfflineCommand.java Sat Sep 29 05:42:59 2012
@@ -28,7 +28,7 @@ public class OfflineCommand extends Tabl
     return "starts the process of taking table offline";
   }
   
-  protected void doTableOp(Shell shellState, String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
+  protected void doTableOp(final Shell shellState, final String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
     if (tableName.equals(Constants.METADATA_TABLE_NAME)) {
       Shell.log.info("  You cannot take the " + Constants.METADATA_TABLE_NAME + " offline.");
     } else {

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OnlineCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OnlineCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OnlineCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OnlineCommand.java Sat Sep 29 05:42:59 2012
@@ -28,7 +28,7 @@ public class OnlineCommand extends Table
     return "starts the process of putting a table online";
   }
   
-  protected void doTableOp(Shell shellState, String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
+  protected void doTableOp(final Shell shellState, final String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
     if (tableName.equals(Constants.METADATA_TABLE_NAME)) {
       Shell.log.info("  The " + Constants.METADATA_TABLE_NAME + " is always online.");
     } else {

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OptUtil.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OptUtil.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OptUtil.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OptUtil.java Sat Sep 29 05:42:59 2012
@@ -29,13 +29,14 @@ public abstract class OptUtil {
   public static final String START_ROW_OPT = "b";
   public static final String END_ROW_OPT = "e";
   
-  public static String getTableOpt(CommandLine cl, Shell shellState) throws TableNotFoundException {
+  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))
+      if (!shellState.getConnector().tableOperations().exists(tableName)) {
         throw new TableNotFoundException(tableName, tableName, "specified table that doesn't exist");
+      }
     } else {
       shellState.checkTableState();
       tableName = shellState.getTableName();
@@ -48,8 +49,8 @@ public abstract class OptUtil {
     return tableOpt("tableName");
   }
   
-  public static Option tableOpt(String description) {
-    Option tableOpt = new Option(Shell.tableOption, "table", true, description);
+  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;
@@ -65,7 +66,7 @@ public abstract class OptUtil {
     }
   }
   
-  public static AdlOpt getAldOpt(CommandLine cl) {
+  public static AdlOpt getAldOpt(final CommandLine cl) {
     if (cl.hasOption(AdlOpt.ADD.opt)) {
       return AdlOpt.ADD;
     } else if (cl.hasOption(AdlOpt.DELETE.opt)) {
@@ -75,11 +76,11 @@ public abstract class OptUtil {
     }
   }
   
-  public static OptionGroup addListDeleteGroup(String name) {
-    Option addOpt = new Option(AdlOpt.ADD.opt, "add", false, "add " + name);
-    Option deleteOpt = new Option(AdlOpt.DELETE.opt, "delete", false, "delete " + name);
-    Option listOpt = new Option(AdlOpt.LIST.opt, "list", false, "list " + name + "(s)");
-    OptionGroup og = new OptionGroup();
+  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);
@@ -88,28 +89,30 @@ public abstract class OptUtil {
   }
   
   public static Option startRowOpt() {
-    Option o = new Option(START_ROW_OPT, "begin-row", true, "begin row (inclusive)");
+    final Option o = new Option(START_ROW_OPT, "begin-row", true, "begin row (inclusive)");
     o.setArgName("begin-row");
     return o;
   }
   
   public static Option endRowOpt() {
-    Option o = new Option(END_ROW_OPT, "end-row", true, "end row (inclusive)");
+    final Option o = new Option(END_ROW_OPT, "end-row", true, "end row (inclusive)");
     o.setArgName("end-row");
     return o;
   }
   
-  public static Text getStartRow(CommandLine cl) throws UnsupportedEncodingException {
-    if (cl.hasOption(START_ROW_OPT))
+  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
+    } else {
       return null;
+    }
   }
   
-  public static Text getEndRow(CommandLine cl) throws UnsupportedEncodingException {
-    if (cl.hasOption(END_ROW_OPT))
+  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
+    } else {
       return null;
+    }
   }
 }

Modified: accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/PasswdCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/PasswdCommand.java?rev=1391754&r1=1391753&r2=1391754&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/PasswdCommand.java (original)
+++ accumulo/branches/ACCUMULO-259/core/src/main/java/org/apache/accumulo/core/util/shell/commands/PasswdCommand.java Sat Sep 29 05:42:59 2012
@@ -33,9 +33,9 @@ public class PasswdCommand extends Comma
   private Option userOpt;
   
   @Override
-  public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException {
-    String currentUser = shellState.getConnector().whoami();
-    String user = cl.getOptionValue(userOpt.getOpt(), currentUser);
+  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;
@@ -61,15 +61,16 @@ public class PasswdCommand extends Comma
       return 0;
     } // user canceled
     
-    if (!password.equals(passwordConfirm))
+    if (!password.equals(passwordConfirm)) {
       throw new IllegalArgumentException("Passwords do not match");
-    
+    }
     byte[] pass = password.getBytes();
     shellState.getConnector().securityOperations().changeUserPassword(user, pass);
     // update the current credentials if the password changed was for
     // the current user
-    if (shellState.getConnector().whoami().equals(user))
+    if (shellState.getConnector().whoami().equals(user)) {
       shellState.updateUser(new AuthInfo(user, ByteBuffer.wrap(pass), shellState.getConnector().getInstance().getInstanceID()));
+    }
     Shell.log.debug("Changed password for user " + user);
     return 0;
   }
@@ -81,7 +82,7 @@ public class PasswdCommand extends Comma
   
   @Override
   public Options getOptions() {
-    Options o = new Options();
+    final Options o = new Options();
     userOpt = new Option(Shell.userOption, "user", true, "user to operate on");
     userOpt.setArgName("user");
     o.addOption(userOpt);



Mime
View raw message