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 D3984109EA for ; Wed, 4 Dec 2013 23:58:46 +0000 (UTC) Received: (qmail 47184 invoked by uid 500); 4 Dec 2013 23:58:44 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 47047 invoked by uid 500); 4 Dec 2013 23:58:44 -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 46856 invoked by uid 99); 4 Dec 2013 23:58:44 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Dec 2013 23:58:44 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id C49E6320370; Wed, 4 Dec 2013 23:58:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ctubbsii@apache.org To: commits@accumulo.apache.org Date: Wed, 04 Dec 2013 23:59:03 -0000 Message-Id: <67956954b07d49f2986adbe536071dee@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [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/master Commit: e1cf746acf8ce72692a2e6d9f4f20acc721814a1 Parents: 7b4f068 Author: Sean Hickey Authored: Tue Aug 13 10:05:37 2013 -0400 Committer: Christopher Tubbs 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 observers; - + public TableNamespaceConfiguration(String namespaceId, AccumuloConfiguration parent) { inst = HdfsZooInstance.getInstance(); this.parent = parent; @@ -87,8 +87,17 @@ public class TableNamespaceConfiguration extends AccumuloConfiguration { public Iterator> iterator() { TreeMap entries = new TreeMap(); - for (Entry parentEntry : parent) - entries.put(parentEntry.getKey(), parentEntry.getValue()); + for (Entry 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 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 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 e : c.tableOperations().getProperties(t)) { if (e.getKey().equals(propKey) && e.getValue().equals(propVal)) {