-
Notifications
You must be signed in to change notification settings - Fork 476
Prevents iterator conflicts #6040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.1
Are you sure you want to change the base?
Changes from all commits
97f2dc0
06c1800
32ccd5a
1e04009
cb2eccb
d518c3c
b0c0644
f422862
6a3f9f8
539e082
2e5da9b
469a83e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ | |
| import org.apache.accumulo.core.client.admin.NamespaceOperations; | ||
| import org.apache.accumulo.core.conf.Property; | ||
| import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope; | ||
| import org.apache.accumulo.core.iteratorsImpl.IteratorConfigUtil; | ||
|
|
||
| public abstract class NamespaceOperationsHelper implements NamespaceOperations { | ||
|
|
||
|
|
@@ -146,45 +147,8 @@ public void checkIteratorConflicts(String namespace, IteratorSetting setting, | |
| if (!exists(namespace)) { | ||
| throw new NamespaceNotFoundException(null, namespace, null); | ||
| } | ||
| for (IteratorScope scope : scopes) { | ||
| String scopeStr = | ||
| String.format("%s%s", Property.TABLE_ITERATOR_PREFIX, scope.name().toLowerCase()); | ||
| String nameStr = String.format("%s.%s", scopeStr, setting.getName()); | ||
| String optStr = String.format("%s.opt.", nameStr); | ||
| Map<String,String> optionConflicts = new TreeMap<>(); | ||
| for (Entry<String,String> property : this.getProperties(namespace)) { | ||
| if (property.getKey().startsWith(scopeStr)) { | ||
| if (property.getKey().equals(nameStr)) { | ||
| throw new AccumuloException(new IllegalArgumentException("iterator name conflict for " | ||
| + setting.getName() + ": " + property.getKey() + "=" + property.getValue())); | ||
| } | ||
| if (property.getKey().startsWith(optStr)) { | ||
| optionConflicts.put(property.getKey(), property.getValue()); | ||
| } | ||
| if (property.getKey().contains(".opt.")) { | ||
| continue; | ||
| } | ||
| String[] parts = property.getValue().split(","); | ||
| if (parts.length != 2) { | ||
| throw new AccumuloException("Bad value for existing iterator setting: " | ||
| + property.getKey() + "=" + property.getValue()); | ||
| } | ||
| try { | ||
| if (Integer.parseInt(parts[0]) == setting.getPriority()) { | ||
| throw new AccumuloException(new IllegalArgumentException( | ||
| "iterator priority conflict: " + property.getKey() + "=" + property.getValue())); | ||
| } | ||
| } catch (NumberFormatException e) { | ||
| throw new AccumuloException("Bad value for existing iterator setting: " | ||
| + property.getKey() + "=" + property.getValue()); | ||
| } | ||
|
Comment on lines
-177
to
-180
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like the new code is not translating this NumberFormatException, is this change in exceptions going to ripple through to the client API? When we parse the props to IteratorSetting we could maintain these exceptions in the new code.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this does change the exceptions the client might receive from this. They will always receive an AccumuloException before and after these changes, but they no longer receive AccumuloExceptions for two things: AccumuloExceptions if I can add back AccumuloExceptions for these two cases if you think that is best.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We should not quietly ignore invalid properties under the iterator prefix, this could be a sign of a typo. If its a typo then the user could expect something to be working and it silently does not. Would be good to fail or warn for that. Made a comment elsewhere about the scope, seems this new code and the old code ignores invalid scopes. Not completely sure about this this though. |
||
| } | ||
| } | ||
| if (!optionConflicts.isEmpty()) { | ||
| throw new AccumuloException(new IllegalArgumentException( | ||
| "iterator options conflict for " + setting.getName() + ": " + optionConflicts)); | ||
| } | ||
| } | ||
| var props = this.getNamespaceProperties(namespace); | ||
| IteratorConfigUtil.checkIteratorConflicts(props, setting, scopes, true); | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ | |
| import org.apache.accumulo.core.client.admin.TableOperations; | ||
| import org.apache.accumulo.core.conf.Property; | ||
| import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope; | ||
| import org.apache.accumulo.core.iteratorsImpl.IteratorConfigUtil; | ||
|
|
||
| public abstract class TableOperationsHelper implements TableOperations { | ||
|
|
||
|
|
@@ -139,45 +140,7 @@ public static void checkIteratorConflicts(Map<String,String> props, IteratorSett | |
| EnumSet<IteratorScope> scopes) throws AccumuloException { | ||
| checkArgument(setting != null, "setting is null"); | ||
| checkArgument(scopes != null, "scopes is null"); | ||
| for (IteratorScope scope : scopes) { | ||
| String scopeStr = | ||
| String.format("%s%s", Property.TABLE_ITERATOR_PREFIX, scope.name().toLowerCase()); | ||
| String nameStr = String.format("%s.%s", scopeStr, setting.getName()); | ||
| String optStr = String.format("%s.opt.", nameStr); | ||
| Map<String,String> optionConflicts = new TreeMap<>(); | ||
| for (Entry<String,String> property : props.entrySet()) { | ||
| if (property.getKey().startsWith(scopeStr)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know if this code was duplicated in NamespaceOperationsHelper?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes this was the exact same in both |
||
| if (property.getKey().equals(nameStr)) { | ||
| throw new AccumuloException(new IllegalArgumentException("iterator name conflict for " | ||
| + setting.getName() + ": " + property.getKey() + "=" + property.getValue())); | ||
| } | ||
| if (property.getKey().startsWith(optStr)) { | ||
| optionConflicts.put(property.getKey(), property.getValue()); | ||
| } | ||
| if (property.getKey().contains(".opt.")) { | ||
| continue; | ||
| } | ||
| String[] parts = property.getValue().split(","); | ||
| if (parts.length != 2) { | ||
| throw new AccumuloException("Bad value for existing iterator setting: " | ||
| + property.getKey() + "=" + property.getValue()); | ||
| } | ||
| try { | ||
| if (Integer.parseInt(parts[0]) == setting.getPriority()) { | ||
| throw new AccumuloException(new IllegalArgumentException( | ||
| "iterator priority conflict: " + property.getKey() + "=" + property.getValue())); | ||
| } | ||
| } catch (NumberFormatException e) { | ||
| throw new AccumuloException("Bad value for existing iterator setting: " | ||
| + property.getKey() + "=" + property.getValue()); | ||
| } | ||
| } | ||
| } | ||
| if (!optionConflicts.isEmpty()) { | ||
| throw new AccumuloException(new IllegalArgumentException( | ||
| "iterator options conflict for " + setting.getName() + ": " + optionConflicts)); | ||
| } | ||
| } | ||
| IteratorConfigUtil.checkIteratorConflicts(props, setting, scopes, true); | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could remove noDefaultsPropMap since I pushed the check for equality into checkIteratorConflicts