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 2021/03/24 00:21:16 UTC
[accumulo] branch main updated: Minor cleanup of deprecated shell
commands
This is an automated email from the ASF dual-hosted git repository.
ctubbsii pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push:
new 1dc72fc Minor cleanup of deprecated shell commands
1dc72fc is described below
commit 1dc72fce2c781dee597c8c11876a3bc6c321c199
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Tue Mar 23 20:17:37 2021 -0400
Minor cleanup of deprecated shell commands
Follow-up from #1970
* Annotate deprecated commands for the shell the same way
* Suppress warnings from deprecated shell commands
* Update descriptions of deprecated shell commands to indicate they are
deprecated
* Remove redundant getName for ScriptCommand
* Use try-with-resources for reader and remove redundant super() and
remove foreach in favor of HashSet constructor that takes another
collection (IDE automated changes when saving file)
---
.../main/java/org/apache/accumulo/shell/Shell.java | 20 +++++++-------------
.../shell/commands/DeleteScanIterCommand.java | 3 ++-
.../accumulo/shell/commands/ScriptCommand.java | 11 ++---------
.../accumulo/shell/commands/SetScanIterCommand.java | 3 ++-
4 files changed, 13 insertions(+), 24 deletions(-)
diff --git a/shell/src/main/java/org/apache/accumulo/shell/Shell.java b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
index a206406..41d83bc 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/Shell.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
@@ -97,7 +97,6 @@ import org.apache.accumulo.shell.commands.DeleteIterCommand;
import org.apache.accumulo.shell.commands.DeleteManyCommand;
import org.apache.accumulo.shell.commands.DeleteNamespaceCommand;
import org.apache.accumulo.shell.commands.DeleteRowsCommand;
-import org.apache.accumulo.shell.commands.DeleteScanIterCommand;
import org.apache.accumulo.shell.commands.DeleteShellIterCommand;
import org.apache.accumulo.shell.commands.DeleteTableCommand;
import org.apache.accumulo.shell.commands.DeleteUserCommand;
@@ -147,11 +146,9 @@ import org.apache.accumulo.shell.commands.RenameNamespaceCommand;
import org.apache.accumulo.shell.commands.RenameTableCommand;
import org.apache.accumulo.shell.commands.RevokeCommand;
import org.apache.accumulo.shell.commands.ScanCommand;
-import org.apache.accumulo.shell.commands.ScriptCommand;
import org.apache.accumulo.shell.commands.SetAuthsCommand;
import org.apache.accumulo.shell.commands.SetGroupsCommand;
import org.apache.accumulo.shell.commands.SetIterCommand;
-import org.apache.accumulo.shell.commands.SetScanIterCommand;
import org.apache.accumulo.shell.commands.SetShellIterCommand;
import org.apache.accumulo.shell.commands.SleepCommand;
import org.apache.accumulo.shell.commands.SummariesCommand;
@@ -260,7 +257,6 @@ public class Shell extends ShellOptions implements KeywordExecutable {
public Shell() {}
public Shell(LineReader reader) {
- super();
this.reader = reader;
this.terminal = reader.getTerminal();
this.writer = terminal.writer();
@@ -394,13 +390,15 @@ public class Shell extends ShellOptions implements KeywordExecutable {
new ListScansCommand(), new ListCompactionsCommand(), new TraceCommand(),
new PingCommand(), new ListBulkCommand(), new ListTabletsCommand()};
@SuppressWarnings("deprecation")
- Command[] execCommands =
- {new ExecfileCommand(), new HistoryCommand(), new ExtensionCommand(), new ScriptCommand()};
+ Command[] execCommands = {new ExecfileCommand(), new HistoryCommand(), new ExtensionCommand(),
+ new org.apache.accumulo.shell.commands.ScriptCommand()};
Command[] exitCommands = {new ByeCommand(), new ExitCommand(), new QuitCommand()};
Command[] helpCommands =
{new AboutCommand(), new HelpCommand(), new InfoCommand(), new QuestionCommand()};
- Command[] iteratorCommands = {new DeleteIterCommand(), new DeleteScanIterCommand(),
- new ListIterCommand(), new SetIterCommand(), new SetScanIterCommand(),
+ @SuppressWarnings("deprecation")
+ Command[] iteratorCommands = {new DeleteIterCommand(),
+ new org.apache.accumulo.shell.commands.DeleteScanIterCommand(), new ListIterCommand(),
+ new SetIterCommand(), new org.apache.accumulo.shell.commands.SetScanIterCommand(),
new SetShellIterCommand(), new ListShellIterCommand(), new DeleteShellIterCommand()};
Command[] otherCommands = {new HiddenCommand()};
Command[] permissionsCommands = {new GrantCommand(), new RevokeCommand(),
@@ -844,11 +842,7 @@ public class Shell extends ShellOptions implements KeywordExecutable {
Map<Command.CompletionSet,Set<String>> options = new HashMap<>();
- Set<String> commands = new HashSet<>();
- for (String a : commandFactory.keySet()) {
- commands.add(a);
- }
-
+ Set<String> commands = new HashSet<>(commandFactory.keySet());
Set<String> modifiedUserlist = new HashSet<>();
Set<String> modifiedTablenames = new HashSet<>();
Set<String> modifiedNamespaces = new HashSet<>();
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/DeleteScanIterCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/DeleteScanIterCommand.java
index e59700d..d5e4a88 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/DeleteScanIterCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/DeleteScanIterCommand.java
@@ -29,6 +29,7 @@ import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionGroup;
import org.apache.commons.cli.Options;
+@Deprecated
public class DeleteScanIterCommand extends Command {
private Option nameOpt, allOpt;
@@ -79,7 +80,7 @@ public class DeleteScanIterCommand extends Command {
@Override
public String description() {
- return "deletes a table-specific scan iterator so it is no longer used"
+ return "(deprecated) deletes a table-specific scan iterator so it is no longer used"
+ " during this shell session";
}
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/ScriptCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/ScriptCommand.java
index 59cb596..9479fa4 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/ScriptCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/ScriptCommand.java
@@ -145,7 +145,7 @@ public class ScriptCommand extends Command {
return 1;
}
Reader reader = new FileReader(f, UTF_8);
- try {
+ try (reader) {
engine.eval(reader, ctx);
if (invoke) {
this.invokeFunctionOrMethod(shellState, engine, cl, argArray);
@@ -154,7 +154,6 @@ public class ScriptCommand extends Command {
shellState.printException(ex);
return 1;
} finally {
- reader.close();
if (writer != null) {
writer.close();
}
@@ -194,7 +193,6 @@ public class ScriptCommand extends Command {
return 0;
}
- @SuppressWarnings("deprecation")
private void putConnector(Bindings b, AccumuloClient client) {
try {
b.put("connection", org.apache.accumulo.core.client.Connector.from(client));
@@ -205,7 +203,7 @@ public class ScriptCommand extends Command {
@Override
public String description() {
- return "execute JSR-223 scripts";
+ return "(deprecated) execute JSR-223 scripts";
}
@Override
@@ -214,11 +212,6 @@ public class ScriptCommand extends Command {
}
@Override
- public String getName() {
- return "script";
- }
-
- @Override
public Options getOptions() {
final Options o = new Options();
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/SetScanIterCommand.java b/shell/src/main/java/org/apache/accumulo/shell/commands/SetScanIterCommand.java
index a92a0c1..eecbac8 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/SetScanIterCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/SetScanIterCommand.java
@@ -38,6 +38,7 @@ import org.apache.commons.cli.Option;
import org.apache.commons.cli.OptionGroup;
import org.apache.commons.cli.Options;
+@Deprecated
public class SetScanIterCommand extends SetIterCommand {
@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState)
@@ -81,7 +82,7 @@ public class SetScanIterCommand extends SetIterCommand {
@Override
public String description() {
- return "sets a table-specific scan iterator for this shell session";
+ return "(deprecated) sets a table-specific scan iterator for this shell session";
}
@Override