Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3BC7D1834F for ; Thu, 3 Sep 2015 21:30:10 +0000 (UTC) Received: (qmail 24039 invoked by uid 500); 3 Sep 2015 21:30:10 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 24007 invoked by uid 500); 3 Sep 2015 21:30:10 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 23992 invoked by uid 99); 3 Sep 2015 21:30:10 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Sep 2015 21:30:10 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id F22AEE7EB3; Thu, 3 Sep 2015 21:30:09 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kturner@apache.org To: commits@accumulo.apache.org Message-Id: <850df1fd41234208b7a25eccd8f60a86@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: accumulo git commit: ACCUMULO-3972 fix how setshelliter and setscaniter check classes can load Date: Thu, 3 Sep 2015 21:30:09 +0000 (UTC) Repository: accumulo Updated Branches: refs/heads/1.6 07ac4c85f -> e4ffc7797 ACCUMULO-3972 fix how setshelliter and setscaniter check classes can load Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/e4ffc779 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/e4ffc779 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/e4ffc779 Branch: refs/heads/1.6 Commit: e4ffc77974e80a085aad86a8089bfa13650d0530 Parents: 07ac4c8 Author: Keith Turner Authored: Thu Sep 3 16:43:40 2015 -0400 Committer: Keith Turner Committed: Thu Sep 3 16:43:40 2015 -0400 ---------------------------------------------------------------------- .../apache/accumulo/core/util/shell/Shell.java | 8 ++++---- .../core/util/shell/commands/CompactCommand.java | 5 +++++ .../core/util/shell/commands/ScanCommand.java | 18 +++++++++++++++++- .../core/util/shell/commands/SetIterCommand.java | 11 ++++------- .../util/shell/commands/SetScanIterCommand.java | 15 +-------------- .../util/shell/commands/SetShellIterCommand.java | 7 ------- 6 files changed, 31 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/e4ffc779/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java b/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java index 8cfb689..143ce28 100644 --- a/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java +++ b/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java @@ -40,10 +40,6 @@ import java.util.TreeMap; import java.util.UUID; import java.util.concurrent.TimeUnit; -import jline.console.ConsoleReader; -import jline.console.UserInterruptException; -import jline.console.history.FileHistory; - import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; @@ -180,6 +176,10 @@ import org.apache.log4j.Logger; import com.beust.jcommander.JCommander; import com.beust.jcommander.ParameterException; +import jline.console.ConsoleReader; +import jline.console.UserInterruptException; +import jline.console.history.FileHistory; + /** * A convenient console interface to perform basic accumulo functions Includes auto-complete, help, and quoted strings with escape sequences */ http://git-wip-us.apache.org/repos/asf/accumulo/blob/e4ffc779/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CompactCommand.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CompactCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CompactCommand.java index a535347..868e728 100644 --- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CompactCommand.java +++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CompactCommand.java @@ -47,6 +47,7 @@ public class CompactCommand extends TableOperation { return "sets all tablets for a table to major compact as soon as possible (based on current time)"; } + @Override protected void doTableOp(final Shell shellState, final String tableName) throws AccumuloException, AccumuloSecurityException { // compact the tables @@ -63,6 +64,10 @@ public class CompactCommand extends TableOperation { Shell.log.info("Compacting table ..."); } + for (IteratorSetting iteratorSetting : iterators) { + ScanCommand.ensureTserversCanLoadIterator(shellState, tableName, iteratorSetting.getIteratorClass()); + } + shellState.getConnector().tableOperations().compact(tableName, startRow, endRow, iterators, flush, wait); Shell.log.info("Compaction of table " + tableName + " " + (wait ? "completed" : "started") + " for given range"); http://git-wip-us.apache.org/repos/asf/accumulo/blob/e4ffc779/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java index 38736dd..78657b9 100644 --- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java +++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ScanCommand.java @@ -28,10 +28,12 @@ import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.IteratorSetting; import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.client.ScannerBase; +import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Range; import org.apache.accumulo.core.data.Value; +import org.apache.accumulo.core.iterators.SortedKeyValueIterator; import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.core.util.format.BinaryFormatter; import org.apache.accumulo.core.util.format.Formatter; @@ -40,6 +42,8 @@ import org.apache.accumulo.core.util.interpret.ScanInterpreter; 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.ShellCommandException; +import org.apache.accumulo.core.util.shell.ShellCommandException.ErrorCode; import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Option; @@ -116,7 +120,15 @@ public class ScanCommand extends Command { return Long.MAX_VALUE; } - protected void addScanIterators(final Shell shellState, CommandLine cl, final Scanner scanner, final String tableName) { + static void ensureTserversCanLoadIterator(final Shell shellState, String tableName, String classname) + throws AccumuloException, AccumuloSecurityException, TableNotFoundException, ShellCommandException { + if (!shellState.getConnector().tableOperations().testClassLoad(tableName, classname, SortedKeyValueIterator.class.getName())) { + throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, + "Servers are unable to load " + classname + " as type " + SortedKeyValueIterator.class.getName()); + } + } + + protected void addScanIterators(final Shell shellState, CommandLine cl, final Scanner scanner, final String tableName) throws Exception { List tableScanIterators; if (cl.hasOption(profileOpt.getOpt())) { @@ -126,6 +138,10 @@ public class ScanCommand extends Command { if (tableScanIterators == null) { throw new IllegalArgumentException("Profile " + profile + " does not exist"); } + + for (IteratorSetting iteratorSetting : tableScanIterators) { + ensureTserversCanLoadIterator(shellState, tableName, iteratorSetting.getIteratorClass()); + } } else { tableScanIterators = shellState.scanIteratorOptions.get(tableName); if (tableScanIterators == null) { http://git-wip-us.apache.org/repos/asf/accumulo/blob/e4ffc779/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java index 2266f52..0ff240b 100644 --- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java +++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java @@ -23,8 +23,6 @@ import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; -import jline.console.ConsoleReader; - import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.IteratorSetting; @@ -50,6 +48,8 @@ import org.apache.commons.cli.OptionGroup; import org.apache.commons.cli.Options; import org.apache.commons.lang.StringUtils; +import jline.console.ConsoleReader; + public class SetIterCommand extends Command { private Option allScopeOpt, mincScopeOpt, majcScopeOpt, scanScopeOpt, nameOpt, priorityOpt; @@ -117,10 +117,7 @@ public class SetIterCommand extends Command { final String tableName = OptUtil.getTableOpt(cl, shellState); - if (!shellState.getConnector().tableOperations().testClassLoad(tableName, classname, SortedKeyValueIterator.class.getName())) { - throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Servers are unable to load " + classname + " as type " - + SortedKeyValueIterator.class.getName()); - } + ScanCommand.ensureTserversCanLoadIterator(shellState, tableName, classname); final String aggregatorClass = options.get("aggregatorClass"); @SuppressWarnings("deprecation") @@ -225,7 +222,7 @@ public class SetIterCommand extends Command { } @SuppressWarnings("unchecked") - SortedKeyValueIterator skvi = (SortedKeyValueIterator) untypedInstance; + SortedKeyValueIterator skvi = untypedInstance; OptionDescriber iterOptions = null; if (OptionDescriber.class.isAssignableFrom(skvi.getClass())) { iterOptions = (OptionDescriber) skvi; http://git-wip-us.apache.org/repos/asf/accumulo/blob/e4ffc779/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetScanIterCommand.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetScanIterCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetScanIterCommand.java index 9c74586..95efd22 100644 --- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetScanIterCommand.java +++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetScanIterCommand.java @@ -30,11 +30,9 @@ import org.apache.accumulo.core.client.IteratorSetting; import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope; -import org.apache.accumulo.core.iterators.SortedKeyValueIterator; import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.core.util.shell.Shell; 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.cli.Option; import org.apache.commons.cli.OptionGroup; @@ -54,18 +52,7 @@ public class SetScanIterCommand extends SetIterCommand { final String tableName = OptUtil.getTableOpt(cl, shellState); - // instead of setting table properties, just put the options in a list to use at scan time - Class loadClass; - try { - loadClass = getClass().getClassLoader().loadClass(classname); - } catch (ClassNotFoundException e) { - throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Unable to load " + classname); - } - try { - loadClass.asSubclass(SortedKeyValueIterator.class); - } catch (ClassCastException ex) { - throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Unable to load " + classname + " as type " + SortedKeyValueIterator.class.getName()); - } + ScanCommand.ensureTserversCanLoadIterator(shellState, tableName, classname); for (Iterator> i = options.entrySet().iterator(); i.hasNext();) { final Entry entry = i.next(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/e4ffc779/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetShellIterCommand.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetShellIterCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetShellIterCommand.java index a06c412..f164548 100644 --- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetShellIterCommand.java +++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetShellIterCommand.java @@ -29,10 +29,8 @@ import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.IteratorSetting; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope; -import org.apache.accumulo.core.iterators.SortedKeyValueIterator; import org.apache.accumulo.core.util.shell.Shell; 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.cli.Option; import org.apache.commons.cli.OptionGroup; @@ -54,11 +52,6 @@ public class SetShellIterCommand extends SetIterCommand { String profile = cl.getOptionValue(profileOpt.getOpt()); - if (!shellState.getConnector().instanceOperations().testClassLoad(classname, SortedKeyValueIterator.class.getName())) { - throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Servers are unable to load " + classname + " as type " - + SortedKeyValueIterator.class.getName()); - } - // instead of setting table properties, just put the options in a list to use at scan time for (Iterator> i = options.entrySet().iterator(); i.hasNext();) { final Entry entry = i.next();