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 AA7CE1081D for ; Fri, 1 Nov 2013 02:00:09 +0000 (UTC) Received: (qmail 29327 invoked by uid 500); 1 Nov 2013 02:00:04 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 28975 invoked by uid 500); 1 Nov 2013 02:00:04 -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 28346 invoked by uid 99); 1 Nov 2013 02:00:03 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Nov 2013 02:00:03 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 50461D0E2; Fri, 1 Nov 2013 02:00:03 +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: Fri, 01 Nov 2013 02:00:35 -0000 Message-Id: <74e61b2e6e3a472dbaa84b65447f4e6a@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [34/54] 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/1372292c Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/1372292c Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/1372292c Branch: refs/heads/ACCUMULO-802 Commit: 1372292c5790697d6e9024a46e86a52374c46a84 Parents: 9134cc3 Author: Sean Hickey Authored: Wed Aug 7 11:28:26 2013 -0400 Committer: Christopher Tubbs Committed: Thu Oct 31 21:32:38 2013 -0400 ---------------------------------------------------------------------- .../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/1372292c/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/1372292c/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 fe3c30f..8e4299e 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 @@ -145,7 +145,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/1372292c/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/1372292c/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/1372292c/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; + } +}