Updated Branches:
  refs/heads/1.6.0-SNAPSHOT 5117947c4 -> 98e374b0e

ACCUMULO-2316 No more namespacenotfound for table requests


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 98e374b0ea342136d4ef68cd3a266653ea07de11
Parents: 17324b9
Author: John Vines <vi...@apache.org>
Authored: Mon Feb 3 18:03:55 2014 -0500
Committer: John Vines <vi...@apache.org>
Committed: Mon Feb 3 18:04:46 2014 -0500

----------------------------------------------------------------------
 .../client/admin/SecurityOperationsImpl.java     |  4 ++++
 .../server/client/ClientServiceHandler.java      | 19 +++++++++++--------
 .../accumulo/master/FateServiceHandler.java      | 12 ++++++------
 .../master/MasterClientServiceHandler.java       |  4 ++--
 .../org/apache/accumulo/test/NamespacesIT.java   | 12 ++----------
 5 files changed, 25 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/98e374b0/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperationsImpl.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperationsImpl.java
 
b/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperationsImpl.java
index ebd79ad..17feb9b 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperationsImpl.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/client/admin/SecurityOperationsImpl.java
@@ -53,6 +53,8 @@ public class SecurityOperationsImpl implements 
SecurityOperations {
       // recast missing table
       if (ttoe.getType() == TableOperationExceptionType.NOTFOUND)
         throw new AccumuloSecurityException(null, 
SecurityErrorCode.TABLE_DOESNT_EXIST);
+      else if (ttoe.getType() == 
TableOperationExceptionType.NAMESPACE_NOTFOUND)
+        throw new AccumuloSecurityException(null, 
SecurityErrorCode.NAMESPACE_DOESNT_EXIST);
       else
         throw new AccumuloException(ttoe);
     } catch (ThriftSecurityException e) {
@@ -71,6 +73,8 @@ public class SecurityOperationsImpl implements 
SecurityOperations {
       // recast missing table
       if (ttoe.getType() == TableOperationExceptionType.NOTFOUND)
         throw new AccumuloSecurityException(null, 
SecurityErrorCode.TABLE_DOESNT_EXIST);
+      else if (ttoe.getType() == 
TableOperationExceptionType.NAMESPACE_NOTFOUND)
+        throw new AccumuloSecurityException(null, 
SecurityErrorCode.NAMESPACE_DOESNT_EXIST);
       else
         throw new AccumuloException(ttoe);
     } catch (ThriftSecurityException e) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/98e374b0/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
----------------------------------------------------------------------
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
 
b/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
index 3571d7f..d62ccc1 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
@@ -80,12 +80,15 @@ public class ClientServiceHandler implements 
ClientService.Iface {
     this.fs = fs;
   }
 
-  public static String checkTableId(Instance instance, String tableName, 
TableOperation operation) throws ThriftTableOperationException {
+  public static String checkTableId(Instance instance, String tableName, 
TableOperation operation, boolean allowNamespaceNotFound) throws 
ThriftTableOperationException {
     TableOperationExceptionType reason = null;
     try {
       return Tables._getTableId(instance, tableName);
     } catch (NamespaceNotFoundException e) {
-      reason = TableOperationExceptionType.NAMESPACE_NOTFOUND;
+      if (allowNamespaceNotFound)
+        reason = TableOperationExceptionType.NAMESPACE_NOTFOUND;
+      else
+        reason = TableOperationExceptionType.NOTFOUND;
     } catch (TableNotFoundException e) {
       reason = TableOperationExceptionType.NOTFOUND;
     }
@@ -182,7 +185,7 @@ public class ClientServiceHandler implements 
ClientService.Iface {
   @Override
   public void grantTablePermission(TInfo tinfo, TCredentials credentials, 
String user, String tableName, byte permission) throws ThriftSecurityException,
       ThriftTableOperationException {
-    String tableId = checkTableId(instance, tableName, 
TableOperation.PERMISSION);
+    String tableId = checkTableId(instance, tableName, 
TableOperation.PERMISSION, false);
     String namespaceId = Tables.getNamespaceId(instance, tableId); 
 
     security.grantTablePermission(credentials, user, tableId, 
TablePermission.getPermissionById(permission), namespaceId);
@@ -203,7 +206,7 @@ public class ClientServiceHandler implements 
ClientService.Iface {
   @Override
   public void revokeTablePermission(TInfo tinfo, TCredentials credentials, 
String user, String tableName, byte permission) throws ThriftSecurityException,
       ThriftTableOperationException {
-    String tableId = checkTableId(instance, tableName, 
TableOperation.PERMISSION);
+    String tableId = checkTableId(instance, tableName, 
TableOperation.PERMISSION, false);
     String namespaceId = Tables.getNamespaceId(instance, tableId); 
 
     security.revokeTablePermission(credentials, user, tableId, 
TablePermission.getPermissionById(permission), namespaceId);
@@ -217,7 +220,7 @@ public class ClientServiceHandler implements 
ClientService.Iface {
   @Override
   public boolean hasTablePermission(TInfo tinfo, TCredentials credentials, 
String user, String tableName, byte tblPerm) throws ThriftSecurityException,
       ThriftTableOperationException {
-    String tableId = checkTableId(instance, tableName, 
TableOperation.PERMISSION);
+    String tableId = checkTableId(instance, tableName, 
TableOperation.PERMISSION, false);
     return security.hasTablePermission(credentials, user, tableId, 
TablePermission.getPermissionById(tblPerm));
   }
 
@@ -268,7 +271,7 @@ public class ClientServiceHandler implements 
ClientService.Iface {
 
   @Override
   public Map<String,String> getTableConfiguration(TInfo tinfo, TCredentials 
credentials, String tableName) throws TException, ThriftTableOperationException 
{
-    String tableId = checkTableId(instance, tableName, null);
+    String tableId = checkTableId(instance, tableName, null, true);
     AccumuloConfiguration config = 
ServerConfiguration.getTableConfiguration(instance, tableId);
     return conf(credentials, config);
   }
@@ -331,7 +334,7 @@ public class ClientServiceHandler implements 
ClientService.Iface {
 
     security.authenticateUser(credentials, credentials);
 
-    String tableId = checkTableId(instance, tableName, null);
+    String tableId = checkTableId(instance, tableName, null, true);
 
     ClassLoader loader = getClass().getClassLoader();
     Class<?> shouldMatch;
@@ -403,7 +406,7 @@ public class ClientServiceHandler implements 
ClientService.Iface {
 
       for (String table : tables) {
         // ensure that table table exists
-        String tableId = checkTableId(instance, table, null);
+        String tableId = checkTableId(instance, table, null, true);
         tableIds.add(tableId);
         String namespaceId = Tables.getNamespaceId(instance, tableId);
         if (!security.canScan(credentials, tableId, namespaceId))

http://git-wip-us.apache.org/repos/asf/accumulo/blob/98e374b0/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java
----------------------------------------------------------------------
diff --git 
a/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java
 
b/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java
index 555e3e4..7e274c0 100644
--- 
a/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java
+++ 
b/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java
@@ -160,7 +160,7 @@ class FateServiceHandler implements FateService.Iface {
 
         });
 
-        String tableId = 
ClientServiceHandler.checkTableId(master.getInstance(), oldTableName, tableOp);
+        String tableId = 
ClientServiceHandler.checkTableId(master.getInstance(), oldTableName, tableOp, 
true);
         String namespaceId = Tables.getNamespaceId(master.getInstance(), 
tableId);
 
         if (!master.security.canRenameTable(c, tableId, oldTableName, 
newTableName, namespaceId))
@@ -215,7 +215,7 @@ class FateServiceHandler implements FateService.Iface {
         TableOperation tableOp = TableOperation.DELETE;
         String tableName = validateTableNameArgument(arguments.get(0), 
tableOp, Tables.NOT_SYSTEM);
 
-        final String tableId = 
ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp);
+        final String tableId = 
ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp, 
true);
         String namespaceId = Tables.getNamespaceId(master.getInstance(), 
tableId);
 
         if (!master.security.canDeleteTable(c, tableId, namespaceId))
@@ -251,7 +251,7 @@ class FateServiceHandler implements FateService.Iface {
         Text startRow = ByteBufferUtil.toText(arguments.get(1));
         Text endRow = ByteBufferUtil.toText(arguments.get(2));
 
-        final String tableId = 
ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp);
+        final String tableId = 
ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp, 
true);
         String namespaceId = Tables.getNamespaceId(master.getInstance(), 
tableId);
 
         if (!master.security.canMerge(c, tableId, namespaceId))
@@ -267,7 +267,7 @@ class FateServiceHandler implements FateService.Iface {
         Text startRow = ByteBufferUtil.toText(arguments.get(1));
         Text endRow = ByteBufferUtil.toText(arguments.get(2));
 
-        final String tableId = 
ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp);
+        final String tableId = 
ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp, 
true);
         String namespaceId = Tables.getNamespaceId(master.getInstance(), 
tableId);
 
         if (!master.security.canDeleteRange(c, tableId, tableName, startRow, 
endRow, namespaceId))
@@ -283,7 +283,7 @@ class FateServiceHandler implements FateService.Iface {
         String failDir = ByteBufferUtil.toString(arguments.get(2));
         boolean setTime = 
Boolean.parseBoolean(ByteBufferUtil.toString(arguments.get(3)));
 
-        final String tableId = 
ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp);
+        final String tableId = 
ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp, 
true);
         String namespaceId = Tables.getNamespaceId(master.getInstance(), 
tableId);
         
         if (!master.security.canBulkImport(c, tableId, tableName, dir, 
failDir, namespaceId))
@@ -339,7 +339,7 @@ class FateServiceHandler implements FateService.Iface {
         String tableName = validateTableNameArgument(arguments.get(0), 
tableOp, Tables.NOT_SYSTEM);
         String exportDir = ByteBufferUtil.toString(arguments.get(1));
 
-        String tableId = 
ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp);
+        String tableId = 
ClientServiceHandler.checkTableId(master.getInstance(), tableName, tableOp, 
true);
         String namespaceId = Tables.getNamespaceId(master.getInstance(), 
tableId);
         
         if (!master.security.canExport(c, tableId, tableName, exportDir, 
namespaceId))

http://git-wip-us.apache.org/repos/asf/accumulo/blob/98e374b0/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java
----------------------------------------------------------------------
diff --git 
a/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java
 
b/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java
index 8023169..847cd80 100644
--- 
a/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java
+++ 
b/server/master/src/main/java/org/apache/accumulo/master/MasterClientServiceHandler.java
@@ -434,7 +434,7 @@ class MasterClientServiceHandler extends FateServiceHandler 
implements MasterCli
 
   private void alterTableProperty(TCredentials c, String tableName, String 
property, String value, TableOperation op) throws ThriftSecurityException,
       ThriftTableOperationException {
-    final String tableId = 
ClientServiceHandler.checkTableId(master.getInstance(), tableName, op);
+    final String tableId = 
ClientServiceHandler.checkTableId(master.getInstance(), tableName, op, false);
     String namespaceId = Tables.getNamespaceId(master.getInstance(), tableId); 
     if (!master.security.canAlterTable(c, tableId, namespaceId))
       throw new ThriftSecurityException(c.getPrincipal(), 
SecurityErrorCode.PERMISSION_DENIED);
@@ -447,7 +447,7 @@ class MasterClientServiceHandler extends FateServiceHandler 
implements MasterCli
       }
     } catch (KeeperException.NoNodeException e) {
       // race condition... table no longer exists? This call will throw an 
exception if the table was deleted:
-      ClientServiceHandler.checkTableId(master.getInstance(), tableName, op);
+      ClientServiceHandler.checkTableId(master.getInstance(), tableName, op, 
true);
       log.info("Error altering table property", e);
       throw new ThriftTableOperationException(tableId, tableName, op, 
TableOperationExceptionType.OTHER, "Problem altering table property");
     } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/98e374b0/test/src/test/java/org/apache/accumulo/test/NamespacesIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/NamespacesIT.java 
b/test/src/test/java/org/apache/accumulo/test/NamespacesIT.java
index 6915c96..3ea16c5 100644
--- a/test/src/test/java/org/apache/accumulo/test/NamespacesIT.java
+++ b/test/src/test/java/org/apache/accumulo/test/NamespacesIT.java
@@ -528,13 +528,6 @@ public class NamespacesIT extends SimpleMacIT {
     assertFalse(c.tableOperations().exists(t2));
     assertTrue(c.tableOperations().exists(t3));
     assertFalse(c.tableOperations().exists(t4));
-
-    // unqualified rename
-    c.tableOperations().rename(t3, Tables.qualify(t4).getSecond());
-    assertFalse(c.tableOperations().exists(t1));
-    assertFalse(c.tableOperations().exists(t2));
-    assertFalse(c.tableOperations().exists(t3));
-    assertTrue(c.tableOperations().exists(t4));
   }
 
   /**
@@ -871,8 +864,7 @@ public class NamespacesIT extends SimpleMacIT {
         }
       } catch (Exception e) {
         numRun++;
-        if (!(e instanceof AccumuloException) || !(e.getCause() instanceof 
TableNotFoundException)
-            || !(e.getCause().getCause() instanceof 
NamespaceNotFoundException))
+        if (!(e instanceof TableNotFoundException || (e instanceof 
AccumuloException && e.getCause() instanceof TableNotFoundException)))
           throw new Exception("Case " + i + " resulted in " + 
e.getClass().getName(), e);
       }
 
@@ -976,7 +968,7 @@ public class NamespacesIT extends SimpleMacIT {
         }
       } catch (Exception e) {
         numRun++;
-        if (!(e instanceof TableNotFoundException) || !(e.getCause() 
instanceof NamespaceNotFoundException))
+        if (!(e instanceof TableNotFoundException) && !(e.getCause() 
instanceof NamespaceNotFoundException))
           throw new Exception("Case " + i + " resulted in " + 
e.getClass().getName(), e);
       }
   }

Reply via email to