ctubbsii closed pull request #409: ACCUMULO-4791 fix setshelliter usage
URL: https://github.com/apache/accumulo/pull/409
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthorizor.java
b/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthorizor.java
index 28036270f8..3e6c6b72ac 100644
---
a/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthorizor.java
+++
b/server/base/src/main/java/org/apache/accumulo/server/security/handler/ZKAuthorizor.java
@@ -19,7 +19,6 @@
import static java.nio.charset.StandardCharsets.UTF_8;
import java.nio.ByteBuffer;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -35,6 +34,7 @@
import org.apache.accumulo.core.security.SystemPermission;
import org.apache.accumulo.core.security.TablePermission;
import org.apache.accumulo.core.security.thrift.TCredentials;
+import org.apache.accumulo.core.util.ByteBufferUtil;
import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
@@ -163,11 +163,19 @@ public void changeAuthorizations(String user,
Authorizations authorizations) thr
@Override
public boolean isValidAuthorizations(String user, List<ByteBuffer> auths)
throws AccumuloSecurityException {
- Collection<ByteBuffer> userauths =
getCachedUserAuthorizations(user).getAuthorizationsBB();
- for (ByteBuffer auth : auths)
- if (!userauths.contains(auth))
+ if (auths.isEmpty()) {
+ // avoid deserializing auths from ZK cache
+ return true;
+ }
+
+ Authorizations userauths = getCachedUserAuthorizations(user);
+
+ for (ByteBuffer auth : auths) {
+ if (!userauths.contains(ByteBufferUtil.toBytes(auth))) {
return false;
+ }
+ }
+
return true;
}
-
}
diff --git
a/shell/src/main/java/org/apache/accumulo/shell/commands/SetIterCommand.java
b/shell/src/main/java/org/apache/accumulo/shell/commands/SetIterCommand.java
index fffdf21f8f..c692215db2 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/SetIterCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/SetIterCommand.java
@@ -47,13 +47,18 @@
import org.apache.commons.cli.OptionGroup;
import org.apache.commons.cli.Options;
import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import jline.console.ConsoleReader;
public class SetIterCommand extends Command {
- private Option allScopeOpt, mincScopeOpt, majcScopeOpt, scanScopeOpt,
nameOpt, priorityOpt;
- private Option aggTypeOpt, ageoffTypeOpt, regexTypeOpt, versionTypeOpt,
reqvisTypeOpt, classnameTypeOpt;
+ private static final Logger log =
LoggerFactory.getLogger(SetIterCommand.class);
+
+ private Option allScopeOpt, mincScopeOpt, majcScopeOpt, scanScopeOpt;
+ Option profileOpt, priorityOpt, nameOpt;
+ Option aggTypeOpt, ageoffTypeOpt, regexTypeOpt, versionTypeOpt,
reqvisTypeOpt, classnameTypeOpt;
@Override
public int execute(final String fullCommand, final CommandLine cl, final
Shell shellState) throws AccumuloException, AccumuloSecurityException,
@@ -81,10 +86,32 @@ public int execute(final String fullCommand, final
CommandLine cl, final Shell s
classname = ReqVisFilter.class.getName();
}
- ClassLoader classloader = shellState.getClassLoader(cl, shellState);
-
- // Get the iterator options, with potentially a name provided by the
OptionDescriber impl or through user input
- String configuredName = setUpOptions(classloader, shellState.getReader(),
classname, options);
+ // ACCUMULO-4791: The SetIterCommand class as well as methods within the
Shell.java class all
+ // require that a table or namespace be provided or otherwise they will
not execute. But the
+ // setShellIter command does not require either of these values. In order
to get around
+ // this requirement we will check to see if a profile name has been
provided (indicating that
+ // we are setting a shell iterator). If so, temporarily set the table
state to an
+ // existing table such as accumulo.metadata. This allows the command to
complete successfully.
+ // After completion reassign the table to its original value and continue.
+ String currentTableName = null;
+ String tmpTable = null;
+ String configuredName;
+ try {
+ if (profileOpt != null &&
StringUtils.isBlank(shellState.getTableName())) {
+ currentTableName = shellState.getTableName();
+ tmpTable = "accumulo.metadata";
+ shellState.setTableName(tmpTable);
+ tables = cl.hasOption(OptUtil.tableOpt().getOpt()) ||
!shellState.getTableName().isEmpty();
+ }
+ ClassLoader classloader = shellState.getClassLoader(cl, shellState);
+ // Get the iterator options, with potentially a name provided by the
OptionDescriber impl or through user input
+ configuredName = setUpOptions(classloader, shellState.getReader(),
classname, options);
+ } finally {
+ // ACCUMULO-4792: reset table name and continue
+ if (tmpTable != null) {
+ shellState.setTableName(currentTableName);
+ }
+ }
// Try to get the name provided by the setiter command
String name = cl.getOptionValue(nameOpt.getOpt(), null);
@@ -215,10 +242,8 @@ private static String setUpOptions(ClassLoader
classloader, final ConsoleReader
} catch (IllegalAccessException e) {
throw new IllegalArgumentException(e.getMessage());
} catch (ClassCastException e) {
- StringBuilder msg = new StringBuilder(50);
- msg.append(className).append(" loaded successfully but does not
implement SortedKeyValueIterator.");
- msg.append(" This class cannot be used with this command.");
- throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE,
msg.toString());
+ String msg = className + " loaded successfully but does not implement
SortedKeyValueIterator." + " This class cannot be used with this command.";
+ throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, msg);
}
@SuppressWarnings("unchecked")
@@ -338,22 +363,54 @@ public String description() {
return "sets a table-specific or namespace-specific iterator";
}
- @Override
- public Options getOptions() {
- final Options o = new Options();
+ // Set all options common to both iterators and shell iterators
+ protected void setBaseOptions(Options options) {
+ setPriorityOptions(options);
+ setNameOptions(options);
+ setIteratorTypeOptions(options);
+ }
+ private void setNameOptions(Options options) {
+ nameOpt = new Option("n", "name", true, "iterator to set");
+ nameOpt.setArgName("itername");
+ options.addOption(nameOpt);
+ }
+
+ private void setPriorityOptions(Options options) {
priorityOpt = new Option("p", "priority", true, "the order in which the
iterator is applied");
priorityOpt.setArgName("pri");
priorityOpt.setRequired(true);
+ options.addOption(priorityOpt);
+ }
- nameOpt = new Option("n", "name", true, "iterator to set");
- nameOpt.setArgName("itername");
+ @Override
+ public Options getOptions() {
+ final Options o = new Options();
+ setBaseOptions(o);
+ setScopeOptions(o);
+ setTableOptions(o);
+ return o;
+ }
+ private void setScopeOptions(Options o) {
allScopeOpt = new Option("all", "all-scopes", false, "applied at scan
time, minor and major compactions");
mincScopeOpt = new Option(IteratorScope.minc.name(), "minor-compaction",
false, "applied at minor compaction");
majcScopeOpt = new Option(IteratorScope.majc.name(), "major-compaction",
false, "applied at major compaction");
scanScopeOpt = new Option(IteratorScope.scan.name(), "scan-time", false,
"applied at scan time");
+ o.addOption(allScopeOpt);
+ o.addOption(mincScopeOpt);
+ o.addOption(majcScopeOpt);
+ o.addOption(scanScopeOpt);
+ }
+
+ private void setTableOptions(Options o) {
+ final OptionGroup tableGroup = new OptionGroup();
+ tableGroup.addOption(OptUtil.tableOpt("table to configure iterators on"));
+ tableGroup.addOption(OptUtil.namespaceOpt("namespace to configure
iterators on"));
+ o.addOptionGroup(tableGroup);
+ }
+ private void setIteratorTypeOptions(Options o) {
final OptionGroup typeGroup = new OptionGroup();
classnameTypeOpt = new Option("class", "class-name", true, "a java class
that implements SortedKeyValueIterator");
classnameTypeOpt.setArgName("name");
@@ -370,20 +427,7 @@ public Options getOptions() {
typeGroup.addOption(reqvisTypeOpt);
typeGroup.addOption(ageoffTypeOpt);
typeGroup.setRequired(true);
-
- final OptionGroup tableGroup = new OptionGroup();
- tableGroup.addOption(OptUtil.tableOpt("table to configure iterators on"));
- tableGroup.addOption(OptUtil.namespaceOpt("namespace to configure
iterators on"));
-
- o.addOption(priorityOpt);
- o.addOption(nameOpt);
- o.addOption(allScopeOpt);
- o.addOption(mincScopeOpt);
- o.addOption(majcScopeOpt);
- o.addOption(scanScopeOpt);
o.addOptionGroup(typeGroup);
- o.addOptionGroup(tableGroup);
- return o;
}
@Override
diff --git
a/shell/src/main/java/org/apache/accumulo/shell/commands/SetShellIterCommand.java
b/shell/src/main/java/org/apache/accumulo/shell/commands/SetShellIterCommand.java
index e1fa5e01bd..c2b30f877c 100644
---
a/shell/src/main/java/org/apache/accumulo/shell/commands/SetShellIterCommand.java
+++
b/shell/src/main/java/org/apache/accumulo/shell/commands/SetShellIterCommand.java
@@ -18,7 +18,6 @@
import java.io.IOException;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -28,16 +27,17 @@
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.shell.Shell;
import org.apache.accumulo.shell.ShellCommandException;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionGroup;
import org.apache.commons.cli.Options;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class SetShellIterCommand extends SetIterCommand {
- private Option profileOpt;
+
+ private static final Logger log =
LoggerFactory.getLogger(SetShellIterCommand.class);
@Override
public int execute(final String fullCommand, final CommandLine cl, final
Shell shellState) throws AccumuloException, AccumuloSecurityException,
@@ -74,7 +74,6 @@ protected void setTableProperties(final CommandLine cl, final
Shell shellState,
iter.remove();
}
}
-
tableScanIterators.add(setting);
}
@@ -85,32 +84,17 @@ public String description() {
@Override
public Options getOptions() {
- // Remove the options that specify which type of iterator this is, since
- // they are all scan iterators with this command.
- final HashSet<OptionGroup> groups = new HashSet<>();
- final Options parentOptions = super.getOptions();
- final Options modifiedOptions = new Options();
- for (Iterator<?> it = parentOptions.getOptions().iterator();
it.hasNext();) {
- Option o = (Option) it.next();
- if (!IteratorScope.majc.name().equals(o.getOpt()) &&
!IteratorScope.minc.name().equals(o.getOpt()) &&
!IteratorScope.scan.name().equals(o.getOpt())
- && !"table".equals(o.getLongOpt())) {
- modifiedOptions.addOption(o);
- OptionGroup group = parentOptions.getOptionGroup(o);
- if (group != null)
- groups.add(group);
- }
- }
- for (OptionGroup group : groups) {
- modifiedOptions.addOptionGroup(group);
- }
+ final Options o = new Options();
+ setBaseOptions(o);
+ setProfileOptions(o);
+ return o;
+ }
+ private void setProfileOptions(Options o) {
profileOpt = new Option("pn", "profile", true, "iterator profile name");
profileOpt.setRequired(true);
profileOpt.setArgName("profile");
-
- modifiedOptions.addOption(profileOpt);
-
- return modifiedOptions;
+ o.addOption(profileOpt);
}
}
diff --git a/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java
b/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java
index 6b515b276f..0412dc27b4 100644
--- a/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java
@@ -405,7 +405,7 @@ public void setscaniterDeletescaniter() throws Exception {
ts.exec("insert a cf cq 1");
ts.exec("insert a cf cq 1");
ts.input.set("true\n\n\n\nSTRING");
- ts.exec("setscaniter -class
org.apache.accumulo.core.iterators.user.SummingCombiner -p 10 -n name", true);
+ ts.exec("setscaniter -class " + SUMMING_COMBINER_ITERATOR + " -p 10 -n
name", true);
ts.exec("scan", true, "3", true);
ts.exec("deletescaniter -n name", true);
ts.exec("scan", true, "1", true);
@@ -533,11 +533,11 @@ public void iter() throws Exception {
ts.exec("insert a cf cq 1");
ts.exec("insert a cf cq 1");
ts.input.set("true\n\n\n\nSTRING\n");
- ts.exec("setshelliter -class
org.apache.accumulo.core.iterators.user.SummingCombiner -p 10 -pn sum -n name",
true);
- ts.exec("setshelliter -class
org.apache.accumulo.core.iterators.user.SummingCombiner -p 11 -pn sum -n name",
false);
- ts.exec("setshelliter -class
org.apache.accumulo.core.iterators.user.SummingCombiner -p 10 -pn sum -n
other", false);
+ ts.exec("setshelliter -class " + SUMMING_COMBINER_ITERATOR + " -p 10 -pn
sum -n name", true);
+ ts.exec("setshelliter -class " + SUMMING_COMBINER_ITERATOR + " -p 11 -pn
sum -n name", false);
+ ts.exec("setshelliter -class " + SUMMING_COMBINER_ITERATOR + " -p 10 -pn
sum -n other", false);
ts.input.set("true\n\n\n\nSTRING\n");
- ts.exec("setshelliter -class
org.apache.accumulo.core.iterators.user.SummingCombiner -p 11 -pn sum -n
xyzzy", true);
+ ts.exec("setshelliter -class " + SUMMING_COMBINER_ITERATOR + " -p 11 -pn
sum -n xyzzy", true);
ts.exec("scan -pn sum", true, "3", true);
ts.exec("listshelliter", true, "Iterator name", true);
ts.exec("listshelliter", true, "Iterator xyzzy", true);
@@ -555,11 +555,11 @@ public void iter() throws Exception {
ts.exec("insert a cf cq 1");
ts.exec("insert a cf cq 1");
ts.input.set("true\n\n\n\nSTRING\n");
- ts.exec("setiter -scan -class
org.apache.accumulo.core.iterators.user.SummingCombiner -p 10 -n name", true);
- ts.exec("setiter -scan -class
org.apache.accumulo.core.iterators.user.SummingCombiner -p 11 -n name", false);
- ts.exec("setiter -scan -class
org.apache.accumulo.core.iterators.user.SummingCombiner -p 10 -n other", false);
+ ts.exec("setiter -scan -class " + SUMMING_COMBINER_ITERATOR + " -p 10 -n
name", true);
+ ts.exec("setiter -scan -class " + SUMMING_COMBINER_ITERATOR + " -p 11 -n
name", false);
+ ts.exec("setiter -scan -class " + SUMMING_COMBINER_ITERATOR + " -p 10 -n
other", false);
ts.input.set("true\n\n\n\nSTRING\n");
- ts.exec("setiter -scan -class
org.apache.accumulo.core.iterators.user.SummingCombiner -p 11 -n xyzzy", true);
+ ts.exec("setiter -scan -class " + SUMMING_COMBINER_ITERATOR + " -p 11 -n
xyzzy", true);
ts.exec("scan", true, "3", true);
ts.exec("listiter -scan", true, "Iterator name", true);
ts.exec("listiter -scan", true, "Iterator xyzzy", true);
@@ -580,13 +580,13 @@ public void setIterOptionPrompt() throws Exception {
ts.exec("createtable " + tableName);
ts.input.set("\n\n");
// Setting a non-optiondescriber with no name should fail
- ts.exec("setiter -scan -class
org.apache.accumulo.core.iterators.ColumnFamilyCounter -p 30", false);
+ ts.exec("setiter -scan -class " + COLUMN_FAMILY_COUNTER_ITERATOR + " -p
30", false);
// Name as option will work
- ts.exec("setiter -scan -class
org.apache.accumulo.core.iterators.ColumnFamilyCounter -p 30 -name cfcounter",
true);
+ ts.exec("setiter -scan -class " + COLUMN_FAMILY_COUNTER_ITERATOR + " -p 30
-name cfcounter", true);
String expectedKey = "table.iterator.scan.cfcounter";
- String expectedValue =
"30,org.apache.accumulo.core.iterators.ColumnFamilyCounter";
+ String expectedValue = "30," + COLUMN_FAMILY_COUNTER_ITERATOR;
TableOperations tops = conn.tableOperations();
checkTableForProperty(tops, tableName, expectedKey, expectedValue);
@@ -598,9 +598,9 @@ public void setIterOptionPrompt() throws Exception {
ts.input.set("customcfcounter\n\n");
// Name on the CLI should override OptionDescriber (or user input name, in
this case)
- ts.exec("setiter -scan -class
org.apache.accumulo.core.iterators.ColumnFamilyCounter -p 30", true);
+ ts.exec("setiter -scan -class " + COLUMN_FAMILY_COUNTER_ITERATOR + " -p
30", true);
expectedKey = "table.iterator.scan.customcfcounter";
- expectedValue =
"30,org.apache.accumulo.core.iterators.ColumnFamilyCounter";
+ expectedValue = "30," + COLUMN_FAMILY_COUNTER_ITERATOR;
checkTableForProperty(tops, tableName, expectedKey, expectedValue);
ts.exec("deletetable " + tableName, true);
@@ -611,9 +611,9 @@ public void setIterOptionPrompt() throws Exception {
ts.input.set("customcfcounter\nname1 value1\nname2 value2\n\n");
// Name on the CLI should override OptionDescriber (or user input name, in
this case)
- ts.exec("setiter -scan -class
org.apache.accumulo.core.iterators.ColumnFamilyCounter -p 30", true);
+ ts.exec("setiter -scan -class " + COLUMN_FAMILY_COUNTER_ITERATOR + " -p
30", true);
expectedKey = "table.iterator.scan.customcfcounter";
- expectedValue =
"30,org.apache.accumulo.core.iterators.ColumnFamilyCounter";
+ expectedValue = "30," + COLUMN_FAMILY_COUNTER_ITERATOR;
checkTableForProperty(tops, tableName, expectedKey, expectedValue);
expectedKey = "table.iterator.scan.customcfcounter.opt.name1";
expectedValue = "value1";
@@ -630,9 +630,9 @@ public void setIterOptionPrompt() throws Exception {
ts.input.set("\nname1 value1.1,value1.2,value1.3\nname2 value2\n\n");
// Name on the CLI should override OptionDescriber (or user input name, in
this case)
- ts.exec("setiter -scan -class
org.apache.accumulo.core.iterators.ColumnFamilyCounter -p 30 -name cfcounter",
true);
+ ts.exec("setiter -scan -class " + COLUMN_FAMILY_COUNTER_ITERATOR + " -p 30
-name cfcounter", true);
expectedKey = "table.iterator.scan.cfcounter";
- expectedValue =
"30,org.apache.accumulo.core.iterators.ColumnFamilyCounter";
+ expectedValue = "30," + COLUMN_FAMILY_COUNTER_ITERATOR;
checkTableForProperty(tops, tableName, expectedKey, expectedValue);
expectedKey = "table.iterator.scan.cfcounter.opt.name1";
expectedValue = "value1.1,value1.2,value1.3";
@@ -1665,7 +1665,7 @@ public void namespaces() throws Exception {
ts.exec("namespaces", true, "testers3", true);
ts.exec("deletenamespace testers3 -f", true);
ts.input.set("true\n\n\n\nSTRING\n");
- ts.exec("setiter -ns thing2 -scan -class
org.apache.accumulo.core.iterators.user.SummingCombiner -p 10 -n name", true);
+ ts.exec("setiter -ns thing2 -scan -class " + SUMMING_COMBINER_ITERATOR + "
-p 10 -n name", true);
ts.exec("listiter -ns thing2 -scan", true, "Summing", true);
ts.exec("deleteiter -ns thing2 -n name -scan", true);
ts.exec("createuser dude");
@@ -1729,7 +1729,7 @@ public void scans() throws Exception {
@Test
public void scansWithClassLoaderContext() throws Exception {
try {
-
Class.forName("org.apache.accumulo.test.functional.ValueReversingIterator");
+ Class.forName(VALUE_REVERSING_ITERATOR);
fail("ValueReversingIterator already on the classpath");
} catch (Exception e) {
// Do nothing here, This is success. The following line is here
@@ -1737,66 +1737,122 @@ public void scansWithClassLoaderContext() throws
Exception {
assertTrue(true);
}
ts.exec("createtable t");
+ // Assert that the TabletServer does not know anything about our class
+ String result = ts.exec("setiter -scan -n reverse -t t -p 21 -class " +
VALUE_REVERSING_ITERATOR);
+ assertTrue(result.contains("class not found"));
make10();
setupFakeContextPath();
- // Add the context to the table so that setscaniter works. After
setscaniter succeeds, then
- // remove the property from the table.
- ts.exec("config -s " + Property.VFS_CONTEXT_CLASSPATH_PROPERTY +
FAKE_CONTEXT + "=" + FAKE_CONTEXT_CLASSPATH);
- ts.exec("config -t t -s table.classpath.context=" + FAKE_CONTEXT);
- ts.exec("setscaniter -n reverse -t t -p 21 -class
org.apache.accumulo.test.functional.ValueReversingIterator");
- String result = ts.exec("scan -np -b row1 -e row1");
+ // Add the context to the table so that setiter works.
+ result = ts.exec("config -s " + Property.VFS_CONTEXT_CLASSPATH_PROPERTY +
FAKE_CONTEXT + "=" + FAKE_CONTEXT_CLASSPATH);
+ assertEquals("root@miniInstance t> config -s " +
Property.VFS_CONTEXT_CLASSPATH_PROPERTY + FAKE_CONTEXT + "=" +
FAKE_CONTEXT_CLASSPATH + "\n", result);
+
+ result = ts.exec("config -t t -s table.classpath.context=" + FAKE_CONTEXT);
+ assertEquals("root@miniInstance t> config -t t -s
table.classpath.context=" + FAKE_CONTEXT + "\n", result);
+
+ result = ts.exec("setshelliter -pn baz -n reverse -p 21 -class " +
VALUE_REVERSING_ITERATOR);
+ assertTrue(result.contains("The iterator class does not implement
OptionDescriber"));
+
+ // The implementation of ValueReversingIterator in the FAKE context does
nothing, the value is not reversed.
+ result = ts.exec("scan -pn baz -np -b row1 -e row1");
assertEquals(2, result.split("\n").length);
- log.error(result);
assertTrue(result.contains("value"));
- result = ts.exec("scan -np -b row3 -e row5");
+ result = ts.exec("scan -pn baz -np -b row3 -e row5");
assertEquals(4, result.split("\n").length);
assertTrue(result.contains("value"));
- result = ts.exec("scan -np -r row3");
+ result = ts.exec("scan -pn baz -np -r row3");
assertEquals(2, result.split("\n").length);
assertTrue(result.contains("value"));
- result = ts.exec("scan -np -b row:");
+ result = ts.exec("scan -pn baz -np -b row:");
assertEquals(1, result.split("\n").length);
- result = ts.exec("scan -np -b row");
+ result = ts.exec("scan -pn baz -np -b row");
assertEquals(11, result.split("\n").length);
assertTrue(result.contains("value"));
- result = ts.exec("scan -np -e row:");
+ result = ts.exec("scan -pn baz -np -e row:");
assertEquals(11, result.split("\n").length);
assertTrue(result.contains("value"));
setupRealContextPath();
- ts.exec("config -s " + Property.VFS_CONTEXT_CLASSPATH_PROPERTY +
REAL_CONTEXT + "=" + REAL_CONTEXT_CLASSPATH);
- result = ts.exec("scan -np -b row1 -e row1 -cc " + REAL_CONTEXT);
- log.error(result);
+ // Define a new classloader context, but don't set it on the table
+ result = ts.exec("config -s " + Property.VFS_CONTEXT_CLASSPATH_PROPERTY +
REAL_CONTEXT + "=" + REAL_CONTEXT_CLASSPATH);
+ assertEquals("root@miniInstance t> config -s " +
Property.VFS_CONTEXT_CLASSPATH_PROPERTY + REAL_CONTEXT + "=" +
REAL_CONTEXT_CLASSPATH + "\n", result);
+ // Override the table classloader context with the REAL implementation of
ValueReversingIterator, which does reverse the value.
+ result = ts.exec("scan -pn baz -np -b row1 -e row1 -cc " + REAL_CONTEXT);
assertEquals(2, result.split("\n").length);
assertTrue(result.contains("eulav"));
assertFalse(result.contains("value"));
- result = ts.exec("scan -np -b row3 -e row5 -cc " + REAL_CONTEXT);
+ result = ts.exec("scan -pn baz -np -b row3 -e row5 -cc " + REAL_CONTEXT);
assertEquals(4, result.split("\n").length);
assertTrue(result.contains("eulav"));
assertFalse(result.contains("value"));
- result = ts.exec("scan -np -r row3 -cc " + REAL_CONTEXT);
+ result = ts.exec("scan -pn baz -np -r row3 -cc " + REAL_CONTEXT);
assertEquals(2, result.split("\n").length);
assertTrue(result.contains("eulav"));
assertFalse(result.contains("value"));
- result = ts.exec("scan -np -b row: -cc " + REAL_CONTEXT);
+ result = ts.exec("scan -pn baz -np -b row: -cc " + REAL_CONTEXT);
assertEquals(1, result.split("\n").length);
- result = ts.exec("scan -np -b row -cc " + REAL_CONTEXT);
+ result = ts.exec("scan -pn baz -np -b row -cc " + REAL_CONTEXT);
assertEquals(11, result.split("\n").length);
assertTrue(result.contains("eulav"));
assertFalse(result.contains("value"));
- result = ts.exec("scan -np -e row: -cc " + REAL_CONTEXT);
+ result = ts.exec("scan -pn baz -np -e row: -cc " + REAL_CONTEXT);
assertEquals(11, result.split("\n").length);
assertTrue(result.contains("eulav"));
assertFalse(result.contains("value"));
ts.exec("deletetable -f t");
}
+ /**
+ * The purpose of this test is to verify that you can successfully scan a
table with a regular iterator. It was written to verify that the changes made
while
+ * updating the setshelliter command did not break the existing setiter
capabilities. It tests that a table can be scanned with an iterator both while
within
+ * a table context and also while in the 'notable' context.
+ */
+ @Test
+ public void testScanTableWithIterSetWithoutProfile() throws Exception {
+ final String table = name.getMethodName();
+
+ // create a table
+ ts.exec("createtable " + table, true);
+
+ // add some data
+ ts.exec("insert foo a b c", true);
+ ts.exec("scan", true, "foo a:b [] c");
+
+ // create a normal iterator while in current table context
+ ts.input.set("\n1000\n\n");
+ ts.exec("setiter -scan -n itname -p 10 -ageoff", true);
+
+ ts.exec("sleep 2", true);
+ // scan the created table.
+ ts.exec("scan", true, "", true);
+ ts.exec("deletetable -f " + table);
+
+ // Repeat process but do it within the 'notable' context (after table
creation and insertion)
+ // create a table
+ ts.exec("createtable " + table, true);
+
+ // add some data
+ ts.exec("insert foo a b c", true);
+ ts.exec("notable");
+ ts.exec("scan -t " + table, true, "foo a:b [] c");
+
+ // create a normal iterator which in current table context
+ ts.input.set("\n1000\n\n");
+ ts.exec("setiter -scan -n itname -p 10 -ageoff -t " + table, true);
+ ts.exec("sleep 2", true);
+ // re-scan the table. Should not see data.
+ ts.exec("scan -t " + table, true, "", true);
+ ts.exec("deletetable -f " + table);
+ }
+
private static final String FAKE_CONTEXT = "FAKE";
private static final String FAKE_CONTEXT_CLASSPATH = "file://" +
System.getProperty("user.dir") + "/target/" +
ShellServerIT.class.getSimpleName()
+ "-fake-iterators.jar";
private static final String REAL_CONTEXT = "REAL";
private static final String REAL_CONTEXT_CLASSPATH = "file://" +
System.getProperty("user.dir") + "/target/" +
ShellServerIT.class.getSimpleName()
+ "-real-iterators.jar";
+ private static final String VALUE_REVERSING_ITERATOR =
"org.apache.accumulo.test.functional.ValueReversingIterator";
+ private static final String SUMMING_COMBINER_ITERATOR =
"org.apache.accumulo.core.iterators.user.SummingCombiner";
+ private static final String COLUMN_FAMILY_COUNTER_ITERATOR =
"org.apache.accumulo.core.iterators" + ".ColumnFamilyCounter";
private void setupRealContextPath() throws Exception {
// Copy the test iterators jar to tmp
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services