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 2013/12/05 00:58:14 UTC
[22/50] [abbrv] git commit: ACCUMULO-324 made the system namespace
ignore system-level (and site and default-level) iterators and constraints
ACCUMULO-324 made the system namespace ignore system-level (and site and default-level) iterators and constraints
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/e1cf746a
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/e1cf746a
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/e1cf746a
Branch: refs/heads/1.6.0-SNAPSHOT
Commit: e1cf746acf8ce72692a2e6d9f4f20acc721814a1
Parents: 7b4f068
Author: Sean Hickey <ta...@gmail.com>
Authored: Tue Aug 13 10:05:37 2013 -0400
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Wed Dec 4 18:46:10 2013 -0500
----------------------------------------------------------------------
.../conf/TableNamespaceConfiguration.java | 22 ++++++++++++++++---
.../apache/accumulo/test/TableNamespacesIT.java | 23 ++++++++++++++++++++
2 files changed, 42 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/e1cf746a/server/base/src/main/java/org/apache/accumulo/server/conf/TableNamespaceConfiguration.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/TableNamespaceConfiguration.java b/server/base/src/main/java/org/apache/accumulo/server/conf/TableNamespaceConfiguration.java
index 6c75e25..2ebe338 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/TableNamespaceConfiguration.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/TableNamespaceConfiguration.java
@@ -43,7 +43,7 @@ public class TableNamespaceConfiguration extends AccumuloConfiguration {
protected String namespaceId = null;
protected Instance inst = null;
private Set<ConfigurationObserver> observers;
-
+
public TableNamespaceConfiguration(String namespaceId, AccumuloConfiguration parent) {
inst = HdfsZooInstance.getInstance();
this.parent = parent;
@@ -87,8 +87,17 @@ public class TableNamespaceConfiguration extends AccumuloConfiguration {
public Iterator<Entry<String,String>> iterator() {
TreeMap<String,String> entries = new TreeMap<String,String>();
- for (Entry<String,String> parentEntry : parent)
- entries.put(parentEntry.getKey(), parentEntry.getValue());
+ for (Entry<String,String> parentEntry : parent) {
+ if (this.namespaceId.equals(Constants.SYSTEM_TABLE_NAMESPACE_ID)) {
+ // exclude system iterators/constraints from the system namespace
+ // so they don't affect the metadata or root tables.
+ if (!isIterConst(parentEntry)) {
+ entries.put(parentEntry.getKey(), parentEntry.getValue());
+ }
+ } else {
+ entries.put(parentEntry.getKey(), parentEntry.getValue());
+ }
+ }
List<String> children = getPropCache().getChildren(
ZooUtil.getRoot(inst.getInstanceID()) + Constants.ZNAMESPACES + "/" + getNamespaceId() + Constants.ZNAMESPACE_CONF);
@@ -143,4 +152,11 @@ public class TableNamespaceConfiguration extends AccumuloConfiguration {
for (ConfigurationObserver co : copy)
co.propertiesChanged();
}
+
+ protected boolean isIterConst(Entry<String,String> e) {
+ if (e.getKey().startsWith(Property.TABLE_ITERATOR_PREFIX.getKey()) || e.getKey().startsWith(Property.TABLE_CONSTRAINT_PREFIX.getKey())) {
+ return true;
+ }
+ return false;
+ }
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/e1cf746a/test/src/test/java/org/apache/accumulo/test/TableNamespacesIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/TableNamespacesIT.java b/test/src/test/java/org/apache/accumulo/test/TableNamespacesIT.java
index 38955e3..5705044 100644
--- a/test/src/test/java/org/apache/accumulo/test/TableNamespacesIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/TableNamespacesIT.java
@@ -432,6 +432,7 @@ public class TableNamespacesIT {
}
assertTrue(!hasProp);
}
+
/**
* Tests new Namespace permissions as well as modifications to Table permissions because of namespaces. Checks each permission to first make sure the user
* doesn't have permission to perform the action, then root grants them the permission and we check to make sure they could perform the action.
@@ -578,6 +579,28 @@ public class TableNamespacesIT {
c.securityOperations().revokeSystemPermission(user1, SystemPermission.ALTER_NAMESPACE);
}
+ /**
+ * This test makes sure that system-level iterators and constraints are ignored by the system namespace so that the metadata and root tables aren't affected
+ */
+ @Test
+ public void excludeSystemIterConst() throws Exception {
+ Connector c = accumulo.getConnector("root", secret);
+
+ c.instanceOperations().setProperty("table.iterator.scan.sum", "20," + SimpleFilter.class.getName());
+ assertTrue(c.instanceOperations().getSystemConfiguration().containsValue("20," + SimpleFilter.class.getName()));
+
+ assertTrue(checkTableNamespaceHasProp(c, Constants.DEFAULT_TABLE_NAMESPACE, "table.iterator.scan.sum", "20," + SimpleFilter.class.getName()));
+ assertTrue(!checkTableNamespaceHasProp(c, Constants.SYSTEM_TABLE_NAMESPACE, "table.iterator.scan.sum", "20," + SimpleFilter.class.getName()));
+ c.instanceOperations().removeProperty("table.iterator.scan.sum");
+
+ c.instanceOperations().setProperty("table.constraint.42", NumericValueConstraint.class.getName());
+ assertTrue(c.instanceOperations().getSystemConfiguration().containsValue(NumericValueConstraint.class.getName()));
+
+ assertTrue(checkTableNamespaceHasProp(c, Constants.DEFAULT_TABLE_NAMESPACE, "table.constraint.42", NumericValueConstraint.class.getName()));
+ assertTrue(!checkTableNamespaceHasProp(c, Constants.SYSTEM_TABLE_NAMESPACE, "table.constraint.42", NumericValueConstraint.class.getName()));
+ c.instanceOperations().removeProperty("table.constraint.42");
+ }
+
private boolean checkTableHasProp(Connector c, String t, String propKey, String propVal) throws AccumuloException, TableNotFoundException {
for (Entry<String,String> e : c.tableOperations().getProperties(t)) {
if (e.getKey().equals(propKey) && e.getValue().equals(propVal)) {