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 2110710A01 for ; Wed, 4 Dec 2013 23:58:48 +0000 (UTC) Received: (qmail 48003 invoked by uid 500); 4 Dec 2013 23:58:46 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 47945 invoked by uid 500); 4 Dec 2013 23:58:46 -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 47796 invoked by uid 99); 4 Dec 2013 23:58:46 -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:46 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id A970C32039E; Wed, 4 Dec 2013 23:58:45 +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:28 -0000 Message-Id: <03e814a63a134b47bfc24b7c25aa07da@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [47/50] [abbrv] git commit: ACCUMULO-1859 update namepace config w/ new getPropertiesMethod 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/master Commit: 5b791b166b9190285bfb3ba3d45c3de0dbb93af1 Parents: 725d821 Author: Keith Turner Authored: Thu Nov 14 14:20:33 2013 -0500 Committer: Christopher Tubbs 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> iterator() { - TreeMap entries = new TreeMap(); - - 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()); - } + private class SystemNamespaceFilter implements PropertyFilter { + + private PropertyFilter userFilter; + + SystemNamespaceFilter(PropertyFilter userFilter) { + this.userFilter = userFilter; } - List 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 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 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 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()); } }