accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [49/54] git commit: ACCUMULO-324 made the system namespace ignore system-level (and site and default-level) iterators and constraints
Date Fri, 01 Nov 2013 02:00:50 GMT
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/a11a8ae9
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/a11a8ae9
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/a11a8ae9

Branch: refs/heads/ACCUMULO-802
Commit: a11a8ae934359ed859833f3df2ebee6deb2886e6
Parents: 1bbf9ad
Author: Sean Hickey <tallirishllama@gmail.com>
Authored: Tue Aug 13 10:05:37 2013 -0400
Committer: Christopher Tubbs <ctubbsii@apache.org>
Committed: Thu Oct 31 21:38:26 2013 -0400

----------------------------------------------------------------------
 .../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/a11a8ae9/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/a11a8ae9/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)) {


Mime
View raw message