ACCUMULO-3169 Handle table not found case in clone

* Ensure that we can retrieve the namespaceId for the given srcTableId when we
  construct a CloneTable fate operation.
* Throw an appropriate exception which propagates to the client when we can't.


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

Branch: refs/heads/master
Commit: 76c545bb3bdb4c59963cc00417a663ab1ae046f1
Parents: 182fbce
Author: Christopher Tubbs <[email protected]>
Authored: Fri May 29 17:01:40 2015 -0400
Committer: Christopher Tubbs <[email protected]>
Committed: Fri May 29 17:09:01 2015 -0400

----------------------------------------------------------------------
 .../apache/accumulo/master/tableOps/CloneTable.java    | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/76c545bb/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
----------------------------------------------------------------------
diff --git 
a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
 
b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
index da0afd8..b7e335f 100644
--- 
a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
+++ 
b/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java
@@ -231,7 +231,8 @@ public class CloneTable extends MasterRepo {
   private static final long serialVersionUID = 1L;
   private CloneInfo cloneInfo;
 
-  public CloneTable(String user, String srcTableId, String tableName, 
Map<String,String> propertiesToSet, Set<String> propertiesToExclude) {
+  public CloneTable(String user, String srcTableId, String tableName, 
Map<String,String> propertiesToSet, Set<String> propertiesToExclude)
+      throws ThriftTableOperationException {
     cloneInfo = new CloneInfo();
     cloneInfo.user = user;
     cloneInfo.srcTableId = srcTableId;
@@ -239,7 +240,15 @@ public class CloneTable extends MasterRepo {
     cloneInfo.propertiesToExclude = propertiesToExclude;
     cloneInfo.propertiesToSet = propertiesToSet;
     Instance inst = HdfsZooInstance.getInstance();
-    cloneInfo.srcNamespaceId = Tables.getNamespaceId(inst, 
cloneInfo.srcTableId);
+    try {
+      cloneInfo.srcNamespaceId = Tables.getNamespaceId(inst, 
cloneInfo.srcTableId);
+    } catch (IllegalArgumentException e) {
+      if (inst == null || cloneInfo.srcTableId == null) {
+        // just throw the exception if the illegal argument was thrown by the 
argument checker and not due to table non-existence
+        throw e;
+      }
+      throw new ThriftTableOperationException(cloneInfo.srcTableId, "", 
TableOperation.CLONE, TableOperationExceptionType.NOTFOUND, "Table does not 
exist");
+    }
   }
 
   @Override

Reply via email to