You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2014/04/08 05:03:39 UTC
[43/53] [abbrv] ACCUMULO-1879 Move shell into new package and module
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FormatterCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FormatterCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FormatterCommand.java
deleted file mode 100644
index 631c6e6..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/FormatterCommand.java
+++ /dev/null
@@ -1,69 +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.util.shell.commands;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.util.format.Formatter;
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-public class FormatterCommand extends ShellPluginConfigurationCommand {
-
- private Option interpeterOption;
-
- public FormatterCommand() {
- super("formatter", Property.TABLE_FORMATTER_CLASS, "f");
- }
-
- @Override
- public String description() {
- return "specifies a formatter to use for displaying table entries";
- }
-
- public static Class<? extends Formatter> getCurrentFormatter(final String tableName, final Shell shellState) {
- return ShellPluginConfigurationCommand.getPluginClass(tableName, shellState, Formatter.class, Property.TABLE_FORMATTER_CLASS);
- }
-
- @Override
- public Options getOptions() {
- final Options options = super.getOptions();
-
- interpeterOption = new Option("i", "interpeter", false, "configure class as interpreter also");
-
- options.addOption(interpeterOption);
-
- return options;
- }
-
- protected void setPlugin(final CommandLine cl, final Shell shellState, final String tableName, final String className) throws AccumuloException, AccumuloSecurityException {
- super.setPlugin(cl, shellState, tableName, className);
- if (cl.hasOption(interpeterOption.getOpt())) {
- shellState.getConnector().tableOperations().setProperty(tableName, Property.TABLE_INTERPRETER_CLASS.toString(), className);
- }
- }
-
- protected void removePlugin(final CommandLine cl, final Shell shellState, final String tableName) throws AccumuloException, AccumuloSecurityException {
- super.removePlugin(cl, shellState, tableName);
- if (cl.hasOption(interpeterOption.getOpt())) {
- shellState.getConnector().tableOperations().removeProperty(tableName, Property.TABLE_INTERPRETER_CLASS.toString());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
deleted file mode 100644
index e40a83f..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
+++ /dev/null
@@ -1,67 +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.util.shell.commands;
-
-import java.io.IOException;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.Command;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.lang.StringUtils;
-
-public class GetAuthsCommand extends Command {
- private Option userOpt;
-
- @Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException {
- final String user = cl.getOptionValue(userOpt.getOpt(), shellState.getConnector().whoami());
- // Sort authorizations
- Authorizations auths = shellState.getConnector().securityOperations().getUserAuthorizations(user);
- SortedSet<String> set = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
- for (byte[] auth : auths) {
- set.add(new String(auth));
- }
- shellState.getReader().println(StringUtils.join(set, ','));
- return 0;
- }
-
- @Override
- public String description() {
- return "displays the maximum scan authorizations for a user";
- }
-
- @Override
- public Options getOptions() {
- final Options o = new Options();
- userOpt = new Option(Shell.userOption, "user", true, "user to operate on");
- userOpt.setArgName("user");
- o.addOption(userOpt);
- return o;
- }
-
- @Override
- public int numArgs() {
- return 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetGroupsCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetGroupsCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetGroupsCommand.java
deleted file mode 100644
index bef2e5c..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetGroupsCommand.java
+++ /dev/null
@@ -1,60 +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.util.shell.commands;
-
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.apache.accumulo.core.util.LocalityGroupUtil;
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.Command;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Options;
-import org.apache.hadoop.io.Text;
-
-public class GetGroupsCommand extends Command {
-
- @Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
- final String tableName = OptUtil.getTableOpt(cl, shellState);
-
- final Map<String,Set<Text>> groups = shellState.getConnector().tableOperations().getLocalityGroups(tableName);
-
- for (Entry<String,Set<Text>> entry : groups.entrySet()) {
- shellState.getReader().println(entry.getKey() + "=" + LocalityGroupUtil.encodeColumnFamilies(entry.getValue()));
- }
- return 0;
- }
-
- @Override
- public String description() {
- return "gets the locality groups for a given table";
- }
-
- @Override
- public int numArgs() {
- return 0;
- }
-
- @Override
- public Options getOptions() {
- final Options opts = new Options();
- opts.addOption(OptUtil.tableOpt("table to fetch locality groups from"));
- return opts;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java
deleted file mode 100644
index 92c7c5d..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java
+++ /dev/null
@@ -1,155 +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.util.shell.commands;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.Iterator;
-import java.util.Map.Entry;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.KeyExtent;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.metadata.MetadataTable;
-import org.apache.accumulo.core.metadata.RootTable;
-import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.util.TextUtil;
-import org.apache.accumulo.core.util.format.BinaryFormatter;
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.Command;
-import org.apache.accumulo.core.util.shell.Shell.PrintFile;
-import org.apache.accumulo.core.util.shell.Shell.PrintLine;
-import org.apache.accumulo.core.util.shell.Shell.PrintShell;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.hadoop.io.Text;
-
-public class GetSplitsCommand extends Command {
-
- private Option outputFileOpt, maxSplitsOpt, base64Opt, verboseOpt;
-
- @Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException, AccumuloException, AccumuloSecurityException,
- TableNotFoundException {
- final String tableName = OptUtil.getTableOpt(cl, shellState);
-
- final String outputFile = cl.getOptionValue(outputFileOpt.getOpt());
- final String m = cl.getOptionValue(maxSplitsOpt.getOpt());
- final int maxSplits = m == null ? 0 : Integer.parseInt(m);
- final boolean encode = cl.hasOption(base64Opt.getOpt());
- final boolean verbose = cl.hasOption(verboseOpt.getOpt());
-
- final PrintLine p = outputFile == null ? new PrintShell(shellState.getReader()) : new PrintFile(outputFile);
-
- try {
- if (!verbose) {
- for (Text row : maxSplits > 0 ? shellState.getConnector().tableOperations().listSplits(tableName, maxSplits) : shellState.getConnector()
- .tableOperations().listSplits(tableName)) {
- p.print(encode(encode, row));
- }
- } else {
- String systemTableToCheck = MetadataTable.NAME.equals(tableName) ? RootTable.NAME : MetadataTable.NAME;
- final Scanner scanner = shellState.getConnector().createScanner(systemTableToCheck, Authorizations.EMPTY);
- TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.fetch(scanner);
- final Text start = new Text(shellState.getConnector().tableOperations().tableIdMap().get(tableName));
- final Text end = new Text(start);
- end.append(new byte[] {'<'}, 0, 1);
- scanner.setRange(new Range(start, end));
- for (Iterator<Entry<Key,Value>> iterator = scanner.iterator(); iterator.hasNext();) {
- final Entry<Key,Value> next = iterator.next();
- if (TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.hasColumns(next.getKey())) {
- KeyExtent extent = new KeyExtent(next.getKey().getRow(), next.getValue());
- final String pr = encode(encode, extent.getPrevEndRow());
- final String er = encode(encode, extent.getEndRow());
- final String line = String.format("%-26s (%s, %s%s", obscuredTabletName(extent), pr == null ? "-inf" : pr, er == null ? "+inf" : er,
- er == null ? ") Default Tablet " : "]");
- p.print(line);
- }
- }
- }
-
- } finally {
- p.close();
- }
-
- return 0;
- }
-
- private static String encode(final boolean encode, final Text text) {
- if (text == null) {
- return null;
- }
- BinaryFormatter.getlength(text.getLength());
- return encode ? new String(Base64.encodeBase64(TextUtil.getBytes(text)), StandardCharsets.UTF_8) : BinaryFormatter.appendText(new StringBuilder(), text).toString();
- }
-
- private static String obscuredTabletName(final KeyExtent extent) {
- MessageDigest digester;
- try {
- digester = MessageDigest.getInstance("MD5");
- } catch (NoSuchAlgorithmException e) {
- throw new RuntimeException(e);
- }
- if (extent.getEndRow() != null && extent.getEndRow().getLength() > 0) {
- digester.update(extent.getEndRow().getBytes(), 0, extent.getEndRow().getLength());
- }
- return new String(Base64.encodeBase64(digester.digest()), StandardCharsets.UTF_8);
- }
-
- @Override
- public String description() {
- return "retrieves the current split points for tablets in the current table";
- }
-
- @Override
- public int numArgs() {
- return 0;
- }
-
- @Override
- public Options getOptions() {
- final Options opts = new Options();
-
- outputFileOpt = new Option("o", "output", true, "local file to write the splits to");
- outputFileOpt.setArgName("file");
-
- maxSplitsOpt = new Option("m", "max", true, "maximum number of splits to return (evenly spaced)");
- maxSplitsOpt.setArgName("num");
-
- base64Opt = new Option("b64", "base64encoded", false, "encode the split points");
-
- verboseOpt = new Option("v", "verbose", false, "print out the tablet information with start/end rows");
-
- opts.addOption(outputFileOpt);
- opts.addOption(maxSplitsOpt);
- opts.addOption(base64Opt);
- opts.addOption(verboseOpt);
- opts.addOption(OptUtil.tableOpt("table to get splits for"));
-
- return opts;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/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
deleted file mode 100644
index de719fd..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrantCommand.java
+++ /dev/null
@@ -1,133 +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.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.util.BadArgumentException;
-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;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionGroup;
-import org.apache.commons.cli.Options;
-
-public class 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 {
- shellState.getConnector().securityOperations().grantSystemPermission(user, SystemPermission.valueOf(permission[1]));
- Shell.log.debug("Granted " + user + " the " + permission[1] + " permission");
- } catch (IllegalArgumentException e) {
- throw new BadArgumentException("No such system permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
- }
- } else if (permission[0].equalsIgnoreCase("Table")) {
- super.execute(fullCommand, cl, shellState);
- } else if (permission[0].equalsIgnoreCase("Namespace")) {
- if (cl.hasOption(optNamespace.getOpt())) {
- try {
- shellState.getConnector().securityOperations()
- .grantNamespacePermission(user, cl.getOptionValue(optNamespace.getOpt()), NamespacePermission.valueOf(permission[1]));
- } catch (IllegalArgumentException e) {
- throw new BadArgumentException("No such namespace permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
- }
- } else {
- throw new BadArgumentException("No namespace specified to apply permission to", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
- }
- } else {
- throw new BadArgumentException("Unrecognized permission", fullCommand, fullCommand.indexOf(cl.getArgs()[0]));
- }
- return 0;
- }
-
- @Override
- protected void doTableOp(final Shell shellState, final String tableName) throws Exception {
- try {
- shellState.getConnector().securityOperations().grantTablePermission(user, tableName, TablePermission.valueOf(permission[1]));
- Shell.log.debug("Granted " + user + " the " + permission[1] + " permission on table " + tableName);
- } catch (IllegalArgumentException e) {
- throw new IllegalArgumentException("No such table permission", e);
- }
- }
-
- @Override
- public String description() {
- 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(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");
-
- optNamespace = new Option(Shell.namespaceOption, "namespace", true, "name of a namespace to operate on");
- optNamespace.setArgName("namespace");
-
- group.addOption(systemOpt);
- group.addOption(optTableName);
- group.addOption(optTablePattern);
- group.addOption(optNamespace);
-
- o.addOptionGroup(group);
- userOpt = new Option(Shell.userOption, "user", true, "user to operate on");
- userOpt.setArgName("username");
- userOpt.setRequired(true);
- o.addOption(userOpt);
-
- return o;
- }
-
- @Override
- public int numArgs() {
- return 1;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrepCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrepCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrepCommand.java
deleted file mode 100644
index c2ff232..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GrepCommand.java
+++ /dev/null
@@ -1,111 +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.util.shell.commands;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.accumulo.core.client.BatchScanner;
-import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.iterators.user.GrepIterator;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.util.format.Formatter;
-import org.apache.accumulo.core.util.interpret.ScanInterpreter;
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.PrintFile;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.MissingArgumentException;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-public class GrepCommand extends ScanCommand {
-
- private Option numThreadsOpt;
-
- @Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
- final PrintFile printFile = getOutputFile(cl);
-
- final String tableName = OptUtil.getTableOpt(cl, shellState);
-
- if (cl.getArgList().isEmpty()) {
- throw new MissingArgumentException("No terms specified");
- }
- final Class<? extends Formatter> formatter = getFormatter(cl, tableName, shellState);
- final ScanInterpreter interpeter = getInterpreter(cl, tableName, shellState);
-
- // handle first argument, if present, the authorizations list to
- // scan with
- int numThreads = 20;
- if (cl.hasOption(numThreadsOpt.getOpt())) {
- numThreads = Integer.parseInt(cl.getOptionValue(numThreadsOpt.getOpt()));
- }
- final Authorizations auths = getAuths(cl, shellState);
- final BatchScanner scanner = shellState.getConnector().createBatchScanner(tableName, auths, numThreads);
- scanner.setRanges(Collections.singletonList(getRange(cl, interpeter)));
-
- scanner.setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS);
-
- for (int i = 0; i < cl.getArgs().length; i++) {
- setUpIterator(Integer.MAX_VALUE - cl.getArgs().length + i, "grep" + i, cl.getArgs()[i], scanner, cl);
- }
- try {
- // handle columns
- fetchColumns(cl, scanner, interpeter);
-
- // output the records
- printRecords(cl, shellState, scanner, formatter, printFile);
- } finally {
- scanner.close();
- }
-
- return 0;
- }
-
- protected void setUpIterator(final int prio, final String name, final String term, final BatchScanner scanner, CommandLine cl) throws IOException {
- if (prio < 0) {
- throw new IllegalArgumentException("Priority < 0 " + prio);
- }
- final IteratorSetting grep = new IteratorSetting(prio, name, GrepIterator.class);
- GrepIterator.setTerm(grep, term);
- scanner.addScanIterator(grep);
- }
-
- @Override
- public String description() {
- return "searches each row, column family, column qualifier and value in a table for a substring (not a regular expression), in parallel, on the server side";
- }
-
- @Override
- public Options getOptions() {
- final Options opts = super.getOptions();
- numThreadsOpt = new Option("nt", "num-threads", true, "number of threads to use");
- opts.addOption(numThreadsOpt);
- return opts;
- }
-
- @Override
- public String usage() {
- return getName() + " <term>{ <term>}";
- }
-
- @Override
- public int numArgs() {
- return Shell.NO_FIXED_ARG_LENGTH_CHECK;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java
deleted file mode 100644
index 9881e00..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java
+++ /dev/null
@@ -1,129 +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.util.shell.commands;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.Command;
-import org.apache.accumulo.core.util.shell.ShellCommandException;
-import org.apache.accumulo.core.util.shell.Token;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-public class HelpCommand extends Command {
- private Option disablePaginationOpt;
- private Option noWrapOpt;
-
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws ShellCommandException, IOException {
- int numColumns = shellState.getReader().getTerminal().getWidth();
- if (cl.hasOption(noWrapOpt.getOpt())) {
- numColumns = Integer.MAX_VALUE;
- }
- // print help summary
- if (cl.getArgs().length == 0) {
- int i = 0;
- for (String cmd : shellState.commandFactory.keySet()) {
- i = Math.max(i, cmd.length());
- }
- if (numColumns < 40) {
- throw new IllegalArgumentException("numColumns must be at least 40 (was " + numColumns + ")");
- }
- final ArrayList<String> output = new ArrayList<String>();
- for (Entry<String,Command[]> cmdGroup : shellState.commandGrouping.entrySet()) {
- output.add(cmdGroup.getKey());
- for (Command c : cmdGroup.getValue()) {
- String n = c.getName();
- String s = c.description();
- if (s == null) {
- s = "";
- }
- int beginIndex = 0;
- int endIndex = s.length();
- while (beginIndex < endIndex && s.charAt(beginIndex) == ' ')
- beginIndex++;
- String dash = "-";
- while (endIndex > beginIndex && endIndex - beginIndex + i + 5 > numColumns) {
- endIndex = s.lastIndexOf(" ", numColumns + beginIndex - i - 5);
- if (endIndex == -1 || endIndex < beginIndex) {
- endIndex = numColumns + beginIndex - i - 5 - 1;
- output.add(String.format("%-" + i + "s %s %s-", n, dash, s.substring(beginIndex, endIndex)));
- dash = " ";
- beginIndex = endIndex;
- } else {
- output.add(String.format("%-" + i + "s %s %s", n, dash, s.substring(beginIndex, endIndex)));
- dash = " ";
- beginIndex = endIndex + 1;
- }
- n = "";
- endIndex = s.length();
- while (beginIndex < endIndex && s.charAt(beginIndex) == ' ') {
- beginIndex++;
- }
- }
- output.add(String.format("%-" + i + "s %s %s", n, dash, s.substring(beginIndex, endIndex)));
- }
- output.add("");
- }
- shellState.printLines(output.iterator(), !cl.hasOption(disablePaginationOpt.getOpt()));
- }
-
- // print help for every command on command line
- for (String cmd : cl.getArgs()) {
- final Command c = shellState.commandFactory.get(cmd);
- if (c == null) {
- shellState.getReader().println(String.format("Unknown command \"%s\". Enter \"help\" for a list possible commands.", cmd));
- } else {
- c.printHelp(shellState, numColumns);
- }
- }
- return 0;
- }
-
- public String description() {
- return "provides information about the available commands";
- }
-
- public void registerCompletion(final Token root, final Map<Command.CompletionSet,Set<String>> special) {
- registerCompletionForCommands(root, special);
- }
-
- @Override
- public Options getOptions() {
- final Options o = new Options();
- disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output");
- o.addOption(disablePaginationOpt);
- noWrapOpt = new Option("nw", "no-wrap", false, "disable wrapping of output");
- o.addOption(noWrapOpt);
- return o;
- }
-
- @Override
- public String usage() {
- return getName() + " [ <command>{ <command>} ]";
- }
-
- @Override
- public int numArgs() {
- return Shell.NO_FIXED_ARG_LENGTH_CHECK;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java
deleted file mode 100644
index c1615ea..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java
+++ /dev/null
@@ -1,62 +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.util.shell.commands;
-
-import java.nio.charset.StandardCharsets;
-import java.security.SecureRandom;
-import java.util.Random;
-
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.Command;
-import org.apache.accumulo.core.util.shell.ShellCommandException;
-import org.apache.accumulo.core.util.shell.ShellCommandException.ErrorCode;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.codec.binary.Base64;
-
-public class HiddenCommand extends Command {
- private static Random rand = new SecureRandom();
-
- @Override
- public String description() {
- return "The first rule of Accumulo is: \"You don't talk about Accumulo.\"";
- }
-
- @Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
- if (rand.nextInt(10) == 0) {
- shellState.getReader().beep();
- shellState.getReader().println();
- shellState.getReader().println(
- new String(Base64.decodeBase64(("ICAgICAgIC4tLS4KICAgICAgLyAvXCBcCiAgICAgKCAvLS1cICkKICAgICAuPl8gIF88LgogICAgLyB8ICd8ICcgXAog"
- + "ICAvICB8Xy58Xy4gIFwKICAvIC98ICAgICAgfFwgXAogfCB8IHwgfFwvfCB8IHwgfAogfF98IHwgfCAgfCB8IHxffAogICAgIC8gIF9fICBcCiAgICAvICAv"
- + "ICBcICBcCiAgIC8gIC8gICAgXCAgXF8KIHwvICAvICAgICAgXCB8IHwKIHxfXy8gICAgICAgIFx8X3wK").getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8));
- } else {
- throw new ShellCommandException(ErrorCode.UNRECOGNIZED_COMMAND, getName());
- }
- return 0;
- }
-
- @Override
- public int numArgs() {
- return Shell.NO_FIXED_ARG_LENGTH_CHECK;
- }
-
- @Override
- public String getName() {
- return "accvmvlo";
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HistoryCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HistoryCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HistoryCommand.java
deleted file mode 100644
index 9531d90..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HistoryCommand.java
+++ /dev/null
@@ -1,82 +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.util.shell.commands;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.ListIterator;
-
-import jline.console.history.History.Entry;
-
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.Command;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.collections.iterators.AbstractIteratorDecorator;
-
-public class HistoryCommand extends Command {
- private Option clearHist;
- private Option disablePaginationOpt;
-
- @SuppressWarnings("unchecked")
- @Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException {
- if (cl.hasOption(clearHist.getOpt())) {
- shellState.getReader().getHistory().clear();
- } else {
- ListIterator<Entry> it = shellState.getReader().getHistory().entries();
- shellState.printLines(new HistoryLineIterator(it), !cl.hasOption(disablePaginationOpt.getOpt()));
- }
-
- return 0;
- }
-
- /**
- * Decorator that converts an Iterator<History.Entry> to an Iterator<String>.
- */
- private static class HistoryLineIterator extends AbstractIteratorDecorator {
- public HistoryLineIterator(Iterator<Entry> iterator) {
- super(iterator);
- }
-
- @Override
- public String next() {
- return super.next().toString();
- }
- }
-
- @Override
- public String description() {
- return ("generates a list of commands previously executed");
- }
-
- @Override
- public int numArgs() {
- return 0;
- }
-
- @Override
- public Options getOptions() {
- final Options o = new Options();
- clearHist = new Option("c", "clear", false, "clear history file");
- o.addOption(clearHist);
- disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output");
- o.addOption(disablePaginationOpt);
- return o;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ImportDirectoryCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ImportDirectoryCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ImportDirectoryCommand.java
deleted file mode 100644
index 13db3a4..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ImportDirectoryCommand.java
+++ /dev/null
@@ -1,58 +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.util.shell.commands;
-
-import java.io.IOException;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.Command;
-import org.apache.commons.cli.CommandLine;
-
-public class ImportDirectoryCommand extends Command {
-
- @Override
- public String description() {
- return "bulk imports an entire directory of data files to the current table. The boolean argument determines if accumulo sets the time.";
- }
-
- @Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException, AccumuloException, AccumuloSecurityException,
- TableNotFoundException {
- shellState.checkTableState();
-
- String dir = cl.getArgs()[0];
- String failureDir = cl.getArgs()[1];
- final boolean setTime = Boolean.parseBoolean(cl.getArgs()[2]);
-
- shellState.getConnector().tableOperations().importDirectory(shellState.getTableName(), dir, failureDir, setTime);
- return 0;
- }
-
- @Override
- public int numArgs() {
- return 3;
- }
-
- @Override
- public String usage() {
- return getName() + " <directory> <failureDirectory> true|false";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ImportTableCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ImportTableCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ImportTableCommand.java
deleted file mode 100644
index 571c45b..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ImportTableCommand.java
+++ /dev/null
@@ -1,51 +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.util.shell.commands;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.TableExistsException;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.Command;
-import org.apache.commons.cli.CommandLine;
-
-public class ImportTableCommand extends Command {
-
- @Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
- TableExistsException {
-
- shellState.getConnector().tableOperations().importTable(cl.getArgs()[0], cl.getArgs()[1]);
- return 0;
- }
-
- @Override
- public String usage() {
- return getName() + " <table name> <import dir>";
- }
-
- @Override
- public String description() {
- return "imports a table";
- }
-
- @Override
- public int numArgs() {
- return 2;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InfoCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InfoCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InfoCommand.java
deleted file mode 100644
index 57de6b1..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InfoCommand.java
+++ /dev/null
@@ -1,19 +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.util.shell.commands;
-
-public class InfoCommand extends AboutCommand {}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InsertCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InsertCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InsertCommand.java
deleted file mode 100644
index a97db05..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InsertCommand.java
+++ /dev/null
@@ -1,148 +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.util.shell.commands;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
-import org.apache.accumulo.core.client.MutationsRejectedException;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.security.SecurityErrorCode;
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.data.ConstraintViolationSummary;
-import org.apache.accumulo.core.data.KeyExtent;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.security.ColumnVisibility;
-import org.apache.accumulo.core.tabletserver.thrift.ConstraintViolationException;
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.Command;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.hadoop.io.Text;
-
-public class InsertCommand extends Command {
- private Option insertOptAuths, timestampOpt;
- private Option timeoutOption;
-
- protected long getTimeout(final CommandLine cl) {
- if (cl.hasOption(timeoutOption.getLongOpt())) {
- return AccumuloConfiguration.getTimeInMillis(cl.getOptionValue(timeoutOption.getLongOpt()));
- }
-
- return Long.MAX_VALUE;
- }
-
- @Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException,
- TableNotFoundException, IOException, ConstraintViolationException {
- shellState.checkTableState();
-
- final Mutation m = new Mutation(new Text(cl.getArgs()[0].getBytes(Shell.CHARSET)));
- final Text colf = new Text(cl.getArgs()[1].getBytes(Shell.CHARSET));
- final Text colq = new Text(cl.getArgs()[2].getBytes(Shell.CHARSET));
- final Value val = new Value(cl.getArgs()[3].getBytes(Shell.CHARSET));
-
- if (cl.hasOption(insertOptAuths.getOpt())) {
- final ColumnVisibility le = new ColumnVisibility(cl.getOptionValue(insertOptAuths.getOpt()));
- Shell.log.debug("Authorization label will be set to: " + le.toString());
-
- if (cl.hasOption(timestampOpt.getOpt()))
- m.put(colf, colq, le, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt())), val);
- else
- m.put(colf, colq, le, val);
- } else if (cl.hasOption(timestampOpt.getOpt()))
- m.put(colf, colq, Long.parseLong(cl.getOptionValue(timestampOpt.getOpt())), val);
- else
- m.put(colf, colq, val);
-
- final BatchWriter bw = shellState.getConnector().createBatchWriter(shellState.getTableName(),
- new BatchWriterConfig().setMaxMemory(Math.max(m.estimatedMemoryUsed(), 1024)).setMaxWriteThreads(1).setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS));
- bw.addMutation(m);
- try {
- bw.close();
- } catch (MutationsRejectedException e) {
- final ArrayList<String> lines = new ArrayList<String>();
- if (e.getAuthorizationFailuresMap().isEmpty() == false) {
- lines.add(" Authorization Failures:");
- }
- for (Entry<KeyExtent,Set<SecurityErrorCode>> entry : e.getAuthorizationFailuresMap().entrySet()) {
- lines.add(" " + entry);
- }
- if (e.getConstraintViolationSummaries().isEmpty() == false) {
- lines.add(" Constraint Failures:");
- }
- for (ConstraintViolationSummary cvs : e.getConstraintViolationSummaries()) {
- lines.add(" " + cvs.toString());
- }
-
- if (lines.size() == 0 || e.getUnknownExceptions() > 0) {
- // must always print something
- lines.add(" " + e.getClass().getName() + " : " + e.getMessage());
- if (e.getCause() != null)
- lines.add(" Caused by : " + e.getCause().getClass().getName() + " : " + e.getCause().getMessage());
- }
-
- shellState.printLines(lines.iterator(), false);
-
- return 1;
- }
- return 0;
- }
-
- @Override
- public String description() {
- return "inserts a record";
- }
-
- @Override
- public String usage() {
- return getName() + " <row> <colfamily> <colqualifier> <value>";
- }
-
- @Override
- public Options getOptions() {
- final Options o = new Options();
- insertOptAuths = new Option("l", "visibility-label", true, "formatted visibility");
- insertOptAuths.setArgName("expression");
- o.addOption(insertOptAuths);
-
- timestampOpt = new Option("ts", "timestamp", true, "timestamp to use for insert");
- timestampOpt.setArgName("timestamp");
- o.addOption(timestampOpt);
-
- timeoutOption = new Option(null, "timeout", true,
- "time before insert should fail if no data is written. If no unit is given assumes seconds. Units d,h,m,s,and ms are supported. e.g. 30s or 100ms");
- timeoutOption.setArgName("timeout");
- o.addOption(timeoutOption);
-
- return o;
- }
-
- @Override
- public int numArgs() {
- return 4;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InterpreterCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InterpreterCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InterpreterCommand.java
deleted file mode 100644
index 090bd7f..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/InterpreterCommand.java
+++ /dev/null
@@ -1,40 +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.util.shell.commands;
-
-import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.util.interpret.ScanInterpreter;
-import org.apache.accumulo.core.util.shell.Shell;
-
-/**
- *
- */
-public class InterpreterCommand extends ShellPluginConfigurationCommand {
-
- public InterpreterCommand() {
- super("interpreter", Property.TABLE_INTERPRETER_CLASS, "i");
- }
-
- @Override
- public String description() {
- return "specifies a scan interpreter to interpret scan range and column arguments";
- }
-
- public static Class<? extends ScanInterpreter> getCurrentInterpreter(final String tableName, final Shell shellState) {
- return ShellPluginConfigurationCommand.getPluginClass(tableName, shellState, ScanInterpreter.class, Property.TABLE_INTERPRETER_CLASS);
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListCompactionsCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListCompactionsCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListCompactionsCommand.java
deleted file mode 100644
index baa59a0..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListCompactionsCommand.java
+++ /dev/null
@@ -1,78 +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.util.shell.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.accumulo.core.client.admin.InstanceOperations;
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.Command;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-public class ListCompactionsCommand extends Command {
-
- private Option tserverOption, disablePaginationOpt;
-
- @Override
- public String description() {
- return "lists what compactions are currently running in accumulo. See the accumulo.core.client.admin.ActiveCompaciton javadoc for more information about columns.";
- }
-
- @Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
-
- List<String> tservers;
-
- final InstanceOperations instanceOps = shellState.getConnector().instanceOperations();
-
- final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt());
-
- if (cl.hasOption(tserverOption.getOpt())) {
- tservers = new ArrayList<String>();
- tservers.add(cl.getOptionValue(tserverOption.getOpt()));
- } else {
- tservers = instanceOps.getTabletServers();
- }
-
- shellState.printLines(new ActiveCompactionIterator(tservers, instanceOps), paginate);
-
- return 0;
- }
-
- @Override
- public int numArgs() {
- return 0;
- }
-
- @Override
- public Options getOptions() {
- final Options opts = new Options();
-
- tserverOption = new Option("ts", "tabletServer", true, "tablet server to list compactions for");
- tserverOption.setArgName("tablet server");
- opts.addOption(tserverOption);
-
- disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output");
- opts.addOption(disablePaginationOpt);
-
- return opts;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/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
deleted file mode 100644
index 9aac389..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java
+++ /dev/null
@@ -1,140 +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.util.shell.commands;
-
-import java.util.EnumMap;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.Command;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionGroup;
-import org.apache.commons.cli.Options;
-
-public class ListIterCommand extends Command {
- private Option nameOpt, allScopesOpt;
- private Map<IteratorScope,Option> scopeOpts;
-
- @Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
-
- boolean tables = cl.hasOption(OptUtil.tableOpt().getOpt()) || !shellState.getTableName().isEmpty();
- boolean namespaces = cl.hasOption(OptUtil.namespaceOpt().getOpt());
-
- final Map<String,EnumSet<IteratorScope>> iterators;
- if (namespaces) {
- iterators = shellState.getConnector().namespaceOperations().listIterators(OptUtil.getNamespaceOpt(cl, shellState));
- } else if (tables) {
- iterators = shellState.getConnector().tableOperations().listIterators(OptUtil.getTableOpt(cl, shellState));
- } else {
- throw new IllegalArgumentException("No table or namespace specified");
- }
-
- if (cl.hasOption(nameOpt.getOpt())) {
- final String name = cl.getOptionValue(nameOpt.getOpt());
- if (!iterators.containsKey(name)) {
- Shell.log.warn("no iterators found that match your criteria");
- return 0;
- }
- final EnumSet<IteratorScope> scopes = iterators.get(name);
- iterators.clear();
- iterators.put(name, scopes);
- }
-
- final boolean allScopes = cl.hasOption(allScopesOpt.getOpt());
- Set<IteratorScope> desiredScopes = new HashSet<IteratorScope>();
- for (IteratorScope scope : IteratorScope.values()) {
- if (allScopes || cl.hasOption(scopeOpts.get(scope).getOpt()))
- desiredScopes.add(scope);
- }
- if (desiredScopes.isEmpty()) {
- throw new IllegalArgumentException("You must select at least one scope to configure");
- }
- final StringBuilder sb = new StringBuilder("-\n");
- for (Entry<String,EnumSet<IteratorScope>> entry : iterators.entrySet()) {
- final String name = entry.getKey();
- final EnumSet<IteratorScope> scopes = entry.getValue();
- for (IteratorScope scope : scopes) {
- if (desiredScopes.contains(scope)) {
- IteratorSetting setting;
- if (namespaces) {
- setting = shellState.getConnector().namespaceOperations().getIteratorSetting(OptUtil.getNamespaceOpt(cl, shellState), name, scope);
- } else if (tables) {
- setting = shellState.getConnector().tableOperations().getIteratorSetting(OptUtil.getTableOpt(cl, shellState), name, scope);
- } else {
- throw new IllegalArgumentException("No table or namespace specified");
- }
- sb.append("- Iterator ").append(setting.getName()).append(", ").append(scope).append(" scope options:\n");
- sb.append("- ").append("iteratorPriority").append(" = ").append(setting.getPriority()).append("\n");
- sb.append("- ").append("iteratorClassName").append(" = ").append(setting.getIteratorClass()).append("\n");
- for (Entry<String,String> optEntry : setting.getOptions().entrySet()) {
- sb.append("- ").append(optEntry.getKey()).append(" = ").append(optEntry.getValue()).append("\n");
- }
- }
- }
- }
- sb.append("-");
- shellState.getReader().println(sb.toString());
-
- return 0;
- }
-
- @Override
- public String description() {
- return "lists table-specific or namespace-specific iterators configured in this shell session";
- }
-
- @Override
- public int numArgs() {
- return 0;
- }
-
- @Override
- public Options getOptions() {
- final Options o = new Options();
-
- nameOpt = new Option("n", "name", true, "iterator to list");
- nameOpt.setArgName("itername");
-
- allScopesOpt = new Option("all", "all-scopes", false, "list from all scopes");
- o.addOption(allScopesOpt);
-
- scopeOpts = new EnumMap<IteratorScope,Option>(IteratorScope.class);
- scopeOpts.put(IteratorScope.minc, new Option(IteratorScope.minc.name(), "minor-compaction", false, "list iterator for minor compaction scope"));
- scopeOpts.put(IteratorScope.majc, new Option(IteratorScope.majc.name(), "major-compaction", false, "list iterator for major compaction scope"));
- scopeOpts.put(IteratorScope.scan, new Option(IteratorScope.scan.name(), "scan-time", false, "list iterator for scan scope"));
-
- OptionGroup grp = new OptionGroup();
- grp.addOption(OptUtil.tableOpt("table to list the configured iterators on"));
- grp.addOption(OptUtil.namespaceOpt("namespace to list the configured iterators on"));
- o.addOptionGroup(grp);
- o.addOption(nameOpt);
-
- for (Option opt : scopeOpts.values()) {
- o.addOption(opt);
- }
-
- return o;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListScansCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListScansCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListScansCommand.java
deleted file mode 100644
index e4a2692..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListScansCommand.java
+++ /dev/null
@@ -1,78 +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.util.shell.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.accumulo.core.client.admin.InstanceOperations;
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.Command;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-public class ListScansCommand extends Command {
-
- private Option tserverOption, disablePaginationOpt;
-
- @Override
- public String description() {
- return "lists what scans are currently running in accumulo. See the accumulo.core.client.admin.ActiveScan javadoc for more information about columns.";
- }
-
- @Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
-
- List<String> tservers;
-
- final InstanceOperations instanceOps = shellState.getConnector().instanceOperations();
-
- final boolean paginate = !cl.hasOption(disablePaginationOpt.getOpt());
-
- if (cl.hasOption(tserverOption.getOpt())) {
- tservers = new ArrayList<String>();
- tservers.add(cl.getOptionValue(tserverOption.getOpt()));
- } else {
- tservers = instanceOps.getTabletServers();
- }
-
- shellState.printLines(new ActiveScanIterator(tservers, instanceOps), paginate);
-
- return 0;
- }
-
- @Override
- public int numArgs() {
- return 0;
- }
-
- @Override
- public Options getOptions() {
- final Options opts = new Options();
-
- tserverOption = new Option("ts", "tabletServer", true, "tablet server to list scans for");
- tserverOption.setArgName("tablet server");
- opts.addOption(tserverOption);
-
- disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output");
- opts.addOption(disablePaginationOpt);
-
- return opts;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListShellIterCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListShellIterCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListShellIterCommand.java
deleted file mode 100644
index 7f6ad84..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListShellIterCommand.java
+++ /dev/null
@@ -1,105 +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.util.shell.commands;
-
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.Command;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-/**
- *
- */
-public class ListShellIterCommand extends Command {
-
- private Option nameOpt, profileOpt;
-
- @Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
- if (shellState.iteratorProfiles.size() == 0)
- return 0;
-
- final StringBuilder sb = new StringBuilder();
-
- String profile = null;
- if (cl.hasOption(profileOpt.getOpt()))
- profile = cl.getOptionValue(profileOpt.getOpt());
-
- String name = null;
- if (cl.hasOption(nameOpt.getOpt()))
- name = cl.getOptionValue(nameOpt.getOpt());
-
- Set<Entry<String,List<IteratorSetting>>> es = shellState.iteratorProfiles.entrySet();
- for (Entry<String,List<IteratorSetting>> entry : es) {
- if (profile != null && !profile.equals(entry.getKey()))
- continue;
-
- sb.append("-\n");
- sb.append("- Profile : " + entry.getKey() + "\n");
- for (IteratorSetting setting : entry.getValue()) {
- if (name != null && !name.equals(setting.getName()))
- continue;
-
- sb.append("- Iterator ").append(setting.getName()).append(", ").append(" options:\n");
- sb.append("- ").append("iteratorPriority").append(" = ").append(setting.getPriority()).append("\n");
- sb.append("- ").append("iteratorClassName").append(" = ").append(setting.getIteratorClass()).append("\n");
- for (Entry<String,String> optEntry : setting.getOptions().entrySet()) {
- sb.append("- ").append(optEntry.getKey()).append(" = ").append(optEntry.getValue()).append("\n");
- }
- }
- }
-
- if (sb.length() > 0) {
- sb.append("-\n");
- }
-
- shellState.getReader().print(sb.toString());
-
- return 0;
- }
-
- public String description() {
- return "lists iterators profiles configured in shell";
- }
-
- @Override
- public int numArgs() {
- return 0;
- }
-
- @Override
- public Options getOptions() {
- final Options o = new Options();
-
- profileOpt = new Option("pn", "profile", true, "iterator profile name");
- profileOpt.setArgName("profile");
-
- nameOpt = new Option("n", "name", true, "iterator to list");
- nameOpt.setArgName("itername");
-
- o.addOption(profileOpt);
- o.addOption(nameOpt);
-
- return o;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MaxRowCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MaxRowCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MaxRowCommand.java
deleted file mode 100644
index ddb6cc1..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MaxRowCommand.java
+++ /dev/null
@@ -1,55 +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.util.shell.commands;
-
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.util.interpret.ScanInterpreter;
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.commons.cli.CommandLine;
-import org.apache.hadoop.io.Text;
-
-public class MaxRowCommand extends ScanCommand {
-
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
- final String tableName = OptUtil.getTableOpt(cl, shellState);
-
- final ScanInterpreter interpeter = getInterpreter(cl, tableName, shellState);
-
- final Range range = getRange(cl, interpeter);
- final Authorizations auths = getAuths(cl, shellState);
- final Text startRow = range.getStartKey() == null ? null : range.getStartKey().getRow();
- final Text endRow = range.getEndKey() == null ? null : range.getEndKey().getRow();
-
- try {
- final Text max = shellState.getConnector().tableOperations()
- .getMaxRow(tableName, auths, startRow, range.isStartKeyInclusive(), endRow, range.isEndKeyInclusive());
- if (max != null) {
- shellState.getReader().println(max.toString());
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return 0;
- }
-
- @Override
- public String description() {
- return "finds the max row in a table within a given range";
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java
deleted file mode 100644
index 9774e36..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/MergeCommand.java
+++ /dev/null
@@ -1,111 +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.util.shell.commands;
-
-import java.io.IOException;
-
-import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.util.Merge;
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.Command;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.hadoop.io.Text;
-
-public class MergeCommand extends Command {
- private Option verboseOpt, forceOpt, sizeOpt, allOpt;
-
- @Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
- boolean verbose = shellState.isVerbose();
- boolean force = false;
- boolean all = false;
- long size = -1;
- final String tableName = OptUtil.getTableOpt(cl, shellState);
- final Text startRow = OptUtil.getStartRow(cl);
- final Text endRow = OptUtil.getEndRow(cl);
- if (cl.hasOption(verboseOpt.getOpt())) {
- verbose = true;
- }
- if (cl.hasOption(forceOpt.getOpt())) {
- force = true;
- }
- if (cl.hasOption(allOpt.getOpt())) {
- all = true;
- }
- if (cl.hasOption(sizeOpt.getOpt())) {
- size = AccumuloConfiguration.getMemoryInBytes(cl.getOptionValue(sizeOpt.getOpt()));
- }
- if (startRow == null && endRow == null && size < 0 && !all) {
- shellState.getReader().flush();
- String line = shellState.getReader().readLine("Merge the entire table { " + tableName + " } into one tablet (yes|no)? ");
- if (line == null)
- return 0;
- if (!line.equalsIgnoreCase("y") && !line.equalsIgnoreCase("yes"))
- return 0;
- }
- if (size < 0) {
- shellState.getConnector().tableOperations().merge(tableName, startRow, endRow);
- } else {
- final boolean finalVerbose = verbose;
- final Merge merge = new Merge() {
- protected void message(String fmt, Object... args) {
- if (finalVerbose) {
- try {
- shellState.getReader().println(String.format(fmt, args));
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
- }
- };
- merge.mergomatic(shellState.getConnector(), tableName, startRow, endRow, size, force);
- }
- return 0;
- }
-
- @Override
- public String description() {
- return "merges tablets in a table";
- }
-
- @Override
- public int numArgs() {
- return 0;
- }
-
- @Override
- public Options getOptions() {
- final Options o = new Options();
- verboseOpt = new Option("v", "verbose", false, "verbose output during merge");
- sizeOpt = new Option("s", "size", true, "merge tablets to the given size over the entire table");
- forceOpt = new Option("f", "force", false, "merge small tablets to large tablets, even if it goes over the given size");
- allOpt = new Option("", "all", false, "allow an entire table to be merged into one tablet without prompting the user for confirmation");
- Option startRowOpt = OptUtil.startRowOpt();
- startRowOpt.setDescription("begin row (NOT inclusive)");
- o.addOption(startRowOpt);
- o.addOption(OptUtil.endRowOpt());
- o.addOption(OptUtil.tableOpt("table to be merged"));
- o.addOption(verboseOpt);
- o.addOption(sizeOpt);
- o.addOption(forceOpt);
- o.addOption(allOpt);
- return o;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/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
deleted file mode 100644
index 2dcba55..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacePermissionsCommand.java
+++ /dev/null
@@ -1,44 +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.util.shell.commands;
-
-import java.io.IOException;
-
-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;
-
-public class NamespacePermissionsCommand extends Command {
- @Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException {
- for (String p : NamespacePermission.printableValues()) {
- shellState.getReader().println(p);
- }
- return 0;
- }
-
- @Override
- public String description() {
- return "displays a list of valid namespace permissions";
- }
-
- @Override
- public int numArgs() {
- return 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/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
deleted file mode 100644
index 16ee645..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NamespacesCommand.java
+++ /dev/null
@@ -1,83 +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.util.shell.commands;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeMap;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.impl.Namespaces;
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.Command;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-
-import com.google.common.base.Function;
-import com.google.common.collect.Iterators;
-
-public class NamespacesCommand extends Command {
- private Option disablePaginationOpt, namespaceIdOption;
-
- private static final String DEFAULT_NAMESPACE_DISPLAY_NAME = "\"\"";
-
- @Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException {
- Map<String,String> namespaces = new TreeMap<String,String>(shellState.getConnector().namespaceOperations().namespaceIdMap());
-
- Iterator<String> it = Iterators.transform(namespaces.entrySet().iterator(), new Function<Entry<String,String>,String>() {
- @Override
- public String apply(Map.Entry<String,String> entry) {
- String name = entry.getKey();
- if (Namespaces.DEFAULT_NAMESPACE.equals(name))
- name = DEFAULT_NAMESPACE_DISPLAY_NAME;
- String id = entry.getValue();
- if (cl.hasOption(namespaceIdOption.getOpt()))
- return String.format(TablesCommand.NAME_AND_ID_FORMAT, name, id);
- else
- return name;
- };
- });
-
- shellState.printLines(it, !cl.hasOption(disablePaginationOpt.getOpt()));
- return 0;
- }
-
- @Override
- public String description() {
- return "displays a list of all existing namespaces";
- }
-
- @Override
- public Options getOptions() {
- final Options o = new Options();
- namespaceIdOption = new Option("l", "list-ids", false, "display internal namespace ids along with the name");
- o.addOption(namespaceIdOption);
- disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output");
- o.addOption(disablePaginationOpt);
- return o;
- }
-
- @Override
- public int numArgs() {
- return 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/066043d4/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NoTableCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NoTableCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NoTableCommand.java
deleted file mode 100644
index afdab53..0000000
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/NoTableCommand.java
+++ /dev/null
@@ -1,40 +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.util.shell.commands;
-
-import org.apache.accumulo.core.util.shell.Shell;
-import org.apache.accumulo.core.util.shell.Shell.Command;
-import org.apache.commons.cli.CommandLine;
-
-public class NoTableCommand extends Command {
- @Override
- public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
- shellState.setTableName("");
-
- return 0;
- }
-
- @Override
- public String description() {
- return "returns to a tableless shell state";
- }
-
- @Override
- public int numArgs() {
- return 0;
- }
-}