You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2013/12/05 00:58:01 UTC

[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 <ta...@gmail.com>
Authored: Wed Aug 7 11:28:26 2013 -0400
Committer: Christopher Tubbs <ct...@apache.org>
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<String,TableConfiguration> tableInstances = new HashMap<String,TableConfiguration>(1);
   private static final Map<String,TableNamespaceConfiguration> tableNamespaceInstances = new HashMap<String,TableNamespaceConfiguration>(1);
+  private static final Map<String,TableNamespaceConfiguration> tableParentInstances = new HashMap<String,TableNamespaceConfiguration>(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<ConfigurationObserver> 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;
+  }
+}