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 E215D10993 for ; Wed, 4 Dec 2013 23:57:54 +0000 (UTC) Received: (qmail 39835 invoked by uid 500); 4 Dec 2013 23:57:54 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 39816 invoked by uid 500); 4 Dec 2013 23:57:54 -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 39808 invoked by uid 99); 4 Dec 2013 23:57:54 -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:57:54 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 8197E32023F; Wed, 4 Dec 2013 23:57:54 +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:58:01 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [09/50] [abbrv] git commit: ACCUMULO-802 fixed problem where moving a table to a new namespace would still inherit its properties from the old namespace ACCUMULO-802 fixed problem where moving a table to a new namespace would still inherit its properties from the old namespace Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/88d44bc6 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/88d44bc6 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/88d44bc6 Branch: refs/heads/1.6.0-SNAPSHOT Commit: 88d44bc6f512ed7a1226fcad628557fee44d1b88 Parents: 08729d2 Author: Sean Hickey Authored: Wed Aug 7 11:28:26 2013 -0400 Committer: Christopher Tubbs Committed: Wed Dec 4 18:46:10 2013 -0500 ---------------------------------------------------------------------- .../server/conf/ServerConfiguration.java | 10 ++--- .../server/conf/TableConfiguration.java | 10 +++++ .../conf/TableNamespaceConfiguration.java | 6 +-- .../accumulo/master/tableOps/RenameTable.java | 3 -- .../server/conf/TableParentConfiguration.java | 41 ++++++++++++++++++++ 5 files changed, 59 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/88d44bc6/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfiguration.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfiguration.java b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfiguration.java index fe78ca4..5093025 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfiguration.java +++ b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfiguration.java @@ -33,6 +33,7 @@ public class ServerConfiguration { private static final Map tableInstances = new HashMap(1); private static final Map tableNamespaceInstances = new HashMap(1); + private static final Map tableParentInstances = new HashMap(1); private static SecurityPermission CONFIGURATION_PERMISSION = new SecurityPermission("configurationPermission"); public static synchronized SiteConfiguration getSiteConfiguration() { @@ -63,13 +64,12 @@ public class ServerConfiguration { public static TableNamespaceConfiguration getTableNamespaceConfigurationForTable(Instance instance, String tableId) { checkPermissions(); - String namespaceId = Tables.getNamespace(instance, tableId); - synchronized (tableNamespaceInstances) { - TableNamespaceConfiguration conf = tableNamespaceInstances.get(namespaceId); + synchronized (tableParentInstances) { + TableNamespaceConfiguration conf = tableParentInstances.get(tableId); if (conf == null) { - conf = new TableNamespaceConfiguration(namespaceId, getSystemConfiguration(instance)); + conf = new TableParentConfiguration(tableId, getSystemConfiguration(instance)); ConfigSanityCheck.validate(conf); - tableNamespaceInstances.put(namespaceId, conf); + tableParentInstances.put(tableId, conf); } return conf; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/88d44bc6/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java b/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java index 2e595a9..530b2c2 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java +++ b/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java @@ -142,7 +142,17 @@ public class TableConfiguration extends AccumuloConfiguration { return table; } + /** + * returns the actual TableNamespaceConfiguration that corresponds to the current parent namespace. + */ public TableNamespaceConfiguration getNamespaceConfiguration() { + return ServerConfiguration.getTableNamespaceConfiguration(parent.inst, parent.namespaceId); + } + + /** + * returns the parent, which is actually a TableParentConfiguration that can change which namespace it references + */ + public TableNamespaceConfiguration getParentConfiguration() { return parent; } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/88d44bc6/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 60da78a..6c75e25 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 @@ -40,8 +40,8 @@ public class TableNamespaceConfiguration extends AccumuloConfiguration { private final AccumuloConfiguration parent; private static ZooCache propCache = null; - private String namespaceId = null; - private Instance inst = null; + protected String namespaceId = null; + protected Instance inst = null; private Set observers; public TableNamespaceConfiguration(String namespaceId, AccumuloConfiguration parent) { @@ -103,7 +103,7 @@ public class TableNamespaceConfiguration extends AccumuloConfiguration { return entries.entrySet().iterator(); } - private String getNamespaceId() { + protected String getNamespaceId() { return namespaceId; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/88d44bc6/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java index a58b847..18b7532 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java @@ -71,9 +71,6 @@ public class RenameTable extends MasterRepo { newTableName = Tables.extractTableName(newTableName); oldTableName = Tables.extractTableName(oldTableName); - // TODO ACCUMULO-802 renaming a table to a new namespace does not change it's parent configuration to be the new namespace - // ...it should...somehow... - IZooReaderWriter zoo = ZooReaderWriter.getRetryingInstance(); Utils.tableNameLock.lock(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/88d44bc6/server/src/main/java/org/apache/accumulo/server/conf/TableParentConfiguration.java ---------------------------------------------------------------------- diff --git a/server/src/main/java/org/apache/accumulo/server/conf/TableParentConfiguration.java b/server/src/main/java/org/apache/accumulo/server/conf/TableParentConfiguration.java new file mode 100644 index 0000000..7590d76 --- /dev/null +++ b/server/src/main/java/org/apache/accumulo/server/conf/TableParentConfiguration.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.accumulo.server.conf; + +import org.apache.accumulo.core.client.impl.Tables; +import org.apache.accumulo.core.conf.AccumuloConfiguration; + + +/** + * Used by TableConfiguration to dynamically get the TableNamespaceConfiguration if the namespace changes + */ +public class TableParentConfiguration extends TableNamespaceConfiguration { + + private String tableId; + + public TableParentConfiguration(String tableId, AccumuloConfiguration parent) { + super(null, parent); + this.tableId = tableId; + this.namespaceId = getNamespaceId(); + } + + @Override + protected String getNamespaceId() { + this.namespaceId = Tables.getNamespace(inst, tableId); + return this.namespaceId; + } +}