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

[1/2] git commit: ACCUMULO-2086 Use the tableID instead of the tableName where necessary.

Updated Branches:
  refs/heads/1.6.0-SNAPSHOT 92bd40c6e -> 744f06bfb


ACCUMULO-2086 Use the tableID instead of the tableName where necessary.


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: e8c9aae904380f22e55a31e3a7422ecd4597b0b0
Parents: 92bd40c
Author: Josh Elser <el...@apache.org>
Authored: Mon Dec 23 20:39:31 2013 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Mon Dec 23 20:39:31 2013 -0500

----------------------------------------------------------------------
 .../test/randomwalk/security/TableOp.java       | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/e8c9aae9/test/src/main/java/org/apache/accumulo/test/randomwalk/security/TableOp.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/TableOp.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/TableOp.java
index a636355..0215365 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/security/TableOp.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/security/TableOp.java
@@ -64,12 +64,18 @@ public class TableOp extends Test {
       tp = TablePermission.valueOf(action);
     }
     
-    boolean tableExists = WalkingSecurity.get(state).getTableExists();
-    String tableName = WalkingSecurity.get(state).getTableName();
+    final boolean tableExists = WalkingSecurity.get(state).getTableExists();
+    final String tableName = WalkingSecurity.get(state).getTableName();
+    final String tableId = conn.tableOperations().tableIdMap().get(tableName);
+    
+    if (null == tableId) {
+      log.error("Could not determine tableID from name " + tableName);
+      return;
+    }
     
     switch (tp) {
       case READ: {
-        boolean canRead = WalkingSecurity.get(state).canScan(WalkingSecurity.get(state).getTabCredentials(), tableName);
+        boolean canRead = WalkingSecurity.get(state).canScan(WalkingSecurity.get(state).getTabCredentials(), tableId);
         Authorizations auths = WalkingSecurity.get(state).getUserAuthorizations(WalkingSecurity.get(state).getTabCredentials());
         boolean ambiguousZone = WalkingSecurity.get(state).inAmbiguousZone(conn.whoami(), tp);
         boolean ambiguousAuths = WalkingSecurity.get(state).ambiguousAuthorizations(conn.whoami());
@@ -140,7 +146,7 @@ public class TableOp extends Test {
         break;
       }
       case WRITE:
-        boolean canWrite = WalkingSecurity.get(state).canWrite(WalkingSecurity.get(state).getTabCredentials(), tableName);
+        boolean canWrite = WalkingSecurity.get(state).canWrite(WalkingSecurity.get(state).getTabCredentials(), tableId);
         boolean ambiguousZone = WalkingSecurity.get(state).inAmbiguousZone(conn.whoami(), tp);
         
         String key = WalkingSecurity.get(state).getLastKey() + "1";
@@ -214,7 +220,7 @@ public class TableOp extends Test {
           return;
         } catch (AccumuloSecurityException ae) {
           if (ae.getSecurityErrorCode().equals(SecurityErrorCode.PERMISSION_DENIED)) {
-            if (WalkingSecurity.get(state).canBulkImport(WalkingSecurity.get(state).getTabCredentials(), tableName))
+            if (WalkingSecurity.get(state).canBulkImport(WalkingSecurity.get(state).getTabCredentials(), tableId))
               throw new AccumuloException("Bulk Import failed when it should have worked: " + tableName);
             return;
           } else if (ae.getSecurityErrorCode().equals(SecurityErrorCode.BAD_CREDENTIALS)) {
@@ -228,12 +234,12 @@ public class TableOp extends Test {
         fs.delete(dir, true);
         fs.delete(fail, true);
         
-        if (!WalkingSecurity.get(state).canBulkImport(WalkingSecurity.get(state).getTabCredentials(), tableName))
+        if (!WalkingSecurity.get(state).canBulkImport(WalkingSecurity.get(state).getTabCredentials(), tableId))
           throw new AccumuloException("Bulk Import succeeded when it should have failed: " + dir + " table " + tableName);
         break;
       case ALTER_TABLE:
         AlterTable.renameTable(conn, state, tableName, tableName + "plus",
-            WalkingSecurity.get(state).canAlterTable(WalkingSecurity.get(state).getTabCredentials(), tableName), tableExists);
+            WalkingSecurity.get(state).canAlterTable(WalkingSecurity.get(state).getTabCredentials(), tableId), tableExists);
         break;
       
       case GRANT:


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

Posted by el...@apache.org.
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/1.6.0-SNAPSHOT
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);
   }
 }