accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [48/50] [abbrv] git commit: ACCUMULO-1859 update namepace config w/ new getPropertiesMethod
Date Wed, 04 Dec 2013 23:58:40 GMT
ACCUMULO-1859 update namepace config w/ new getPropertiesMethod


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/5b791b16
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/5b791b16
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/5b791b16

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 5b791b166b9190285bfb3ba3d45c3de0dbb93af1
Parents: 725d821
Author: Keith Turner <kturner@apache.org>
Authored: Thu Nov 14 14:20:33 2013 -0500
Committer: Christopher Tubbs <ctubbsii@apache.org>
Committed: Wed Dec 4 18:46:11 2013 -0500

----------------------------------------------------------------------
 .../conf/TableNamespaceConfiguration.java       | 76 +++++++++++---------
 1 file changed, 43 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/5b791b16/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 b4e9598..74621a3 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
@@ -19,11 +19,9 @@ package org.apache.accumulo.server.conf;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map.Entry;
+import java.util.Map;
 import java.util.Set;
-import java.util.TreeMap;
 
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Instance;
@@ -54,19 +52,20 @@ public class TableNamespaceConfiguration extends AccumuloConfiguration
{
   @Override
   public String get(Property property) {
     String key = property.getKey();
-    String value = get(key);
+    String value = get(getPropCache(), key);
 
     if (value == null || !property.getType().isValidFormat(value)) {
       if (value != null)
         log.error("Using default value for " + key + " due to improperly formatted " + property.getType()
+ ": " + value);
-      value = parent.get(property);
+      if (!isIterConst(property.getKey()))
+        value = parent.get(property);
     }
     return value;
   }
 
-  private String get(String key) {
+  private String get(ZooCache zc, String key) {
     String zPath = ZooUtil.getRoot(inst.getInstanceID()) + Constants.ZNAMESPACES + "/" +
getNamespaceId() + Constants.ZNAMESPACE_CONF + "/" + key;
-    byte[] v = getPropCache().get(zPath);
+    byte[] v = zc.get(zPath);
     String value = null;
     if (v != null)
       value = new String(v, Constants.UTF8);
@@ -83,33 +82,47 @@ public class TableNamespaceConfiguration extends AccumuloConfiguration
{
     return propCache;
   }
 
-  @Override
-  public Iterator<Entry<String,String>> iterator() {
-    TreeMap<String,String> entries = new TreeMap<String,String>();
-
-    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());
-      }
+  private class SystemNamespaceFilter implements PropertyFilter {
+
+    private PropertyFilter userFilter;
+
+    SystemNamespaceFilter(PropertyFilter userFilter) {
+      this.userFilter = userFilter;
     }
 
-    List<String> children = getPropCache().getChildren(
-        ZooUtil.getRoot(inst.getInstanceID()) + Constants.ZNAMESPACES + "/" + getNamespaceId()
+ Constants.ZNAMESPACE_CONF);
+    @Override
+    public boolean accept(String key) {
+      if (isIterConst(key))
+        return false;
+      return userFilter.accept(key);
+    }
+
+  }
+
+  @Override
+  public void getProperties(Map<String,String> props, PropertyFilter filter) {
+
+    PropertyFilter parentFilter = filter;
+
+    // exclude system iterators/constraints from the system namespace
+    // so they don't affect the metadata or root tables.
+    if (this.namespaceId.equals(Constants.SYSTEM_TABLE_NAMESPACE_ID))
+      parentFilter = new SystemNamespaceFilter(filter);
+
+    parent.getProperties(props, parentFilter);
+
+    ZooCache zc = getPropCache();
+
+    List<String> children = zc.getChildren(ZooUtil.getRoot(inst.getInstanceID()) +
Constants.ZNAMESPACES + "/" + getNamespaceId() + Constants.ZNAMESPACE_CONF);
     if (children != null) {
       for (String child : children) {
-        String value = get(child);
-        if (child != null && value != null)
-          entries.put(child, value);
+        if (child != null && filter.accept(child)) {
+          String value = get(zc, child);
+          if (value != null)
+            props.put(child, value);
+        }
       }
     }
-
-    return entries.entrySet().iterator();
   }
 
   protected String getNamespaceId() {
@@ -153,10 +166,7 @@ public class TableNamespaceConfiguration extends AccumuloConfiguration
{
       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;
+  protected boolean isIterConst(String key) {
+    return key.startsWith(Property.TABLE_ITERATOR_PREFIX.getKey()) || key.startsWith(Property.TABLE_CONSTRAINT_PREFIX.getKey());
   }
 }


Mime
View raw message