You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2013/12/24 07:18:37 UTC

[3/7] git commit: ACCUMULO-2087 Check for the null result from zk and throw something slightly more meaningful.

ACCUMULO-2087 Check for the null result from zk and throw something slightly more meaningful.


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

Branch: refs/heads/master
Commit: 744f06bfbf23f1cf3f8b0f8b785decd04e69842f
Parents: e8c9aae
Author: Josh Elser <el...@apache.org>
Authored: Mon Dec 23 22:51:32 2013 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Mon Dec 23 22:51:32 2013 -0500

----------------------------------------------------------------------
 .../apache/accumulo/core/client/impl/Tables.java  | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/744f06bf/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 45db491..ba11f1e 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
@@ -30,6 +30,7 @@ import org.apache.accumulo.core.client.NamespaceNotFoundException;
 import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.master.state.tables.TableState;
 import org.apache.accumulo.core.metadata.MetadataTable;
+import org.apache.accumulo.core.util.ArgumentChecker;
 import org.apache.accumulo.core.util.Pair;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
@@ -195,9 +196,24 @@ public class Tables {
     return new Pair<String,String>(defaultNamespace, tableName);
   }
 
-  public static String getNamespace(Instance instance, String tableId) {
+  /**
+   * Returns the namespace for a given table ID.
+   * @param instance The Accumulo Instance
+   * @param tableId The tableId
+   * @return The namespace which this table resides in.
+   * @throws IllegalArgumentException if the table doesn't exist in ZooKeeper
+   */
+  public static String getNamespace(Instance instance, String tableId) throws IllegalArgumentException {
+    ArgumentChecker.notNull(instance, tableId);
+    
     ZooCache zc = getZooCache(instance);
     byte[] n = zc.get(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_NAMESPACE);
+    
+    // We might get null out of ZooCache if this tableID doesn't exist
+    if (null == n) {
+      throw new IllegalArgumentException("Table with id " + tableId + " does not exist");
+    }
+    
     return new String(n, Constants.UTF8);
   }
 }