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:42 UTC

[50/50] [abbrv] git commit: ACCUMULO-802 fix more issues from ReviewBoard

ACCUMULO-802 fix more issues from ReviewBoard


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 859cf2087c2506f60178efff1e08d8ad91af3d2d
Parents: 8b54ced
Author: Christopher Tubbs <ct...@apache.org>
Authored: Wed Dec 4 18:45:51 2013 -0500
Committer: Christopher Tubbs <ct...@apache.org>
Committed: Wed Dec 4 18:47:21 2013 -0500

----------------------------------------------------------------------
 .../core/client/admin/NamespaceOperations.java  |  5 ++++-
 .../client/admin/NamespaceOperationsImpl.java   |  8 +++-----
 .../core/client/admin/TableOperationsImpl.java  |  8 +-------
 .../accumulo/core/client/impl/Tables.java       | 21 +++++++++++++-------
 .../shell/commands/CreateNamespaceCommand.java  |  3 ---
 .../randomwalk/concurrent/RenameNamespace.java  |  2 +-
 6 files changed, 23 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/859cf208/core/src/main/java/org/apache/accumulo/core/client/admin/NamespaceOperations.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/NamespaceOperations.java b/core/src/main/java/org/apache/accumulo/core/client/admin/NamespaceOperations.java
