You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2013/12/05 00:58:29 UTC
[37/50] [abbrv] ACCUMULO-802 Renamed "TableNamespace" to "Namespace"
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/security/NamespacePermission.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/NamespacePermission.java b/core/src/main/java/org/apache/accumulo/core/security/NamespacePermission.java
new file mode 100644
index 0000000..fb6847b
--- /dev/null
+++ b/core/src/main/java/org/apache/accumulo/core/security/NamespacePermission.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.core.security;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public enum NamespacePermission {
+ // One can add new permissions, with new numbers, but please don't change or use numbers previously assigned
+ READ((byte) 0),
+ WRITE((byte) 1),
+ ALTER_NAMESPACE((byte) 2),
+ GRANT((byte) 3),
+ ALTER_TABLE((byte) 4),
+ CREATE_TABLE((byte) 5),
+ DROP_TABLE((byte) 6);
+
+ final private byte permID;
+
+ final private static NamespacePermission mapping[] = new NamespacePermission[8];
+ static {
+ for (NamespacePermission perm : NamespacePermission.values())
+ mapping[perm.permID] = perm;
+ }
+
+ private NamespacePermission(byte id) {
+ this.permID = id;
+ }
+
+ public byte getId() {
+ return this.permID;
+ }
+
+ public static List<String> printableValues() {
+ NamespacePermission[] a = NamespacePermission.values();
+
+ List<String> list = new ArrayList<String>(a.length);
+
+ for (NamespacePermission p : a)
+ list.add("Namespace." + p);
+
+ return list;
+ }
+
+ public static NamespacePermission getPermissionById(byte id) {
+ NamespacePermission result = mapping[id];
+ if (result != null)
+ return result;
+ throw new IndexOutOfBoundsException("No such permission");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/security/TableNamespacePermission.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/TableNamespacePermission.java b/core/src/main/java/org/apache/accumulo/core/security/TableNamespacePermission.java
deleted file mode 100644
index 2cf57c7..0000000
--- a/core/src/main/java/org/apache/accumulo/core/security/TableNamespacePermission.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.core.security;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public enum TableNamespacePermission {
- // One can add new permissions, with new numbers, but please don't change or use numbers previously assigned
- READ((byte) 0),
- WRITE((byte) 1),
- ALTER_NAMESPACE((byte) 2),
- GRANT((byte) 3),
- ALTER_TABLE((byte) 4),
- CREATE_TABLE((byte) 5),
- DROP_TABLE((byte) 6);
-
- final private byte permID;
-
- final private static TableNamespacePermission mapping[] = new TableNamespacePermission[8];
- static {
- for (TableNamespacePermission perm : TableNamespacePermission.values())
- mapping[perm.permID] = perm;
- }
-
- private TableNamespacePermission(byte id) {
- this.permID = id;
- }
-
- public byte getId() {
- return this.permID;
- }
-
- public static List<String> printableValues() {
- TableNamespacePermission[] a = TableNamespacePermission.values();
-
- List<String> list = new ArrayList<String>(a.length);
-
- for (TableNamespacePermission p : a)
- list.add("Namespace." + p);
-
- return list;
- }
-
- public static TableNamespacePermission getPermissionById(byte id) {
- TableNamespacePermission result = mapping[id];
- if (result != null)
- return result;
- throw new IndexOutOfBoundsException("No such permission");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java b/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
index 7d13d5f..3a32d8e 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
@@ -727,12 +727,12 @@ public class Shell extends ShellOptions {
userlist = Collections.emptySet();
}
- Set<String> tableNamespaces = null;
+ Set<String> namespaces = null;
try {
- tableNamespaces = connector.tableNamespaceOperations().list();
+ namespaces = connector.namespaceOperations().list();
} catch (Exception e) {
- log.debug("Unable to obtain list of table namespaces", e);
- tableNamespaces = Collections.emptySet();
+ log.debug("Unable to obtain list of namespaces", e);
+ namespaces = Collections.emptySet();
}
Map<Command.CompletionSet,Set<String>> options = new HashMap<Command.CompletionSet,Set<String>>();
@@ -743,18 +743,18 @@ public class Shell extends ShellOptions {
Set<String> modifiedUserlist = new HashSet<String>();
Set<String> modifiedTablenames = new HashSet<String>();
- Set<String> modifiedTableNamespaces = new HashSet<String>();
+ Set<String> modifiedNamespaces = new HashSet<String>();
for (String a : tableNames)
modifiedTablenames.add(a.replaceAll("([\\s'\"])", "\\\\$1"));
for (String a : userlist)
modifiedUserlist.add(a.replaceAll("([\\s'\"])", "\\\\$1"));
- for (String a : tableNamespaces)
- modifiedTableNamespaces.add(a.replaceAll("([\\s'\"])", "\\\\$1"));
+ for (String a : namespaces)
+ modifiedNamespaces.add(a.replaceAll("([\\s'\"])", "\\\\$1"));
options.put(Command.CompletionSet.USERNAMES, modifiedUserlist);
options.put(Command.CompletionSet.TABLENAMES, modifiedTablenames);
- options.put(Command.CompletionSet.TABLENAMESPACES, modifiedTableNamespaces);
+ options.put(Command.CompletionSet.NAMESPACES, modifiedNamespaces);
options.put(Command.CompletionSet.COMMANDS, commands);
for (Command[] cmdGroup : commandGrouping.values()) {
@@ -775,7 +775,7 @@ public class Shell extends ShellOptions {
public static abstract class Command {
// Helper methods for completion
public enum CompletionSet {
- TABLENAMES, USERNAMES, COMMANDS, TABLENAMESPACES
+ TABLENAMES, USERNAMES, COMMANDS, NAMESPACES
}
static Set<String> getCommandNames(Map<CompletionSet,Set<String>> objects) {
@@ -790,8 +790,8 @@ public class Shell extends ShellOptions {
return objects.get(CompletionSet.USERNAMES);
}
- static Set<String> getTableNamespaces(Map<CompletionSet,Set<String>> objects) {
- return objects.get(CompletionSet.TABLENAMESPACES);
+ static Set<String> getNamespaces(Map<CompletionSet,Set<String>> objects) {
+ return objects.get(CompletionSet.NAMESPACES);
}
public void registerCompletionGeneral(Token root, Set<String> args, boolean caseSens) {
@@ -816,8 +816,8 @@ public class Shell extends ShellOptions {
registerCompletionGeneral(root, completionSet.get(CompletionSet.COMMANDS), false);
}
- public void registerCompletionForTableNamespaces(Token root, Map<CompletionSet,Set<String>> completionSet) {
- registerCompletionGeneral(root, completionSet.get(CompletionSet.TABLENAMESPACES), true);
+ public void registerCompletionForNamespaces(Token root, Map<CompletionSet,Set<String>> completionSet) {
+ registerCompletionGeneral(root, completionSet.get(CompletionSet.NAMESPACES), true);
}
// abstract methods to override
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/ShellCompletor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/ShellCompletor.java b/core/src/main/java/org/apache/accumulo/core/util/shell/ShellCompletor.java
index 4046714..c64e0c7 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/ShellCompletor.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/ShellCompletor.java
@@ -28,23 +28,24 @@ import org.apache.accumulo.core.util.shell.Shell.Command.CompletionSet;
import org.apache.accumulo.core.util.shell.commands.QuotedStringTokenizer;
public class ShellCompletor implements Completer {
-
+
// private static final Logger log = Logger.getLogger(ShellCompletor.class);
-
+
Map<CompletionSet,Set<String>> options;
Token root = null;
-
+
public ShellCompletor() {}
-
+
public ShellCompletor(Token root) {
this.root = root;
}
-
+
public ShellCompletor(Token rootToken, Map<CompletionSet,Set<String>> options) {
this.root = rootToken;
this.options = options;
}
-
+
+ @Override
@SuppressWarnings({"unchecked", "rawtypes"})
public int complete(String buffer, int cursor, List candidates) {
try {
@@ -55,33 +56,33 @@ public class ShellCompletor implements Completer {
return cursor;
}
}
-
+
private int _complete(String fullBuffer, int cursor, List<String> candidates) {
boolean inTableFlag = false, inUserFlag = false, inNamespaceFlag = false;
// Only want to grab the buffer up to the cursor because
// the user could be trying to tab complete in the middle
// of the line
String buffer = fullBuffer.substring(0, cursor);
-
+
Token current_command_token = root;
String current_string_token = null;
boolean end_space = buffer.endsWith(" ");
-
+
// tabbing with no text
if (buffer.length() == 0) {
candidates.addAll(root.getSubcommandNames());
return 0;
}
-
+
String prefix = "";
-
+
QuotedStringTokenizer qst = new QuotedStringTokenizer(buffer);
-
+
Iterator<String> iter = qst.iterator();
while (iter.hasNext()) {
current_string_token = iter.next();
current_string_token = current_string_token.replaceAll("([\\s'\"])", "\\\\$1");
-
+
if (!iter.hasNext()) {
// if we end in a space and that space isn't part of the last token
// (which would be the case at the start of a quote) OR the buffer
@@ -89,7 +90,7 @@ public class ShellCompletor implements Completer {
// and not complete the current command.
if (end_space && !current_string_token.endsWith(" ") || buffer.endsWith("\"")) {
// match subcommands
-
+
// we're in a subcommand so try to match the universal
// option flags if we're there
if (current_string_token.trim().equals("-" + Shell.tableOption)) {
@@ -98,19 +99,19 @@ public class ShellCompletor implements Completer {
} else if (current_string_token.trim().equals("-" + Shell.userOption)) {
candidates.addAll(options.get(Shell.Command.CompletionSet.USERNAMES));
prefix += "-" + Shell.userOption + " ";
- } else if (current_string_token.trim().equals("-" + Shell.tableNamespaceOption)) {
- candidates.addAll(options.get(Shell.Command.CompletionSet.TABLENAMESPACES));
- prefix += "-" + Shell.tableNamespaceOption + " ";
- }else if (current_command_token != null) {
+ } else if (current_string_token.trim().equals("-" + Shell.namespaceOption)) {
+ candidates.addAll(options.get(Shell.Command.CompletionSet.NAMESPACES));
+ prefix += "-" + Shell.namespaceOption + " ";
+ } else if (current_command_token != null) {
Token next = current_command_token.getSubcommand(current_string_token);
if (next != null) {
current_command_token = next;
-
+
if (current_command_token.getCaseSensitive())
prefix += current_string_token + " ";
else
prefix += current_string_token.toUpperCase() + " ";
-
+
candidates.addAll(current_command_token.getSubcommandNames());
}
}
@@ -118,7 +119,7 @@ public class ShellCompletor implements Completer {
return (prefix.length());
}
// need to match current command
- // if we're in -t <table>, -u <user>, or -tn <tableNamespace> complete those
+ // if we're in -t <table>, -u <user>, or -tn <namespace> complete those
if (inTableFlag) {
for (String a : options.get(Shell.Command.CompletionSet.TABLENAMES))
if (a.startsWith(current_string_token))
@@ -128,33 +129,33 @@ public class ShellCompletor implements Completer {
if (a.startsWith(current_string_token))
candidates.add(a);
} else if (inNamespaceFlag) {
- for (String a : options.get(Shell.Command.CompletionSet.TABLENAMESPACES))
+ for (String a : options.get(Shell.Command.CompletionSet.NAMESPACES))
if (a.startsWith(current_string_token))
candidates.add(a);
} else if (current_command_token != null)
candidates.addAll(current_command_token.getSubcommandNames(current_string_token));
-
+
Collections.sort(candidates);
return (prefix.length());
}
-
+
if (current_string_token.trim().equals("-" + Shell.tableOption))
inTableFlag = true;
else if (current_string_token.trim().equals("-" + Shell.userOption))
inUserFlag = true;
- else if (current_string_token.trim().equals("-" + Shell.tableNamespaceOption))
+ else if (current_string_token.trim().equals("-" + Shell.namespaceOption))
inNamespaceFlag = true;
else
inUserFlag = inTableFlag = inNamespaceFlag = false;
-
+
if (current_command_token != null && current_command_token.getCaseSensitive())
prefix += current_string_token + " ";
else
prefix += current_string_token.toUpperCase() + " ";
-
+
if (current_command_token != null && current_command_token.getSubcommandNames().contains(current_string_token))
current_command_token = current_command_token.getSubcommand(current_string_token);
-
+
}
return 0;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/ShellOptions.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/ShellOptions.java b/core/src/main/java/org/apache/accumulo/core/util/shell/ShellOptions.java
index af55d8d..4e573ed 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/ShellOptions.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/ShellOptions.java
@@ -25,9 +25,9 @@ public abstract class ShellOptions {
// Global options flags
public static final String userOption = "u";
public static final String tableOption = "t";
- public static final String tableNamespaceOption = "tn";
+ public static final String namespaceOption = "ns";
public static final String helpOption = "?";
public static final String helpLongOption = "help";
-
+
final Option helpOpt = new Option(helpOption, helpLongOption, false, "display this help");
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConfigCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConfigCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConfigCommand.java
index 1e49c4d..90d02de 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConfigCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConfigCommand.java
@@ -28,9 +28,9 @@ import jline.console.ConsoleReader;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.TableNamespaceNotFoundException;
+import org.apache.accumulo.core.client.NamespaceNotFoundException;
import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.impl.TableNamespaces;
+import org.apache.accumulo.core.client.impl.Namespaces;
import org.apache.accumulo.core.client.impl.Tables;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.Property;
@@ -46,11 +46,11 @@ import org.apache.commons.cli.OptionGroup;
import org.apache.commons.cli.Options;
public class ConfigCommand extends Command {
- private Option tableOpt, deleteOpt, setOpt, filterOpt, disablePaginationOpt, outputFileOpt, tableNamespaceOpt;
-
+ private Option tableOpt, deleteOpt, setOpt, filterOpt, disablePaginationOpt, outputFileOpt, namespaceOpt;
+
private int COL1 = 10, COL2 = 7;
private ConsoleReader reader;
-
+
@Override
public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> completionSet) {
final Token cmd = new Token(getName());
@@ -63,18 +63,19 @@ public class ConfigCommand extends Command {
cmd.addSubcommand(sub);
root.addSubcommand(cmd);
}
-
+
+ @Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException,
- TableNotFoundException, IOException, ClassNotFoundException, TableNamespaceNotFoundException {
+ TableNotFoundException, IOException, ClassNotFoundException, NamespaceNotFoundException {
reader = shellState.getReader();
-
+
final String tableName = cl.getOptionValue(tableOpt.getOpt());
if (tableName != null && !shellState.getConnector().tableOperations().exists(tableName)) {
throw new TableNotFoundException(null, tableName, null);
}
- final String tableNamespace = cl.getOptionValue(tableNamespaceOpt.getOpt());
- if (tableNamespace != null && !shellState.getConnector().tableNamespaceOperations().exists(tableNamespace)) {
- throw new TableNamespaceNotFoundException(null, tableNamespace, null);
+ final String namespace = cl.getOptionValue(namespaceOpt.getOpt());
+ if (namespace != null && !shellState.getConnector().namespaceOperations().exists(namespace)) {
+ throw new NamespaceNotFoundException(null, namespace, null);
}
if (cl.hasOption(deleteOpt.getOpt())) {
// delete property from table
@@ -88,12 +89,12 @@ public class ConfigCommand extends Command {
}
shellState.getConnector().tableOperations().removeProperty(tableName, property);
Shell.log.debug("Successfully deleted table configuration option.");
- } else if (tableNamespace != null) {
+ } else if (namespace != null) {
if (!Property.isValidTablePropertyKey(property)) {
Shell.log.warn("Invalid per-table property : " + property + ", still removing from zookeeper if it's there.");
}
- shellState.getConnector().tableNamespaceOperations().removeProperty(tableNamespace, property);
- Shell.log.debug("Successfully deleted table namespace configuration option.");
+ shellState.getConnector().namespaceOperations().removeProperty(namespace, property);
+ Shell.log.debug("Successfully deleted namespace configuration option.");
} else {
if (!Property.isValidZooPropertyKey(property)) {
Shell.log.warn("Invalid per-table property : " + property + ", still removing from zookeeper if it's there.");
@@ -110,7 +111,7 @@ public class ConfigCommand extends Command {
final String pair[] = property.split("=", 2);
property = pair[0];
value = pair[1];
-
+
if (tableName != null) {
if (!Property.isValidTablePropertyKey(property)) {
throw new BadArgumentException("Invalid per-table property.", fullCommand, fullCommand.indexOf(property));
@@ -120,14 +121,14 @@ public class ConfigCommand extends Command {
}
shellState.getConnector().tableOperations().setProperty(tableName, property, value);
Shell.log.debug("Successfully set table configuration option.");
- } else if (tableNamespace != null) {
+ } else if (namespace != null) {
if (!Property.isValidTablePropertyKey(property)) {
throw new BadArgumentException("Invalid per-table property.", fullCommand, fullCommand.indexOf(property));
}
if (property.equals(Property.TABLE_DEFAULT_SCANTIME_VISIBILITY.getKey())) {
new ColumnVisibility(value); // validate that it is a valid expression
}
- shellState.getConnector().tableNamespaceOperations().setProperty(tableNamespace, property, value);
+ shellState.getConnector().namespaceOperations().setProperty(namespace, property, value);
Shell.log.debug("Successfully set table configuration option.");
} else {
if (!Property.isValidZooPropertyKey(property)) {
@@ -140,38 +141,38 @@ public class ConfigCommand extends Command {
// display properties
final TreeMap<String,String> systemConfig = new TreeMap<String,String>();
systemConfig.putAll(shellState.getConnector().instanceOperations().getSystemConfiguration());
-
+
final String outputFile = cl.getOptionValue(outputFileOpt.getOpt());
final PrintFile printFile = outputFile == null ? null : new PrintFile(outputFile);
-
+
final TreeMap<String,String> siteConfig = new TreeMap<String,String>();
siteConfig.putAll(shellState.getConnector().instanceOperations().getSiteConfiguration());
-
+
final TreeMap<String,String> defaults = new TreeMap<String,String>();
for (Entry<String,String> defaultEntry : AccumuloConfiguration.getDefaultConfiguration()) {
defaults.put(defaultEntry.getKey(), defaultEntry.getValue());
}
-
+
final TreeMap<String,String> namespaceConfig = new TreeMap<String,String>();
if (tableName != null) {
- String n = TableNamespaces.getNamespaceName(shellState.getInstance(),
+ String n = Namespaces.getNamespaceName(shellState.getInstance(),
Tables.getNamespace(shellState.getInstance(), Tables.getTableId(shellState.getInstance(), tableName)));
- for (Entry<String,String> e : shellState.getConnector().tableNamespaceOperations().getProperties(n)) {
+ for (Entry<String,String> e : shellState.getConnector().namespaceOperations().getProperties(n)) {
namespaceConfig.put(e.getKey(), e.getValue());
}
}
-
+
Iterable<Entry<String,String>> acuconf = shellState.getConnector().instanceOperations().getSystemConfiguration().entrySet();
if (tableName != null) {
acuconf = shellState.getConnector().tableOperations().getProperties(tableName);
- } else if (tableNamespace != null) {
- acuconf = shellState.getConnector().tableNamespaceOperations().getProperties(tableNamespace);
+ } else if (namespace != null) {
+ acuconf = shellState.getConnector().namespaceOperations().getProperties(namespace);
}
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) {
final String key = propEntry.getKey();
// only show properties with similar names to that
@@ -179,24 +180,24 @@ public class ConfigCommand extends Command {
if (cl.hasOption(filterOpt.getOpt()) && !key.contains(cl.getOptionValue(filterOpt.getOpt()))) {
continue;
}
- if ((tableName != null || tableNamespace != null) && !Property.isValidTablePropertyKey(key)) {
+ if ((tableName != null || namespace != null) && !Property.isValidTablePropertyKey(key)) {
continue;
}
COL2 = Math.max(COL2, propEntry.getKey().length() + 3);
}
-
+
final ArrayList<String> output = new ArrayList<String>();
printConfHeader(output);
-
+
for (Entry<String,String> propEntry : sortedConf.entrySet()) {
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()))) {
continue;
}
- if ((tableName != null || tableNamespace != null) && !Property.isValidTablePropertyKey(key)) {
+ if ((tableName != null || namespace != null) && !Property.isValidTablePropertyKey(key)) {
continue;
}
String siteVal = siteConfig.get(key);
@@ -205,7 +206,7 @@ public class ConfigCommand extends Command {
String dfault = defaults.get(key);
String nspVal = namespaceConfig.get(key);
boolean printed = false;
-
+
if (dfault != null && key.toLowerCase().contains("password")) {
siteVal = sysVal = dfault = curVal = curVal.replaceAll(".", "*");
}
@@ -222,7 +223,7 @@ public class ConfigCommand extends Command {
printConfLine(output, "system", printed ? " @override" : key, sysVal == null ? "" : sysVal);
printed = true;
}
-
+
}
if (nspVal != null) {
if (!systemConfig.containsKey(key) || !sysVal.equals(nspVal)) {
@@ -230,11 +231,11 @@ public class ConfigCommand extends Command {
printed = true;
}
}
-
+
// show per-table value only if it is different (overridden)
if (tableName != null && !curVal.equals(nspVal)) {
printConfLine(output, "table", printed ? " @override" : key, curVal);
- } else if (tableNamespace != null && !curVal.equals(sysVal)) {
+ } else if (namespace != null && !curVal.equals(sysVal)) {
printConfLine(output, "namespace", printed ? " @override" : key, curVal);
}
}
@@ -246,13 +247,13 @@ public class ConfigCommand extends Command {
}
return 0;
}
-
+
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(List<String> output, String s1, String s2, String s3) {
if (s2.length() < COL2) {
s2 += " " + Shell.repeat(".", COL2 - s2.length() - 1);
@@ -260,53 +261,53 @@ public class ConfigCommand extends Command {
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(List<String> output) {
int col3 = Math.max(1, Math.min(Integer.MAX_VALUE, reader.getTerminal().getWidth() - COL1 - COL2 - 6));
output.add(String.format("%" + COL1 + "s-+-%" + COL2 + "s-+-%-" + col3 + "s", Shell.repeat("-", COL1), Shell.repeat("-", COL2), Shell.repeat("-", col3)));
}
-
+
@Override
public String description() {
return "prints system properties and table specific properties";
}
-
+
@Override
public Options getOptions() {
final Options o = new Options();
final OptionGroup og = new OptionGroup();
final OptionGroup tgroup = 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");
setOpt = new Option("s", "set", true, "set a per-table property");
filterOpt = new Option("f", "filter", true, "show only properties that contain this string");
disablePaginationOpt = new Option("np", "no-pagination", false, "disables pagination of output");
outputFileOpt = new Option("o", "output", true, "local file to write the scan output to");
- tableNamespaceOpt = new Option(Shell.tableNamespaceOption, "table-namespace", true, "table namespace to display/set/delete properties for");
-
+ namespaceOpt = new Option(Shell.namespaceOption, "namespace", true, "namespace to display/set/delete properties for");
+
tableOpt.setArgName("table");
deleteOpt.setArgName("property");
setOpt.setArgName("property=value");
filterOpt.setArgName("string");
outputFileOpt.setArgName("file");
- tableNamespaceOpt.setArgName("tableNamespace");
-
+ namespaceOpt.setArgName("namespace");
+
og.addOption(deleteOpt);
og.addOption(setOpt);
og.addOption(filterOpt);
-
+
tgroup.addOption(tableOpt);
- tgroup.addOption(tableNamespaceOpt);
-
+ tgroup.addOption(namespaceOpt);
+
o.addOptionGroup(tgroup);
o.addOptionGroup(og);
o.addOption(disablePaginationOpt);
o.addOption(outputFileOpt);
-
+
return o;
}
-
+
@Override
public int numArgs() {
return 0;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConstraintCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConstraintCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConstraintCommand.java
index c91f29e..208ac4a 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConstraintCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ConstraintCommand.java
@@ -29,37 +29,37 @@ import org.apache.commons.cli.OptionGroup;
import org.apache.commons.cli.Options;
public class ConstraintCommand extends Command {
- protected Option tableNamespaceOpt;
-
+ protected Option namespaceOpt;
+
@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
final String tableName;
final String namespace;
-
- if (cl.hasOption(tableNamespaceOpt.getOpt())) {
- namespace = cl.getOptionValue(tableNamespaceOpt.getOpt());
+
+ if (cl.hasOption(namespaceOpt.getOpt())) {
+ namespace = cl.getOptionValue(namespaceOpt.getOpt());
} else {
namespace = null;
}
-
+
if (cl.hasOption(OptUtil.tableOpt().getOpt()) || !shellState.getTableName().isEmpty()) {
tableName = OptUtil.getTableOpt(cl, shellState);
} else {
tableName = null;
}
-
+
int i;
switch (OptUtil.getAldOpt(cl)) {
case ADD:
for (String constraint : cl.getArgs()) {
if (namespace != null) {
- if (!shellState.getConnector().tableNamespaceOperations().testClassLoad(namespace, constraint, Constraint.class.getName())) {
+ if (!shellState.getConnector().namespaceOperations().testClassLoad(namespace, constraint, Constraint.class.getName())) {
throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Servers are unable to load " + constraint + " as type "
+ Constraint.class.getName());
}
- i = shellState.getConnector().tableNamespaceOperations().addConstraint(namespace, constraint);
- shellState.getReader().println("Added constraint " + constraint + " to table namespace " + namespace + " with number " + i);
- } else if (tableName != null && !tableName.isEmpty()){
+ i = shellState.getConnector().namespaceOperations().addConstraint(namespace, constraint);
+ shellState.getReader().println("Added constraint " + constraint + " to namespace " + namespace + " with number " + i);
+ } else if (tableName != null && !tableName.isEmpty()) {
if (!shellState.getConnector().tableOperations().testClassLoad(tableName, constraint, Constraint.class.getName())) {
throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Servers are unable to load " + constraint + " as type "
+ Constraint.class.getName());
@@ -67,7 +67,7 @@ public class ConstraintCommand extends Command {
i = shellState.getConnector().tableOperations().addConstraint(tableName, constraint);
shellState.getReader().println("Added constraint " + constraint + " to table " + tableName + " with number " + i);
} else {
- throw new IllegalArgumentException("Please specify either a table or a table namespace");
+ throw new IllegalArgumentException("Please specify either a table or a namespace");
}
}
break;
@@ -75,59 +75,59 @@ public class ConstraintCommand extends Command {
for (String constraint : cl.getArgs()) {
i = Integer.parseInt(constraint);
if (namespace != null) {
- shellState.getConnector().tableNamespaceOperations().removeConstraint(namespace, i);
- shellState.getReader().println("Removed constraint " + i + " from table namespace " + namespace);
- } else if (tableName != null){
+ shellState.getConnector().namespaceOperations().removeConstraint(namespace, i);
+ shellState.getReader().println("Removed constraint " + i + " from namespace " + namespace);
+ } else if (tableName != null) {
shellState.getConnector().tableOperations().removeConstraint(tableName, i);
shellState.getReader().println("Removed constraint " + i + " from table " + tableName);
} else {
- throw new IllegalArgumentException("Please specify either a table or a table namespace");
+ throw new IllegalArgumentException("Please specify either a table or a namespace");
}
}
break;
case LIST:
if (namespace != null) {
- for (Entry<String,Integer> property : shellState.getConnector().tableNamespaceOperations().listConstraints(namespace).entrySet()) {
+ for (Entry<String,Integer> property : shellState.getConnector().namespaceOperations().listConstraints(namespace).entrySet()) {
shellState.getReader().println(property.toString());
}
- } else if (tableName != null){
+ } else if (tableName != null) {
for (Entry<String,Integer> property : shellState.getConnector().tableOperations().listConstraints(tableName).entrySet()) {
shellState.getReader().println(property.toString());
}
} else {
- throw new IllegalArgumentException("Please specify either a table or a table namespace");
+ throw new IllegalArgumentException("Please specify either a table or a namespace");
}
}
-
+
return 0;
}
-
+
@Override
public String description() {
return "adds, deletes, or lists constraints for a table";
}
-
+
@Override
public int numArgs() {
return Shell.NO_FIXED_ARG_LENGTH_CHECK;
}
-
+
@Override
public String usage() {
return getName() + " <constraint>{ <constraint>}";
}
-
+
@Override
public Options getOptions() {
final Options o = new Options();
o.addOptionGroup(OptUtil.addListDeleteGroup("constraint"));
-
+
OptionGroup grp = new OptionGroup();
grp.addOption(OptUtil.tableOpt("table to add, delete, or list constraints for"));
- tableNamespaceOpt = new Option(Shell.tableNamespaceOption, "table-namespace", true, "name of a table namespace to operate on");
- tableNamespaceOpt.setArgName("tableNamespace");
- grp.addOption(tableNamespaceOpt);
-
+ namespaceOpt = new Option(Shell.namespaceOption, "namespace", true, "name of a namespace to operate on");
+ namespaceOpt.setArgName("namespace");
+ grp.addOption(namespaceOpt);
+
o.addOptionGroup(grp);
return o;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateNamespaceCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateNamespaceCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateNamespaceCommand.java
index 7434767..908a9cc 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateNamespaceCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateNamespaceCommand.java
@@ -21,9 +21,9 @@ import java.util.Map.Entry;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.NamespaceExistsException;
+import org.apache.accumulo.core.client.NamespaceNotFoundException;
import org.apache.accumulo.core.client.TableExistsException;
-import org.apache.accumulo.core.client.TableNamespaceExistsException;
-import org.apache.accumulo.core.client.TableNamespaceNotFoundException;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.util.shell.Shell;
@@ -34,12 +34,12 @@ import org.apache.commons.cli.OptionGroup;
import org.apache.commons.cli.Options;
public class CreateNamespaceCommand extends Command {
- private Option createTableOptCopyConfig, createTableNamespaceOptCopyConfig;
+ private Option createTableOptCopyConfig, createNamespaceOptCopyConfig;
private Option base64Opt;
@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException,
- TableExistsException, TableNotFoundException, IOException, ClassNotFoundException, TableNamespaceExistsException, TableNamespaceNotFoundException {
+ TableExistsException, TableNotFoundException, IOException, ClassNotFoundException, NamespaceExistsException, NamespaceNotFoundException {
if (createTableOptCopyConfig == null) {
getOptions();
@@ -47,25 +47,25 @@ public class CreateNamespaceCommand extends Command {
String namespace = cl.getArgs()[0];
- shellState.getConnector().tableNamespaceOperations().create(namespace);
+ shellState.getConnector().namespaceOperations().create(namespace);
// Copy options if flag was set
Iterable<Entry<String,String>> configuration = null;
- if (cl.hasOption(createTableNamespaceOptCopyConfig.getOpt())) {
- String copy = cl.getOptionValue(createTableNamespaceOptCopyConfig.getOpt());
- if (shellState.getConnector().tableNamespaceOperations().exists(namespace)) {
- configuration = shellState.getConnector().tableNamespaceOperations().getProperties(copy);
+ if (cl.hasOption(createNamespaceOptCopyConfig.getOpt())) {
+ String copy = cl.getOptionValue(createNamespaceOptCopyConfig.getOpt());
+ if (shellState.getConnector().namespaceOperations().exists(namespace)) {
+ configuration = shellState.getConnector().namespaceOperations().getProperties(copy);
}
} else if (cl.hasOption(createTableOptCopyConfig.getOpt())) {
String copy = cl.getOptionValue(createTableOptCopyConfig.getOpt());
- if (shellState.getConnector().tableNamespaceOperations().exists(namespace)) {
+ if (shellState.getConnector().namespaceOperations().exists(namespace)) {
configuration = shellState.getConnector().tableOperations().getProperties(copy);
}
}
if (configuration != null) {
for (Entry<String,String> entry : configuration) {
if (Property.isValidTablePropertyKey(entry.getKey())) {
- shellState.getConnector().tableNamespaceOperations().setProperty(namespace, entry.getKey(), entry.getValue());
+ shellState.getConnector().namespaceOperations().setProperty(namespace, entry.getKey(), entry.getValue());
}
}
}
@@ -75,7 +75,7 @@ public class CreateNamespaceCommand extends Command {
@Override
public String description() {
- return "creates a new table namespace";
+ return "creates a new namespace";
}
@Override
@@ -87,8 +87,8 @@ public class CreateNamespaceCommand extends Command {
public Options getOptions() {
final Options o = new Options();
- createTableNamespaceOptCopyConfig = new Option("cc", "copy-config", true, "table namespace to copy configuration from");
- createTableNamespaceOptCopyConfig.setArgName("tableNamespace");
+ createNamespaceOptCopyConfig = new Option("cc", "copy-config", true, "namespace to copy configuration from");
+ createNamespaceOptCopyConfig.setArgName("namespace");
createTableOptCopyConfig = new Option("ctc", "copy-table-config", true, "table to copy configuration from");
createTableOptCopyConfig.setArgName("tableName");
@@ -97,7 +97,7 @@ public class CreateNamespaceCommand extends Command {
o.addOption(base64Opt);
OptionGroup ogp = new OptionGroup();
ogp.addOption(createTableOptCopyConfig);
- ogp.addOption(createTableNamespaceOptCopyConfig);
+ ogp.addOption(createNamespaceOptCopyConfig);
o.addOptionGroup(ogp);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateTableCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateTableCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateTableCommand.java
index 8081d92..b017eaf 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateTableCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateTableCommand.java
@@ -114,7 +114,7 @@ public class CreateTableCommand extends Command {
String n = Tables.extractNamespace(tableName);
String table = tableName;
- if (n.equals(Constants.DEFAULT_TABLE_NAMESPACE) || n.equals(Constants.SYSTEM_TABLE_NAMESPACE)) {
+ if (n.equals(Constants.DEFAULT_NAMESPACE) || n.equals(Constants.SYSTEM_NAMESPACE)) {
table = Tables.extractTableName(tableName);
}
shellState.setTableName(table); // switch shell to new table context
@@ -216,6 +216,6 @@ public class CreateTableCommand extends Command {
@Override
public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> special) {
- registerCompletionForTableNamespaces(root, special);
+ registerCompletionForNamespaces(root, special);
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java
index 817809d..3d57961 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java
@@ -22,10 +22,10 @@ import java.util.SortedSet;
import java.util.TreeSet;
import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.TableNamespaceNotFoundException;
+import org.apache.accumulo.core.client.NamespaceNotFoundException;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.admin.DiskUsage;
-import org.apache.accumulo.core.client.impl.TableNamespaces;
+import org.apache.accumulo.core.client.impl.Namespaces;
import org.apache.accumulo.core.util.NumUtil;
import org.apache.accumulo.core.util.shell.Shell;
import org.apache.accumulo.core.util.shell.Shell.Command;
@@ -34,13 +34,15 @@ import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
public class DUCommand extends Command {
-
- private Option optTablePattern, optHumanReadble, optTableNamespace;
-
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException, TableNotFoundException, TableNamespaceNotFoundException {
-
+
+ private Option optTablePattern, optHumanReadble, optNamespace;
+
+ @Override
+ public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException, TableNotFoundException,
+ NamespaceNotFoundException {
+
final SortedSet<String> tables = new TreeSet<String>(Arrays.asList(cl.getArgs()));
-
+
if (cl.hasOption(Shell.tableOption)) {
String tableName = cl.getOptionValue(Shell.tableOption);
if (!shellState.getConnector().tableOperations().exists(tableName)) {
@@ -48,15 +50,15 @@ public class DUCommand extends Command {
}
tables.add(tableName);
}
-
- if (cl.hasOption(optTableNamespace.getOpt())) {
+
+ if (cl.hasOption(optNamespace.getOpt())) {
Instance instance = shellState.getInstance();
- String namespaceId = TableNamespaces.getNamespaceId(instance, cl.getOptionValue(optTableNamespace.getOpt()));
- tables.addAll(TableNamespaces.getTableNames(instance, namespaceId));
+ String namespaceId = Namespaces.getNamespaceId(instance, cl.getOptionValue(optNamespace.getOpt()));
+ tables.addAll(Namespaces.getTableNames(instance, namespaceId));
}
-
+
boolean prettyPrint = cl.hasOption(optHumanReadble.getOpt()) ? true : false;
-
+
if (cl.hasOption(optTablePattern.getOpt())) {
for (String table : shellState.getConnector().tableOperations().list()) {
if (table.matches(cl.getOptionValue(optTablePattern.getOpt()))) {
@@ -80,39 +82,39 @@ public class DUCommand extends Command {
}
return 0;
}
-
+
@Override
public String description() {
return "prints how much space, in bytes, is used by files referenced by a table. When multiple tables are specified it prints how much space, in bytes, is used by files shared between tables, if any.";
}
-
+
@Override
public Options getOptions() {
final Options o = new Options();
-
+
optTablePattern = new Option("p", "pattern", true, "regex pattern of table names");
optTablePattern.setArgName("pattern");
-
+
optHumanReadble = new Option("h", "human-readable", false, "format large sizes to human readable units");
optHumanReadble.setArgName("human readable output");
-
- optTableNamespace = new Option(Shell.tableNamespaceOption, "table-namespace", true, "name of a table namespace");
- optTableNamespace.setArgName("table-namespace");
-
+
+ optNamespace = new Option(Shell.namespaceOption, "namespace", true, "name of a namespace");
+ optNamespace.setArgName("namespace");
+
o.addOption(OptUtil.tableOpt("table to examine"));
-
+
o.addOption(optTablePattern);
o.addOption(optHumanReadble);
- o.addOption(optTableNamespace);
-
+ o.addOption(optNamespace);
+
return o;
}
-
+
@Override
public String usage() {
return getName() + " <table>{ <table>}";
}
-
+
@Override
public int numArgs() {
return Shell.NO_FIXED_ARG_LENGTH_CHECK;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java
index 4f2f46f..c100325 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java
@@ -28,16 +28,17 @@ import org.apache.commons.cli.Options;
public class DeleteIterCommand extends Command {
private Option allScopeOpt, mincScopeOpt, majcScopeOpt, scanScopeOpt, nameOpt;
-
+
+ @Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
-
+
boolean tables = cl.hasOption(OptUtil.tableOpt().getOpt()) || !shellState.getTableName().isEmpty();
- boolean namespaces = cl.hasOption(OptUtil.tableNamespaceOpt().getOpt());
-
+ boolean namespaces = cl.hasOption(OptUtil.namespaceOpt().getOpt());
+
final String name = cl.getOptionValue(nameOpt.getOpt());
-
+
if (namespaces) {
- if (!shellState.getConnector().tableNamespaceOperations().listIterators(OptUtil.getTableNamespaceOpt(cl, shellState)).containsKey(name)) {
+ if (!shellState.getConnector().namespaceOperations().listIterators(OptUtil.getNamespaceOpt(cl, shellState)).containsKey(name)) {
Shell.log.warn("no iterators found that match your criteria");
return 0;
}
@@ -47,9 +48,9 @@ public class DeleteIterCommand extends Command {
return 0;
}
} else {
- throw new IllegalArgumentException("No table or table namespace specified");
+ throw new IllegalArgumentException("No table or namespace specified");
}
-
+
final EnumSet<IteratorScope> scopes = EnumSet.noneOf(IteratorScope.class);
if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(mincScopeOpt.getOpt())) {
scopes.add(IteratorScope.minc);
@@ -63,48 +64,49 @@ public class DeleteIterCommand extends Command {
if (scopes.isEmpty()) {
throw new IllegalArgumentException("You must select at least one scope to configure");
}
-
+
if (namespaces) {
- shellState.getConnector().tableNamespaceOperations().removeIterator(OptUtil.getTableNamespaceOpt(cl, shellState), name, scopes);
+ shellState.getConnector().namespaceOperations().removeIterator(OptUtil.getNamespaceOpt(cl, shellState), name, scopes);
} else if (tables) {
shellState.getConnector().tableOperations().removeIterator(OptUtil.getTableOpt(cl, shellState), name, scopes);
} else {
- throw new IllegalArgumentException("No table or table namespace specified");
+ throw new IllegalArgumentException("No table or namespace specified");
}
return 0;
}
-
+
@Override
public String description() {
- return "deletes a table-specific or table-namespace-specific iterator";
+ return "deletes a table-specific or namespace-specific iterator";
}
-
+
+ @Override
public Options getOptions() {
final Options o = new Options();
-
+
nameOpt = new Option("n", "name", true, "iterator to delete");
nameOpt.setArgName("itername");
nameOpt.setRequired(true);
-
+
allScopeOpt = new Option("all", "all-scopes", false, "remove from all scopes");
mincScopeOpt = new Option(IteratorScope.minc.name(), "minor-compaction", false, "remove from minor compaction scope");
majcScopeOpt = new Option(IteratorScope.majc.name(), "major-compaction", false, "remove from major compaction scope");
scanScopeOpt = new Option(IteratorScope.scan.name(), "scan-time", false, "remove from scan scope");
-
+
OptionGroup grp = new OptionGroup();
grp.addOption(OptUtil.tableOpt("table to delete the iterator from"));
- grp.addOption(OptUtil.tableNamespaceOpt("table namespace to delete the iterator from"));
+ grp.addOption(OptUtil.namespaceOpt("namespace to delete the iterator from"));
o.addOptionGroup(grp);
o.addOption(nameOpt);
-
+
o.addOption(allScopeOpt);
o.addOption(mincScopeOpt);
o.addOption(majcScopeOpt);
o.addOption(scanScopeOpt);
-
+
return o;
}
-
+
@Override
public int numArgs() {
return 0;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteNamespaceCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteNamespaceCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteNamespaceCommand.java
index e1b41cd..26473ed 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteNamespaceCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteNamespaceCommand.java
@@ -21,8 +21,8 @@ import java.util.Map;
import java.util.Set;
import org.apache.accumulo.core.Constants;
-import org.apache.accumulo.core.client.TableNamespaceNotFoundException;
-import org.apache.accumulo.core.client.impl.TableNamespaces;
+import org.apache.accumulo.core.client.NamespaceNotFoundException;
+import org.apache.accumulo.core.client.impl.Namespaces;
import org.apache.accumulo.core.util.shell.Shell;
import org.apache.accumulo.core.util.shell.Shell.Command;
import org.apache.accumulo.core.util.shell.Token;
@@ -55,29 +55,29 @@ public class DeleteNamespaceCommand extends Command {
@Override
public String description() {
- return "deletes a table namespace";
+ return "deletes a namespace";
}
protected void doTableOp(final Shell shellState, final String namespace, boolean force) throws Exception {
boolean resetContext = false;
String currentTable = shellState.getTableName();
- if (!TableNamespaces.getNameToIdMap(shellState.getInstance()).containsKey(namespace)) {
- throw new TableNamespaceNotFoundException(null, namespace, null);
+ if (!Namespaces.getNameToIdMap(shellState.getInstance()).containsKey(namespace)) {
+ throw new NamespaceNotFoundException(null, namespace, null);
}
- String namespaceId = TableNamespaces.getNamespaceId(shellState.getInstance(), namespace);
- List<String> tables = TableNamespaces.getTableNames(shellState.getInstance(), namespaceId);
+ String namespaceId = Namespaces.getNamespaceId(shellState.getInstance(), namespace);
+ List<String> tables = Namespaces.getTableNames(shellState.getInstance(), namespaceId);
resetContext = tables.contains(currentTable);
if (force) {
- shellState.getConnector().tableNamespaceOperations().delete(namespace, true);
+ shellState.getConnector().namespaceOperations().delete(namespace, true);
} else {
- shellState.getConnector().tableNamespaceOperations().delete(namespace);
+ shellState.getConnector().namespaceOperations().delete(namespace);
}
- if (namespace.equals(Constants.SYSTEM_TABLE_NAMESPACE)) {
- shellState.getReader().println("Table namespace: [" + namespace + "], can't delete system or default namespace.");
+ if (namespace.equals(Constants.SYSTEM_NAMESPACE)) {
+ shellState.getReader().println("Namespace: [" + namespace + "], can't delete system or default namespace.");
} else {
- shellState.getReader().println("Table namespace: [" + namespace + "] has been deleted.");
+ shellState.getReader().println("Namespace: [" + namespace + "] has been deleted.");
}
if (resetContext) {
shellState.setTableName("");
@@ -100,6 +100,6 @@ public class DeleteNamespaceCommand extends Command {
@Override
public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> special) {
- registerCompletionForTableNamespaces(root, special);
+ registerCompletionForNamespaces(root, special);
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteTableCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteTableCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteTableCommand.java
index 74d3f36..10a12d3 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteTableCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteTableCommand.java
@@ -47,7 +47,7 @@ public class DeleteTableCommand extends TableOperation {
String n = Tables.extractNamespace(tableName);
String checkTable = tableName;
- if (n.equals(Constants.DEFAULT_TABLE_NAMESPACE) || n.equals(Constants.SYSTEM_TABLE_NAMESPACE)) {
+ if (n.equals(Constants.DEFAULT_NAMESPACE) || n.equals(Constants.SYSTEM_NAMESPACE)) {
checkTable = Tables.extractTableName(tableName);
}
if (shellState.getTableName().equals(checkTable)) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrantCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrantCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrantCommand.java
index 9f6e7e4..de719fd 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrantCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrantCommand.java
@@ -19,9 +19,9 @@ package org.apache.accumulo.core.util.shell.commands;
import java.util.Map;
import java.util.Set;
+import org.apache.accumulo.core.security.NamespacePermission;
import org.apache.accumulo.core.security.SystemPermission;
import org.apache.accumulo.core.security.TablePermission;
-import org.apache.accumulo.core.security.TableNamespacePermission;
import org.apache.accumulo.core.util.BadArgumentException;
import org.apache.accumulo.core.util.shell.Shell;
import org.apache.accumulo.core.util.shell.Shell.Command;
@@ -35,15 +35,15 @@ public class GrantCommand extends TableOperation {
{
disableUnflaggedTableOptions();
}
-
+
private Option systemOpt, userOpt;
private String user;
private String[] permission;
-
+
@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
user = cl.hasOption(userOpt.getOpt()) ? cl.getOptionValue(userOpt.getOpt()) : shellState.getConnector().whoami();
-
+
permission = cl.getArgs()[0].split("\\.", 2);
if (cl.hasOption(systemOpt.getOpt()) && permission[0].equalsIgnoreCase("System")) {
try {
@@ -55,22 +55,22 @@ public class GrantCommand extends TableOperation {
} else if (permission[0].equalsIgnoreCase("Table")) {
super.execute(fullCommand, cl, shellState);
} else if (permission[0].equalsIgnoreCase("Namespace")) {
- if (cl.hasOption(optTableNamespace.getOpt())) {
+ if (cl.hasOption(optNamespace.getOpt())) {
try {
shellState.getConnector().securityOperations()
- .grantTableNamespacePermission(user, cl.getOptionValue(optTableNamespace.getOpt()), TableNamespacePermission.valueOf(permission[1]));
+ .grantNamespacePermission(user, cl.getOptionValue(optNamespace.getOpt()), NamespacePermission.valueOf(permission[1]));
} catch (IllegalArgumentException e) {
- throw new BadArgumentException("No such table namespace permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
+ throw new BadArgumentException("No such namespace permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
}
} else {
- throw new BadArgumentException("No Table Namespace specified to apply permission to", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
+ throw new BadArgumentException("No namespace specified to apply permission to", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
}
} else {
throw new BadArgumentException("Unrecognized permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
}
return 0;
}
-
+
@Override
protected void doTableOp(final Shell shellState, final String tableName) throws Exception {
try {
@@ -80,52 +80,52 @@ public class GrantCommand extends TableOperation {
throw new IllegalArgumentException("No such table permission", e);
}
}
-
+
@Override
public String description() {
- return "grants system, table, or table namespace permissions for a user";
+ return "grants system, table, or namespace permissions for a user";
}
-
+
@Override
public String usage() {
return getName() + " <permission>";
}
-
+
@Override
public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> completionSet) {
final Token cmd = new Token(getName());
cmd.addSubcommand(new Token(TablePermission.printableValues()));
cmd.addSubcommand(new Token(SystemPermission.printableValues()));
- cmd.addSubcommand(new Token(TableNamespacePermission.printableValues()));
+ cmd.addSubcommand(new Token(NamespacePermission.printableValues()));
root.addSubcommand(cmd);
}
-
+
@Override
public Options getOptions() {
super.getOptions();
final Options o = new Options();
-
+
final OptionGroup group = new OptionGroup();
-
+
systemOpt = new Option("s", "system", false, "grant a system permission");
-
- optTableNamespace = new Option(Shell.tableNamespaceOption, "table-namespace", true, "name of a table namespace to operate on");
- optTableNamespace.setArgName("tableNamespace");
-
+
+ optNamespace = new Option(Shell.namespaceOption, "namespace", true, "name of a namespace to operate on");
+ optNamespace.setArgName("namespace");
+
group.addOption(systemOpt);
group.addOption(optTableName);
group.addOption(optTablePattern);
- group.addOption(optTableNamespace);
-
+ group.addOption(optNamespace);
+
o.addOptionGroup(group);
userOpt = new Option(Shell.userOption, "user", true, "user to operate on");
userOpt.setArgName("username");
userOpt.setRequired(true);
o.addOption(userOpt);
-
+
return o;
}
-
+
@Override
public int numArgs() {
return 1;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java
index 5e5018f..e29c5e6 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java
@@ -33,22 +33,22 @@ import org.apache.commons.cli.Options;
public class ListIterCommand extends Command {
private Option nameOpt;
private Map<IteratorScope,Option> scopeOpts;
-
+
@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
-
+
boolean tables = cl.hasOption(OptUtil.tableOpt().getOpt()) || !shellState.getTableName().isEmpty();
- boolean namespaces = cl.hasOption(OptUtil.tableNamespaceOpt().getOpt());
-
+ boolean namespaces = cl.hasOption(OptUtil.namespaceOpt().getOpt());
+
final Map<String,EnumSet<IteratorScope>> iterators;
if (namespaces) {
- iterators = shellState.getConnector().tableNamespaceOperations().listIterators(OptUtil.getTableNamespaceOpt(cl, shellState));
+ iterators = shellState.getConnector().namespaceOperations().listIterators(OptUtil.getNamespaceOpt(cl, shellState));
} else if (tables) {
iterators = shellState.getConnector().tableOperations().listIterators(OptUtil.getTableOpt(cl, shellState));
} else {
- throw new IllegalArgumentException("No table or table namespace specified");
+ throw new IllegalArgumentException("No table or namespace specified");
}
-
+
if (cl.hasOption(nameOpt.getOpt())) {
final String name = cl.getOptionValue(nameOpt.getOpt());
if (!iterators.containsKey(name)) {
@@ -59,7 +59,7 @@ public class ListIterCommand extends Command {
iterators.clear();
iterators.put(name, scopes);
}
-
+
boolean hasScope = false;
for (IteratorScope scope : IteratorScope.values()) {
if (cl.hasOption(scopeOpts.get(scope).getOpt()))
@@ -74,11 +74,11 @@ public class ListIterCommand extends Command {
if (cl.hasOption(scopeOpts.get(scope).getOpt())) {
IteratorSetting setting;
if (namespaces) {
- setting = shellState.getConnector().tableNamespaceOperations().getIteratorSetting(OptUtil.getTableNamespaceOpt(cl, shellState), name, scope);
+ setting = shellState.getConnector().namespaceOperations().getIteratorSetting(OptUtil.getNamespaceOpt(cl, shellState), name, scope);
} else if (tables) {
setting = shellState.getConnector().tableOperations().getIteratorSetting(OptUtil.getTableOpt(cl, shellState), name, scope);
} else {
- throw new IllegalArgumentException("No table or table namespace specified");
+ throw new IllegalArgumentException("No table or namespace specified");
}
sb.append("- Iterator ").append(setting.getName()).append(", ").append(scope).append(" scope options:\n");
sb.append("- ").append("iteratorPriority").append(" = ").append(setting.getPriority()).append("\n");
@@ -91,41 +91,42 @@ public class ListIterCommand extends Command {
}
sb.append("-");
shellState.getReader().println(sb.toString());
-
+
return 0;
}
-
+
+ @Override
public String description() {
- return "lists table-specific or table-namespace-specific iterators configured in this shell session";
+ return "lists table-specific or namespace-specific iterators configured in this shell session";
}
-
+
@Override
public int numArgs() {
return 0;
}
-
+
@Override
public Options getOptions() {
final Options o = new Options();
-
+
nameOpt = new Option("n", "name", true, "iterator to list");
nameOpt.setArgName("itername");
-
+
scopeOpts = new EnumMap<IteratorScope,Option>(IteratorScope.class);
scopeOpts.put(IteratorScope.minc, new Option(IteratorScope.minc.name(), "minor-compaction", false, "list iterator for minor compaction scope"));
scopeOpts.put(IteratorScope.majc, new Option(IteratorScope.majc.name(), "major-compaction", false, "list iterator for major compaction scope"));
scopeOpts.put(IteratorScope.scan, new Option(IteratorScope.scan.name(), "scan-time", false, "list iterator for scan scope"));
-
+
OptionGroup grp = new OptionGroup();
grp.addOption(OptUtil.tableOpt("table to list the configured iterators on"));
- grp.addOption(OptUtil.tableNamespaceOpt("table namespace to list the configured iterators on"));
+ grp.addOption(OptUtil.namespaceOpt("namespace to list the configured iterators on"));
o.addOptionGroup(grp);
o.addOption(nameOpt);
-
+
for (Option opt : scopeOpts.values()) {
o.addOption(opt);
}
-
+
return o;
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacePermissionsCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacePermissionsCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacePermissionsCommand.java
index f3e0e6f..2dcba55 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacePermissionsCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacePermissionsCommand.java
@@ -18,7 +18,7 @@ package org.apache.accumulo.core.util.shell.commands;
import java.io.IOException;
-import org.apache.accumulo.core.security.TableNamespacePermission;
+import org.apache.accumulo.core.security.NamespacePermission;
import org.apache.accumulo.core.util.shell.Shell;
import org.apache.accumulo.core.util.shell.Shell.Command;
import org.apache.commons.cli.CommandLine;
@@ -26,7 +26,7 @@ import org.apache.commons.cli.CommandLine;
public class NamespacePermissionsCommand extends Command {
@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException {
- for (String p : TableNamespacePermission.printableValues()) {
+ for (String p : NamespacePermission.printableValues()) {
shellState.getReader().println(p);
}
return 0;
@@ -34,7 +34,7 @@ public class NamespacePermissionsCommand extends Command {
@Override
public String description() {
- return "displays a list of valid table namespace permissions";
+ return "displays a list of valid namespace permissions";
}
@Override
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacesCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacesCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacesCommand.java
index 2056afd..38f7c77 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacesCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacesCommand.java
@@ -36,8 +36,8 @@ public class NamespacesCommand extends Command {
@SuppressWarnings("unchecked")
@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException {
- Iterator<String> names = shellState.getConnector().tableNamespaceOperations().list().iterator();
- Iterator<String> ids = new NamespaceIdIterator(new TreeMap<String,String>(shellState.getConnector().tableNamespaceOperations().namespaceIdMap()).entrySet()
+ Iterator<String> names = shellState.getConnector().namespaceOperations().list().iterator();
+ Iterator<String> ids = new NamespaceIdIterator(new TreeMap<String,String>(shellState.getConnector().namespaceOperations().namespaceIdMap()).entrySet()
.iterator());
if (cl.hasOption(namespaceIdOption.getOpt())) {
@@ -66,13 +66,13 @@ public class NamespacesCommand extends Command {
@Override
public String description() {
- return "displays a list of all existing table namespaces";
+ return "displays a list of all existing namespaces";
}
@Override
public Options getOptions() {
final Options o = new Options();
- namespaceIdOption = new Option("l", "list-ids", false, "display internal table namespace ids along with the name");
+ namespaceIdOption = new Option("l", "list-ids", false, "display internal namespace ids along with the name");
o.addOption(namespaceIdOption);
disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output");
o.addOption(disablePaginationOpt);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OptUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OptUtil.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OptUtil.java
index e92be4a..24b6b9d 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OptUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/OptUtil.java
@@ -18,7 +18,7 @@ package org.apache.accumulo.core.util.shell.commands;
import java.io.UnsupportedEncodingException;
-import org.apache.accumulo.core.client.TableNamespaceNotFoundException;
+import org.apache.accumulo.core.client.NamespaceNotFoundException;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.util.shell.Shell;
import org.apache.commons.cli.CommandLine;
@@ -29,10 +29,10 @@ import org.apache.hadoop.io.Text;
public abstract class OptUtil {
public static final String START_ROW_OPT = "b";
public static final String END_ROW_OPT = "e";
-
+
public static String getTableOpt(final CommandLine cl, final Shell shellState) throws TableNotFoundException {
String tableName;
-
+
if (cl.hasOption(Shell.tableOption)) {
tableName = cl.getOptionValue(Shell.tableOption);
if (!shellState.getConnector().tableOperations().exists(tableName)) {
@@ -42,55 +42,55 @@ public abstract class OptUtil {
shellState.checkTableState();
tableName = shellState.getTableName();
}
-
+
return tableName;
}
-
- public static String getTableNamespaceOpt(final CommandLine cl, final Shell shellState) throws TableNamespaceNotFoundException {
+
+ public static String getNamespaceOpt(final CommandLine cl, final Shell shellState) throws NamespaceNotFoundException {
String namespace = null;
- if (cl.hasOption(Shell.tableNamespaceOption)) {
- namespace = cl.getOptionValue(Shell.tableNamespaceOption);
- if (!shellState.getConnector().tableNamespaceOperations().exists(namespace)) {
- throw new TableNamespaceNotFoundException(namespace, namespace, "specified table namespace that doesn't exist");
+ if (cl.hasOption(Shell.namespaceOption)) {
+ namespace = cl.getOptionValue(Shell.namespaceOption);
+ if (!shellState.getConnector().namespaceOperations().exists(namespace)) {
+ throw new NamespaceNotFoundException(namespace, namespace, "specified namespace that doesn't exist");
}
} else {
- throw new TableNamespaceNotFoundException(null, null, "no table namespace specified");
+ throw new NamespaceNotFoundException(null, null, "no namespace specified");
}
return namespace;
}
-
+
public static Option tableOpt() {
return tableOpt("tableName");
}
-
+
public static Option tableOpt(final String description) {
final Option tableOpt = new Option(Shell.tableOption, "table", true, description);
tableOpt.setArgName("table");
tableOpt.setRequired(false);
return tableOpt;
}
-
- public static Option tableNamespaceOpt() {
- return tableNamespaceOpt("tableNamespace");
+
+ public static Option namespaceOpt() {
+ return namespaceOpt("namespace");
}
-
- public static Option tableNamespaceOpt(final String description) {
- final Option tableNamespaceOpt = new Option(Shell.tableNamespaceOption, "tableNamespace", true, description);
- tableNamespaceOpt.setArgName("tableNamespace");
- tableNamespaceOpt.setRequired(false);
- return tableNamespaceOpt;
+
+ public static Option namespaceOpt(final String description) {
+ final Option namespaceOpt = new Option(Shell.namespaceOption, "namespace", true, description);
+ namespaceOpt.setArgName("namespace");
+ namespaceOpt.setRequired(false);
+ return namespaceOpt;
}
-
+
public static enum AdlOpt {
ADD("a"), DELETE("d"), LIST("l");
-
+
public final String opt;
-
+
private AdlOpt(String opt) {
this.opt = opt;
}
}
-
+
public static AdlOpt getAldOpt(final CommandLine cl) {
if (cl.hasOption(AdlOpt.ADD.opt)) {
return AdlOpt.ADD;
@@ -100,7 +100,7 @@ public abstract class OptUtil {
return AdlOpt.LIST;
}
}
-
+
public static OptionGroup addListDeleteGroup(final String name) {
final Option addOpt = new Option(AdlOpt.ADD.opt, "add", false, "add " + name);
final Option deleteOpt = new Option(AdlOpt.DELETE.opt, "delete", false, "delete " + name);
@@ -112,19 +112,19 @@ public abstract class OptUtil {
og.setRequired(true);
return og;
}
-
+
public static Option startRowOpt() {
final Option o = new Option(START_ROW_OPT, "begin-row", true, "begin row (inclusive)");
o.setArgName("begin-row");
return o;
}
-
+
public static Option endRowOpt() {
final Option o = new Option(END_ROW_OPT, "end-row", true, "end row (inclusive)");
o.setArgName("end-row");
return o;
}
-
+
public static Text getStartRow(final CommandLine cl) throws UnsupportedEncodingException {
if (cl.hasOption(START_ROW_OPT)) {
return new Text(cl.getOptionValue(START_ROW_OPT).getBytes(Shell.CHARSET));
@@ -132,7 +132,7 @@ public abstract class OptUtil {
return null;
}
}
-
+
public static Text getEndRow(final CommandLine cl) throws UnsupportedEncodingException {
if (cl.hasOption(END_ROW_OPT)) {
return new Text(cl.getOptionValue(END_ROW_OPT).getBytes(Shell.CHARSET));
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RenameNamespaceCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RenameNamespaceCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RenameNamespaceCommand.java
index 34fd9fa..d7ff7c3 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RenameNamespaceCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RenameNamespaceCommand.java
@@ -22,11 +22,11 @@ import java.util.Set;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.NamespaceExistsException;
+import org.apache.accumulo.core.client.NamespaceNotFoundException;
import org.apache.accumulo.core.client.TableExistsException;
-import org.apache.accumulo.core.client.TableNamespaceExistsException;
-import org.apache.accumulo.core.client.TableNamespaceNotFoundException;
import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.impl.TableNamespaces;
+import org.apache.accumulo.core.client.impl.Namespaces;
import org.apache.accumulo.core.client.impl.Tables;
import org.apache.accumulo.core.util.shell.Shell;
import org.apache.accumulo.core.util.shell.Shell.Command;
@@ -36,19 +36,19 @@ import org.apache.commons.cli.CommandLine;
public class RenameNamespaceCommand extends Command {
@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException,
- TableNotFoundException, TableExistsException, TableNamespaceNotFoundException, TableNamespaceExistsException {
+ TableNotFoundException, TableExistsException, NamespaceNotFoundException, NamespaceExistsException {
String old = cl.getArgs()[0];
String newer = cl.getArgs()[1];
boolean resetContext = false;
String currentTableId = "";
if (!(shellState.getTableName() == null) && !shellState.getTableName().isEmpty()) {
- String namespaceId = TableNamespaces.getNamespaceId(shellState.getInstance(), old);
- List<String> tableIds = TableNamespaces.getTableIds(shellState.getInstance(), namespaceId);
+ String namespaceId = Namespaces.getNamespaceId(shellState.getInstance(), old);
+ List<String> tableIds = Namespaces.getTableIds(shellState.getInstance(), namespaceId);
currentTableId = Tables.getTableId(shellState.getInstance(), shellState.getTableName());
resetContext = tableIds.contains(currentTableId);
}
- shellState.getConnector().tableNamespaceOperations().rename(old, newer);
+ shellState.getConnector().namespaceOperations().rename(old, newer);
if (resetContext) {
shellState.setTableName(Tables.getTableName(shellState.getInstance(), currentTableId));
@@ -59,17 +59,17 @@ public class RenameNamespaceCommand extends Command {
@Override
public String usage() {
- return getName() + " <current table namespace> <new table namespace>";
+ return getName() + " <current namespace> <new namespace>";
}
@Override
public String description() {
- return "renames a table namespace";
+ return "renames a namespace";
}
@Override
public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> special) {
- registerCompletionForTableNamespaces(root, special);
+ registerCompletionForNamespaces(root, special);
}
@Override
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RenameTableCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RenameTableCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RenameTableCommand.java
index 4ba039d..fe86f35 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RenameTableCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RenameTableCommand.java
@@ -38,7 +38,7 @@ public class RenameTableCommand extends Command {
if (shellState.getTableName().equals(cl.getArgs()[0])) {
String tableName = cl.getArgs()[1];
String n = Tables.extractNamespace(tableName);
- if (n.equals(Constants.DEFAULT_TABLE_NAMESPACE) || n.equals(Constants.SYSTEM_TABLE_NAMESPACE)) {
+ if (n.equals(Constants.DEFAULT_NAMESPACE) || n.equals(Constants.SYSTEM_NAMESPACE)) {
tableName = Tables.extractTableName(tableName);
}
shellState.setTableName(tableName);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/ea8ec193/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RevokeCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RevokeCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RevokeCommand.java
index cc9cd93..dac864d 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RevokeCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/RevokeCommand.java
@@ -19,8 +19,8 @@ package org.apache.accumulo.core.util.shell.commands;
import java.util.Map;
import java.util.Set;
+import org.apache.accumulo.core.security.NamespacePermission;
import org.apache.accumulo.core.security.SystemPermission;
-import org.apache.accumulo.core.security.TableNamespacePermission;
import org.apache.accumulo.core.security.TablePermission;
import org.apache.accumulo.core.util.BadArgumentException;
import org.apache.accumulo.core.util.shell.Shell;
@@ -35,15 +35,15 @@ public class RevokeCommand extends TableOperation {
{
disableUnflaggedTableOptions();
}
-
+
private Option systemOpt, userOpt;
private String user;
private String[] permission;
-
+
@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
user = cl.hasOption(userOpt.getOpt()) ? cl.getOptionValue(userOpt.getOpt()) : shellState.getConnector().whoami();
-
+
permission = cl.getArgs()[0].split("\\.", 2);
if (cl.hasOption(systemOpt.getOpt()) && permission[0].equalsIgnoreCase("System")) {
try {
@@ -55,22 +55,22 @@ public class RevokeCommand extends TableOperation {
} else if (permission[0].equalsIgnoreCase("Table")) {
super.execute(fullCommand, cl, shellState);
} else if (permission[0].equalsIgnoreCase("Namespace")) {
- if (cl.hasOption(optTableNamespace.getOpt())) {
+ if (cl.hasOption(optNamespace.getOpt())) {
try {
shellState.getConnector().securityOperations()
- .revokeTableNamespacePermission(user, cl.getOptionValue(optTableNamespace.getOpt()), TableNamespacePermission.valueOf(permission[1]));
+ .revokeNamespacePermission(user, cl.getOptionValue(optNamespace.getOpt()), NamespacePermission.valueOf(permission[1]));
} catch (IllegalArgumentException e) {
- throw new BadArgumentException("No such table namespace permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
+ throw new BadArgumentException("No such namespace permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
}
} else {
- throw new BadArgumentException("No Table Namespace specified to apply permission to", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
- }
- }else {
+ throw new BadArgumentException("No namespace specified to apply permission to", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
+ }
+ } else {
throw new BadArgumentException("Unrecognized permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
}
return 0;
}
-
+
@Override
protected void doTableOp(final Shell shellState, final String tableName) throws Exception {
try {
@@ -80,52 +80,52 @@ public class RevokeCommand extends TableOperation {
throw new IllegalArgumentException("No such table permission", e);
}
}
-
+
@Override
public String description() {
return "revokes system or table permissions from a user";
}
-
+
@Override
public String usage() {
return getName() + " <permission>";
}
-
+
@Override
public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> completionSet) {
final Token cmd = new Token(getName());
cmd.addSubcommand(new Token(TablePermission.printableValues()));
cmd.addSubcommand(new Token(SystemPermission.printableValues()));
- cmd.addSubcommand(new Token(TableNamespacePermission.printableValues()));
+ cmd.addSubcommand(new Token(NamespacePermission.printableValues()));
root.addSubcommand(cmd);
}
-
+
@Override
public Options getOptions() {
super.getOptions();
final Options o = new Options();
-
+
final OptionGroup group = new OptionGroup();
-
+
systemOpt = new Option("s", "system", false, "revoke a system permission");
-
- optTableNamespace = new Option(Shell.tableNamespaceOption, "table-namespace", true, "name of a table namespace to operate on");
- optTableNamespace.setArgName("tableNamespace");
-
+
+ optNamespace = new Option(Shell.namespaceOption, "namespace", true, "name of a namespace to operate on");
+ optNamespace.setArgName("namespace");
+
group.addOption(systemOpt);
group.addOption(optTableName);
group.addOption(optTablePattern);
- group.addOption(optTableNamespace);
-
+ group.addOption(optNamespace);
+
o.addOptionGroup(group);
userOpt = new Option(Shell.userOption, "user", true, "user to operate on");
userOpt.setArgName("username");
userOpt.setRequired(true);
o.addOption(userOpt);
-
+
return o;
}
-
+
@Override
public int numArgs() {
return 1;