You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by me...@apache.org on 2012/09/12 01:54:13 UTC
svn commit: r1383681 - in /accumulo/trunk/core/src:
main/java/org/apache/accumulo/core/util/shell/commands/
test/java/org/apache/accumulo/core/util/shell/command/
Author: medined
Date: Tue Sep 11 23:54:12 2012
New Revision: 1383681
URL: http://svn.apache.org/viewvc?rev=1383681&view=rev
Log:
add final to parameters .. guided by PMD
Modified:
accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AboutCommand.java
accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ActiveScanIterator.java
accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AddSplitsCommand.java
accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AuthenticateCommand.java
accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ClasspathCommand.java
accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ClearCommand.java
accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CloneTableCommand.java
accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CompactCommand.java
accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConfigCommand.java
accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConstraintCommand.java
accumulo/trunk/core/src/test/java/org/apache/accumulo/core/util/shell/command/FormatterCommandTest.java
Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AboutCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AboutCommand.java?rev=1383681&r1=1383680&r2=1383681&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AboutCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AboutCommand.java Tue Sep 11 23:54:12 2012
@@ -33,10 +33,11 @@ public class AboutCommand extends Comman
}
@Override
- public int execute(String fullCommand, CommandLine cl, Shell shellState) throws IOException {
+ public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException {
shellState.printInfo();
- if (cl.hasOption(verboseOption.getOpt()))
+ if (cl.hasOption(verboseOption.getOpt())) {
shellState.printVerboseInfo();
+ }
return 0;
}
@@ -47,7 +48,7 @@ public class AboutCommand extends Comman
@Override
public Options getOptions() {
- Options opts = new Options();
+ final Options opts = new Options();
verboseOption = new Option("v", "verbose", false, "display detailed session information");
opts.addOption(verboseOption);
return opts;
Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ActiveScanIterator.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ActiveScanIterator.java?rev=1383681&r1=1383680&r2=1383681&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ActiveScanIterator.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ActiveScanIterator.java Tue Sep 11 23:54:12 2012
@@ -33,25 +33,26 @@ class ActiveScanIterator implements Iter
private Iterator<String> scansIter;
private void readNext() {
- List<String> scans = new ArrayList<String>();
+ final List<String> scans = new ArrayList<String>();
while (tsIter.hasNext()) {
- String tserver = tsIter.next();
+ final String tserver = tsIter.next();
try {
- List<ActiveScan> asl = instanceOps.getActiveScans(tserver);
+ final List<ActiveScan> asl = instanceOps.getActiveScans(tserver);
- for (ActiveScan as : asl)
+ for (ActiveScan as : asl) {
scans.add(String.format("%21s |%21s |%9s |%9s |%7s |%6s |%8s |%8s |%10s |%10s |%10s | %s", tserver, as.getClient(),
Duration.format(as.getAge(), "", "-"), Duration.format(as.getLastContactTime(), "", "-"), as.getState(), as.getType(), as.getUser(),
as.getTable(), as.getColumns(), (as.getType() == ScanType.SINGLE ? as.getExtent() : "N/A"), as.getSsiList(), as.getSsio()));
-
+ }
} catch (Exception e) {
scans.add(tserver + " ERROR " + e.getMessage());
}
- if (scans.size() > 0)
+ if (scans.size() > 0) {
break;
+ }
}
scansIter = scans.iterator();
@@ -61,7 +62,7 @@ class ActiveScanIterator implements Iter
this.instanceOps = instanceOps;
this.tsIter = tservers.iterator();
- String header = String.format(" %-21s| %-21s| %-9s| %-9s| %-7s| %-6s| %-8s| %-8s| %-10s| %-10s| %-10s | %s", "TABLET SERVER", "CLIENT", "AGE", "LAST",
+ final String header = String.format(" %-21s| %-21s| %-9s| %-9s| %-7s| %-6s| %-8s| %-8s| %-10s| %-10s| %-10s | %s", "TABLET SERVER", "CLIENT", "AGE", "LAST",
"STATE", "TYPE", "USER", "TABLE", "COLUMNS", "TABLET", "ITERATORS", "ITERATOR OPTIONS");
scansIter = Collections.singletonList(header).iterator();
@@ -74,7 +75,7 @@ class ActiveScanIterator implements Iter
@Override
public String next() {
- String next = scansIter.next();
+ final String next = scansIter.next();
if (!scansIter.hasNext())
readNext();
Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AddSplitsCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AddSplitsCommand.java?rev=1383681&r1=1383680&r2=1383681&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AddSplitsCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AddSplitsCommand.java Tue Sep 11 23:54:12 2012
@@ -32,33 +32,35 @@ import org.apache.hadoop.io.Text;
public class AddSplitsCommand extends Command {
private Option optSplitsFile, base64Opt;
- public int execute(String fullCommand, CommandLine cl, Shell shellState) throws Exception {
- String tableName = OptUtil.getTableOpt(cl, shellState);
- boolean decode = cl.hasOption(base64Opt.getOpt());
+ public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
+ final String tableName = OptUtil.getTableOpt(cl, shellState);
+ final boolean decode = cl.hasOption(base64Opt.getOpt());
- TreeSet<Text> splits = new TreeSet<Text>();
+ final TreeSet<Text> splits = new TreeSet<Text>();
if (cl.hasOption(optSplitsFile.getOpt())) {
- String f = cl.getOptionValue(optSplitsFile.getOpt());
+ final String f = cl.getOptionValue(optSplitsFile.getOpt());
String line;
java.util.Scanner file = new java.util.Scanner(new File(f));
while (file.hasNextLine()) {
line = file.nextLine();
- if (!line.isEmpty())
+ if (!line.isEmpty()) {
splits.add(decode ? new Text(Base64.decodeBase64(line.getBytes())) : new Text(line));
+ }
}
} else {
- if (cl.getArgList().isEmpty())
+ if (cl.getArgList().isEmpty()) {
throw new MissingArgumentException("No split points specified");
-
+ }
for (String s : cl.getArgs()) {
splits.add(new Text(s.getBytes(Shell.CHARSET)));
}
}
- if (!shellState.getConnector().tableOperations().exists(tableName))
+ if (!shellState.getConnector().tableOperations().exists(tableName)) {
throw new TableNotFoundException(null, tableName, null);
+ }
shellState.getConnector().tableOperations().addSplits(tableName, splits);
return 0;
@@ -71,7 +73,7 @@ public class AddSplitsCommand extends Co
@Override
public Options getOptions() {
- Options o = new Options();
+ final Options o = new Options();
optSplitsFile = new Option("sf", "splits-file", true, "file with a newline-separated list of rows to split the table with");
optSplitsFile.setArgName("filename");
Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AuthenticateCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AuthenticateCommand.java?rev=1383681&r1=1383680&r2=1383681&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AuthenticateCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AuthenticateCommand.java Tue Sep 11 23:54:12 2012
@@ -29,15 +29,15 @@ import org.apache.commons.cli.CommandLin
public class AuthenticateCommand extends Command {
@Override
- public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException {
- String user = cl.getArgs()[0];
- String p = shellState.readMaskedLine("Enter current password for '" + user + "': ", '*');
+ public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException {
+ final String user = cl.getArgs()[0];
+ final String p = shellState.readMaskedLine("Enter current password for '" + user + "': ", '*');
if (p == null) {
shellState.getReader().printNewline();
return 0;
} // user canceled
- byte[] password = p.getBytes();
- boolean valid = shellState.getConnector().securityOperations().authenticateUser(user, password);
+ final byte[] password = p.getBytes();
+ final boolean valid = shellState.getConnector().securityOperations().authenticateUser(user, password);
shellState.getReader().printString((valid ? "V" : "Not v") + "alid\n");
return 0;
}
@@ -53,7 +53,7 @@ public class AuthenticateCommand extends
}
@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/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ClasspathCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ClasspathCommand.java?rev=1383681&r1=1383680&r2=1383681&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ClasspathCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ClasspathCommand.java Tue Sep 11 23:54:12 2012
@@ -23,7 +23,7 @@ import org.apache.commons.cli.CommandLin
public class ClasspathCommand extends Command {
@Override
- public int execute(String fullCommand, CommandLine cl, Shell shellState) {
+ public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) {
AccumuloClassLoader.printClassPath();
return 0;
}
Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ClearCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ClearCommand.java?rev=1383681&r1=1383680&r2=1383681&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ClearCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ClearCommand.java Tue Sep 11 23:54:12 2012
@@ -29,11 +29,11 @@ public class ClearCommand extends Comman
}
@Override
- public int execute(String fullCommand, CommandLine cl, Shell shellState) throws IOException {
+ public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException {
// custom clear screen, so I don't have to redraw the prompt twice
- if (!shellState.getReader().getTerminal().isANSISupported())
+ if (!shellState.getReader().getTerminal().isANSISupported()) {
throw new IOException("Terminal does not support ANSI commands");
-
+ }
// send the ANSI code to clear the screen
shellState.getReader().printString(((char) 27) + "[2J");
shellState.getReader().flushConsole();
Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CloneTableCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CloneTableCommand.java?rev=1383681&r1=1383680&r2=1383681&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CloneTableCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CloneTableCommand.java Tue Sep 11 23:54:12 2012
@@ -39,11 +39,11 @@ public class CloneTableCommand extends C
private Option noFlushOption;
@Override
- public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
+ public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
TableExistsException {
- HashMap<String,String> props = new HashMap<String,String>();
- HashSet<String> exclude = new HashSet<String>();
+ final HashMap<String,String> props = new HashMap<String,String>();
+ final HashSet<String> exclude = new HashSet<String>();
boolean flush = true;
if (cl.hasOption(setPropsOption.getOpt())) {
@@ -56,8 +56,9 @@ public class CloneTableCommand extends C
if (cl.hasOption(excludePropsOption.getOpt())) {
String[] keys = cl.getOptionValue(excludePropsOption.getOpt()).split(",");
- for (String key : keys)
+ for (String key : keys) {
exclude.add(key);
+ }
}
if (cl.hasOption(noFlushOption.getOpt())) {
@@ -78,13 +79,13 @@ public class CloneTableCommand extends C
return "clones a table";
}
- public void registerCompletion(Token root, Map<Command.CompletionSet,Set<String>> completionSet) {
+ public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> completionSet) {
registerCompletionForTables(root, completionSet);
}
@Override
public Options getOptions() {
- Options o = new Options();
+ final Options o = new Options();
setPropsOption = new Option("s", "set", true, "set initial properties before the table comes online. Expects <prop>=<value>{,<prop>=<value>}");
o.addOption(setPropsOption);
excludePropsOption = new Option("e", "exclude", true, "exclude properties that should not be copied from source table. Expects <prop>{,<prop>}");
Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CompactCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CompactCommand.java?rev=1383681&r1=1383680&r2=1383681&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CompactCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CompactCommand.java Tue Sep 11 23:54:12 2012
@@ -38,12 +38,12 @@ public class CompactCommand extends Tabl
return "sets all tablets for a table to major compact as soon as possible (based on current time)";
}
- protected void doTableOp(Shell shellState, String tableName) throws AccumuloException, AccumuloSecurityException {
+ protected void doTableOp(final Shell shellState, final String tableName) throws AccumuloException, AccumuloSecurityException {
// compact the tables
try {
- if (wait)
+ if (wait) {
Shell.log.info("Compacting table ...");
-
+ }
shellState.getConnector().tableOperations().compact(tableName, startRow, endRow, flush, wait);
Shell.log.info("Compaction of table " + tableName + " " + (wait ? "completed" : "started") + " for given range");
@@ -53,7 +53,7 @@ public class CompactCommand extends Tabl
}
@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 {
flush = !cl.hasOption(noFlushOption.getOpt());
startRow = OptUtil.getStartRow(cl);
endRow = OptUtil.getEndRow(cl);
@@ -64,7 +64,7 @@ public class CompactCommand extends Tabl
@Override
public Options getOptions() {
- Options opts = super.getOptions();
+ final Options opts = super.getOptions();
opts.addOption(OptUtil.startRowOpt());
opts.addOption(OptUtil.endRowOpt());
Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConfigCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConfigCommand.java?rev=1383681&r1=1383680&r2=1383681&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConfigCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConfigCommand.java Tue Sep 11 23:54:12 2012
@@ -18,6 +18,7 @@ package org.apache.accumulo.core.util.sh
import java.io.IOException;
import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@@ -47,116 +48,121 @@ public class ConfigCommand extends Comma
private ConsoleReader reader;
@Override
- public void registerCompletion(Token root, Map<Command.CompletionSet,Set<String>> completionSet) {
- Token cmd = new Token(getName());
- Token sub = new Token("-" + setOpt.getOpt());
+ public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> completionSet) {
+ final Token cmd = new Token(getName());
+ final Token sub = new Token("-" + setOpt.getOpt());
for (Property p : Property.values()) {
- if (!(p.getKey().endsWith(".")))
+ if (!(p.getKey().endsWith("."))) {
sub.addSubcommand(new Token(p.toString()));
+ }
}
cmd.addSubcommand(sub);
root.addSubcommand(cmd);
}
- public int execute(String fullCommand, CommandLine cl, Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
+ public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
IOException, ClassNotFoundException {
reader = shellState.getReader();
- String tableName = cl.getOptionValue(tableOpt.getOpt());
- if (tableName != null && !shellState.getConnector().tableOperations().exists(tableName))
+ final String tableName = cl.getOptionValue(tableOpt.getOpt());
+ if (tableName != null && !shellState.getConnector().tableOperations().exists(tableName)) {
throw new TableNotFoundException(null, tableName, null);
-
+ }
if (cl.hasOption(deleteOpt.getOpt())) {
// delete property from table
String property = cl.getOptionValue(deleteOpt.getOpt());
- if (property.contains("="))
+ if (property.contains("=")) {
throw new BadArgumentException("Invalid '=' operator in delete operation.", fullCommand, fullCommand.indexOf('='));
+ }
if (tableName != null) {
- if (!Property.isValidTablePropertyKey(property))
+ if (!Property.isValidTablePropertyKey(property)) {
Shell.log.warn("Invalid per-table property : " + property + ", still removing from zookeeper if it's there.");
-
+ }
shellState.getConnector().tableOperations().removeProperty(tableName, property);
Shell.log.debug("Successfully deleted table configuration option.");
} else {
- if (!Property.isValidZooPropertyKey(property))
+ if (!Property.isValidZooPropertyKey(property)) {
Shell.log.warn("Invalid per-table property : " + property + ", still removing from zookeeper if it's there.");
+ }
shellState.getConnector().instanceOperations().removeProperty(property);
Shell.log.debug("Successfully deleted system configuration option");
}
} else if (cl.hasOption(setOpt.getOpt())) {
// set property on table
String property = cl.getOptionValue(setOpt.getOpt()), value = null;
- if (!property.contains("="))
+ if (!property.contains("=")) {
throw new BadArgumentException("Missing '=' operator in set operation.", fullCommand, fullCommand.indexOf(property));
-
- String pair[] = property.split("=", 2);
+ }
+ final String pair[] = property.split("=", 2);
property = pair[0];
value = pair[1];
if (tableName != null) {
- if (!Property.isValidTablePropertyKey(property))
+ if (!Property.isValidTablePropertyKey(property)) {
throw new BadArgumentException("Invalid per-table property.", fullCommand, fullCommand.indexOf(property));
-
- if (property.equals(Property.TABLE_DEFAULT_SCANTIME_VISIBILITY.getKey()))
+ }
+ if (property.equals(Property.TABLE_DEFAULT_SCANTIME_VISIBILITY.getKey())) {
new ColumnVisibility(value); // validate that it is a valid expression
-
+ }
shellState.getConnector().tableOperations().setProperty(tableName, property, value);
Shell.log.debug("Successfully set table configuration option.");
} else {
- if (!Property.isValidZooPropertyKey(property))
+ if (!Property.isValidZooPropertyKey(property)) {
throw new BadArgumentException("Property cannot be modified in zookeeper", fullCommand, fullCommand.indexOf(property));
-
+ }
shellState.getConnector().instanceOperations().setProperty(property, value);
Shell.log.debug("Successfully set system configuration option");
}
} else {
// display properties
- TreeMap<String,String> systemConfig = new TreeMap<String,String>();
+ final TreeMap<String,String> systemConfig = new TreeMap<String,String>();
systemConfig.putAll(shellState.getConnector().instanceOperations().getSystemConfiguration());
- TreeMap<String,String> siteConfig = new TreeMap<String,String>();
+ final TreeMap<String,String> siteConfig = new TreeMap<String,String>();
siteConfig.putAll(shellState.getConnector().instanceOperations().getSiteConfiguration());
- TreeMap<String,String> defaults = new TreeMap<String,String>();
- for (Entry<String,String> defaultEntry : AccumuloConfiguration.getDefaultConfiguration())
+ final TreeMap<String,String> defaults = new TreeMap<String,String>();
+ for (Entry<String,String> defaultEntry : AccumuloConfiguration.getDefaultConfiguration()) {
defaults.put(defaultEntry.getKey(), defaultEntry.getValue());
-
+ }
Iterable<Entry<String,String>> acuconf = shellState.getConnector().instanceOperations().getSystemConfiguration().entrySet();
- if (tableName != null)
+ if (tableName != null) {
acuconf = shellState.getConnector().tableOperations().getProperties(tableName);
-
- TreeMap<String,String> sortedConf = new TreeMap<String,String>();
+ }
+ final TreeMap<String,String> sortedConf = new TreeMap<String,String>();
for (Entry<String,String> propEntry : acuconf) {
sortedConf.put(propEntry.getKey(), propEntry.getValue());
}
for (Entry<String,String> propEntry : acuconf) {
- String key = propEntry.getKey();
+ final String key = propEntry.getKey();
// only show properties with similar names to that
// specified, or all of them if none specified
- if (cl.hasOption(filterOpt.getOpt()) && !key.contains(cl.getOptionValue(filterOpt.getOpt())))
+ if (cl.hasOption(filterOpt.getOpt()) && !key.contains(cl.getOptionValue(filterOpt.getOpt()))) {
continue;
- if (tableName != null && !Property.isValidTablePropertyKey(key))
+ }
+ if (tableName != null && !Property.isValidTablePropertyKey(key)) {
continue;
+ }
COL2 = Math.max(COL2, propEntry.getKey().length() + 3);
}
- ArrayList<String> output = new ArrayList<String>();
+ final ArrayList<String> output = new ArrayList<String>();
printConfHeader(output);
for (Entry<String,String> propEntry : sortedConf.entrySet()) {
- String key = propEntry.getKey();
+ final String key = propEntry.getKey();
// only show properties with similar names to that
// specified, or all of them if none specified
- if (cl.hasOption(filterOpt.getOpt()) && !key.contains(cl.getOptionValue(filterOpt.getOpt())))
+ if (cl.hasOption(filterOpt.getOpt()) && !key.contains(cl.getOptionValue(filterOpt.getOpt()))) {
continue;
-
- if (tableName != null && !Property.isValidTablePropertyKey(key))
+ }
+ if (tableName != null && !Property.isValidTablePropertyKey(key)) {
continue;
-
- String siteVal = siteConfig.get(key);
- String sysVal = systemConfig.get(key);
+ }
+ final String siteVal = siteConfig.get(key);
+ final String sysVal = systemConfig.get(key);
String curVal = propEntry.getValue();
String dfault = defaults.get(key);
boolean printed = false;
@@ -180,8 +186,9 @@ public class ConfigCommand extends Comma
}
// show per-table value only if it is different (overridden)
- if (tableName != null && !curVal.equals(sysVal))
+ if (tableName != null && !curVal.equals(sysVal)) {
printConfLine(output, "table", printed ? " @override" : key, curVal);
+ }
}
printConfFooter(output);
shellState.printLines(output.iterator(), !cl.hasOption(disablePaginationOpt.getOpt()));
@@ -189,20 +196,21 @@ public class ConfigCommand extends Comma
return 0;
}
- private void printConfHeader(ArrayList<String> output) {
+ private void printConfHeader(List<String> output) {
printConfFooter(output);
output.add(String.format("%-" + COL1 + "s | %-" + COL2 + "s | %s", "SCOPE", "NAME", "VALUE"));
printConfFooter(output);
}
- private void printConfLine(ArrayList<String> output, String s1, String s2, String s3) {
- if (s2.length() < COL2)
+ private void printConfLine(List<String> output, String s1, String s2, String s3) {
+ if (s2.length() < COL2) {
s2 += " " + Shell.repeat(".", COL2 - s2.length() - 1);
+ }
output.add(String.format("%-" + COL1 + "s | %-" + COL2 + "s | %s", s1, s2,
s3.replace("\n", "\n" + Shell.repeat(" ", COL1 + 1) + "|" + Shell.repeat(" ", COL2 + 2) + "|" + " ")));
}
- private void printConfFooter(ArrayList<String> output) {
+ private void printConfFooter(List<String> output) {
int col3 = Math.max(1, Math.min(Integer.MAX_VALUE, reader.getTermwidth() - COL1 - COL2 - 6));
output.add(String.format("%" + COL1 + "s-+-%" + COL2 + "s-+-%-" + col3 + "s", Shell.repeat("-", COL1), Shell.repeat("-", COL2), Shell.repeat("-", col3)));
}
@@ -214,8 +222,8 @@ public class ConfigCommand extends Comma
@Override
public Options getOptions() {
- Options o = new Options();
- OptionGroup og = new OptionGroup();
+ final Options o = new Options();
+ final OptionGroup og = new OptionGroup();
tableOpt = new Option(Shell.tableOption, "table", true, "table to display/set/delete properties for");
deleteOpt = new Option("d", "delete", true, "delete a per-table property");
Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConstraintCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConstraintCommand.java?rev=1383681&r1=1383680&r2=1383681&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConstraintCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConstraintCommand.java Tue Sep 11 23:54:12 2012
@@ -28,16 +28,17 @@ import org.apache.commons.cli.Options;
public class ConstraintCommand 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);
int i;
switch (OptUtil.getAldOpt(cl)) {
case ADD:
for (String constraint : cl.getArgs()) {
- if (!shellState.getConnector().instanceOperations().testClassLoad(constraint, Constraint.class.getName()))
+ if (!shellState.getConnector().instanceOperations().testClassLoad(constraint, Constraint.class.getName())) {
throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Servers are unable to load " + constraint + " as type "
+ Constraint.class.getName());
+ }
i = shellState.getConnector().tableOperations().addConstraint(tableName, constraint);
shellState.getReader().printString("Added constraint " + constraint + " to table " + tableName + " with number " + i + "\n");
}
@@ -50,8 +51,9 @@ public class ConstraintCommand extends C
}
break;
case LIST:
- for (Entry<String,Integer> property : shellState.getConnector().tableOperations().listConstraints(tableName).entrySet())
+ for (Entry<String,Integer> property : shellState.getConnector().tableOperations().listConstraints(tableName).entrySet()) {
shellState.getReader().printString(property.toString() + "\n");
+ }
}
return 0;
@@ -74,7 +76,7 @@ public class ConstraintCommand extends C
@Override
public Options getOptions() {
- Options o = new Options();
+ final Options o = new Options();
o.addOptionGroup(OptUtil.addListDeleteGroup("constraint"));
o.addOption(OptUtil.tableOpt("table to add, delete, or list constraints for"));
return o;
Modified: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/util/shell/command/FormatterCommandTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/util/shell/command/FormatterCommandTest.java?rev=1383681&r1=1383680&r2=1383681&view=diff
==============================================================================
--- accumulo/trunk/core/src/test/java/org/apache/accumulo/core/util/shell/command/FormatterCommandTest.java (original)
+++ accumulo/trunk/core/src/test/java/org/apache/accumulo/core/util/shell/command/FormatterCommandTest.java Tue Sep 11 23:54:12 2012
@@ -50,14 +50,14 @@ public class FormatterCommandTest {
// Keep the Shell AUDIT log off the test output
Logger.getLogger(Shell.class).setLevel(Level.WARN);
- String[] args = new String[] {"-fake", "-u", "root", "-p", "passwd"};
+ final String[] args = new String[] {"-fake", "-u", "root", "-p", "passwd"};
- String[] commands = createCommands();
+ final String[] commands = createCommands();
in = MockShell.makeCommands(commands);
writer = new StringWriter();
- MockShell shell = new MockShell(in, writer);
+ final MockShell shell = new MockShell(in, writer);
shell.config(args);
// Can't call createtable in the shell with MockAccumulo
@@ -66,24 +66,23 @@ public class FormatterCommandTest {
try {
shell.start();
} catch (Exception e) {
- System.err.println(e.getMessage());
Assert.fail("Exception while running commands: " + e.getMessage());
}
shell.getReader().flushConsole();
- String[] output = StringUtils.split(writer.toString(), '\n');
+ final String[] output = StringUtils.split(writer.toString(), '\n');
boolean formatterOn = false;
- String[] expectedDefault = new String[] {
+ final String[] expectedDefault = new String[] {
"row cf:cq [] 1234abcd",
"row cf1:cq1 [] 9876fedc",
"row2 cf:cq [] 13579bdf",
"row2 cf1:cq [] 2468ace"
};
- String[] expectedFormatted = new String[] {
+ final String[] expectedFormatted = new String[] {
"row cf:cq [] 0x31 0x32 0x33 0x34 0x61 0x62 0x63 0x64",
"row cf1:cq1 [] 0x39 0x38 0x37 0x36 0x66 0x65 0x64 0x63",
"row2 cf:cq [] 0x31 0x33 0x35 0x37 0x39 0x62 0x64 0x66",
@@ -92,7 +91,7 @@ public class FormatterCommandTest {
int outputIndex = 0;
while (outputIndex < output.length) {
- String line = output[outputIndex];
+ final String line = output[outputIndex];
if (line.startsWith("root@mock-instance")) {
if (line.contains("formatter -t test -f org.apache.accumulo.core.util.shell.command.FormatterCommandTest$HexFormatter")) {
@@ -112,10 +111,8 @@ public class FormatterCommandTest {
}
// Ensure each output is what we expected
- while (expectedIndex + outputIndex < output.length &&
- expectedIndex < expectedFormatted.length) {
+ while (expectedIndex + outputIndex < output.length && expectedIndex < expectedFormatted.length) {
Assert.assertEquals(comparisonData[expectedIndex].trim(), output[expectedIndex + outputIndex].trim());
-
expectedIndex++;
}
@@ -148,8 +145,8 @@ public class FormatterCommandTest {
private Iterator<Entry<Key, Value>> iter = null;
private boolean printTs = false;
- private final String tab = "\t";
- private final String newline = "\n";
+ private final static String tab = "\t";
+ private final static String newline = "\n";
public HexFormatter() {}
@@ -166,7 +163,7 @@ public class FormatterCommandTest {
*/
@Override
public String next() {
- Entry<Key, Value> entry = iter.next();
+ final Entry<Key, Value> entry = iter.next();
String key;
@@ -177,16 +174,16 @@ public class FormatterCommandTest {
key = entry.getKey().toStringNoTime();
}
- Value v = entry.getValue();
+ final Value v = entry.getValue();
// Approximate how much space we'll need
- StringBuilder sb = new StringBuilder(key.length() + v.getSize() * 5);
+ final StringBuilder sb = new StringBuilder(key.length() + v.getSize() * 5);
sb.append(key).append(tab);
for (byte b : v.get()) {
if ((b >= 48 && b <= 57) || (b >= 97 || b <= 102)) {
- sb.append(String.format("0x%x ", new Integer(b)));
+ sb.append(String.format("0x%x ", Integer.valueOf(b)));
}
}
@@ -200,14 +197,13 @@ public class FormatterCommandTest {
*/
@Override
public void remove() {
- return;
}
/* (non-Javadoc)
* @see org.apache.accumulo.core.util.format.Formatter#initialize(java.lang.Iterable, boolean)
*/
@Override
- public void initialize(Iterable<Entry<Key,Value>> scanner, boolean printTimestamps) {
+ public void initialize(final Iterable<Entry<Key,Value>> scanner, final boolean printTimestamps) {
this.iter = scanner.iterator();
this.printTs = printTimestamps;
}