index 4ee670c..535287d 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/NamespaceOperations.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/admin/NamespaceOperations.java
@@ -32,6 +32,9 @@ import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
 /**
  * Provides an API for administering namespaces
  * 
+ * All tables exist in a namespace. The default namespace has no name, and is used if an explicit namespace is not specified. Fully qualified table names look
+ * like "namespaceName.tableName". Tables in the default namespace are fully qualified simply as "tableName".
+ * 
  * @since 1.6.0
  */
 public interface NamespaceOperations {
@@ -63,7 +66,7 @@ public interface NamespaceOperations {
   public boolean exists(String namespace) throws AccumuloException, AccumuloSecurityException;
 
   /**
-   * Create an empty namespace with no initial configuration
+   * Create an empty namespace with no initial configuration. Valid names for a namespace contain letters, numbers, and the underscore character.
    * 
    * @param namespace
    *          the name of the namespace

http://git-wip-us.apache.org/repos/asf/accumulo/blob/859cf208/core/src/main/java/org/apache/accumulo/core/client/admin/NamespaceOperationsImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/NamespaceOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/admin/NamespaceOperationsImpl.java
index 1ddcaf7..e5e18dc 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/NamespaceOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/admin/NamespaceOperationsImpl.java
@@ -98,9 +98,8 @@ public class NamespaceOperationsImpl extends NamespaceOperationsHelper {
 
     try {
       doNamespaceOperation(TableOperation.CREATE, Arrays.asList(ByteBuffer.wrap(namespace.getBytes())), Collections.<String,String> emptyMap());
-    } catch (NamespaceNotFoundException e1) {
-      // should not happen
-      throw new RuntimeException(e1);
+    } catch (NamespaceNotFoundException e) {
+      throw new AssertionError("Shouldn't happen: " + e.getMessage());
     }
   }
 
@@ -235,8 +234,7 @@ public class NamespaceOperationsImpl extends NamespaceOperationsHelper {
     try {
       doNamespaceOperation(TableOperation.DELETE, args, opts);
     } catch (NamespaceExistsException e) {
-      // should not happen
-      throw new RuntimeException(e);
+      throw new AssertionError("Shouldn't happen: " + e.getMessage());
     }
 
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/859cf208/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
index 7f79fcd..ef2bd09 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
@@ -1506,13 +1506,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
       Logger.getLogger(this.getClass()).warn("Failed to check if imported table references external java classes : " + ioe.getMessage());
     }
 
-    String namespace = Tables.qualify(tableName).getFirst();
-    if (!namespaceExists(namespace)) {
-      String info = "Namespace not found while importing to table";
-      throw new RuntimeException(new NamespaceNotFoundException(null, namespace, info));
-    }
-
-    List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes()), ByteBuffer.wrap(importDir.getBytes()));
+    List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes(Constants.UTF8)), ByteBuffer.wrap(importDir.getBytes()));
 
     Map<String,String> opts = Collections.emptyMap();
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/859cf208/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java b/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
index af8c617..45db491 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/Tables.java
@@ -17,6 +17,7 @@
 package org.apache.accumulo.core.client.impl;
 
 import java.security.SecurityPermission;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.SortedMap;
@@ -54,28 +55,34 @@ public class Tables {
 
     TreeMap<String,String> tableMap = new TreeMap<String,String>();
 
+    Map<String,String> namespaceIdToNameMap = new HashMap<String,String>();
+
     for (String tableId : tableIds) {
-      byte[] tblPath = zc.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_NAME);
+      byte[] tableName = zc.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_NAME);
       byte[] nId = zc.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_NAMESPACE);
-      String name = "";
+      String namespaceName = Constants.DEFAULT_NAMESPACE;
       // create fully qualified table name
       if (nId != null) {
         String namespaceId = new String(nId, Constants.UTF8);
         if (!namespaceId.equals(Constants.DEFAULT_NAMESPACE_ID)) {
           try {
-            name += Namespaces.getNamespaceName(instance, namespaceId) + ".";
+            namespaceName = namespaceIdToNameMap.get(namespaceId);
+            if (namespaceName == null) {
+              namespaceName = Namespaces.getNamespaceName(instance, namespaceId);
+              namespaceIdToNameMap.put(namespaceId, namespaceName);
+            }
           } catch (NamespaceNotFoundException e) {
             log.error("Table (" + tableId + ") contains reference to namespace (" + namespaceId + ") that doesn't exist");
             continue;
           }
         }
       }
-      if (tblPath != null) {
-        name += new String(tblPath, Constants.UTF8);
+      if (tableName != null) {
+        String tableNameStr = qualified(new String(tableName, Constants.UTF8), namespaceName);
         if (nameAsKey)
-          tableMap.put(name, tableId);
+          tableMap.put(tableNameStr, tableId);
         else
-          tableMap.put(tableId, name);
+          tableMap.put(tableId, tableNameStr);
       }
     }
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/859cf208/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateNamespaceCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateNamespaceCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateNamespaceCommand.java
index 908a9cc..d59f2ef 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateNamespaceCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateNamespaceCommand.java
@@ -35,7 +35,6 @@ import org.apache.commons.cli.Options;
 
 public class CreateNamespaceCommand extends Command {
   private Option createTableOptCopyConfig, createNamespaceOptCopyConfig;
-  private Option base64Opt;
 
   @Override
   public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException,
@@ -93,8 +92,6 @@ public class CreateNamespaceCommand extends Command {
     createTableOptCopyConfig = new Option("ctc", "copy-table-config", true, "table to copy configuration from");
     createTableOptCopyConfig.setArgName("tableName");
 
-    base64Opt = new Option("b64", "base64encoded", false, "decode encoded split points");
-    o.addOption(base64Opt);
     OptionGroup ogp = new OptionGroup();
     ogp.addOption(createTableOptCopyConfig);
     ogp.addOption(createNamespaceOptCopyConfig);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/859cf208/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameNamespace.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameNamespace.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameNamespace.java
index bf22ad6..5aa21ed 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameNamespace.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameNamespace.java
@@ -46,7 +46,7 @@ public class RenameNamespace extends Test {
     } catch (NamespaceExistsException e) {
       log.debug("Rename namespace " + srcName + " failed, " + newName + " exists");
     } catch (NamespaceNotFoundException e) {
-      log.debug("Rename namespace " + srcName + " failed, doesnt exist");
+      log.debug("Rename namespace " + srcName + " failed, doesn't exist");
     }
   }
 }