accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject git commit: ACCUMULO-2091 Catch AccumuloException in RW RenameTable.
Date Fri, 27 Dec 2013 02:43:58 GMT
Updated Branches:
  refs/heads/1.6.0-SNAPSHOT 9f59c0022 -> ccb6093bb


ACCUMULO-2091 Catch AccumuloException in RW RenameTable.

When we rename a table, we might attempt to rename it to a different namespace. This should
cause an error, so check for
this.


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: ccb6093bbc33bb5ec8155aca7a594c5c58719ca4
Parents: 9f59c00
Author: Josh Elser <elserj@apache.org>
Authored: Thu Dec 26 21:33:28 2013 -0500
Committer: Josh Elser <elserj@apache.org>
Committed: Thu Dec 26 21:36:05 2013 -0500

----------------------------------------------------------------------
 .../test/randomwalk/concurrent/RenameTable.java | 23 ++++++++++++++++++++
 .../test/randomwalk/concurrent/Setup.java       |  2 ++
 2 files changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/ccb6093b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTable.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTable.java
b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTable.java
index 0e0b406..6c7516e 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTable.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTable.java
@@ -20,6 +20,7 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Random;
 
+import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.TableExistsException;
 import org.apache.accumulo.core.client.TableNotFoundException;
@@ -40,6 +41,18 @@ public class RenameTable extends Test {
     String srcTableName = tableNames.get(rand.nextInt(tableNames.size()));
     String newTableName = tableNames.get(rand.nextInt(tableNames.size()));
     
+    String srcNamespace = "", newNamespace = "";
+    
+    int index = srcTableName.indexOf('.');
+    if (-1 != index) {
+      srcNamespace = srcTableName.substring(0, index);
+    }
+    
+    index = newTableName.indexOf('.');
+    if (-1 != index) {
+      newNamespace = newTableName.substring(0, index);
+    }
+    
     try {
       conn.tableOperations().rename(srcTableName, newTableName);
       log.debug("Renamed table " + srcTableName + " " + newTableName);
@@ -49,6 +62,16 @@ public class RenameTable extends Test {
       log.debug("Rename " + srcTableName + " failed, doesnt exist");
     } catch (IllegalArgumentException e) {
       log.debug("Rename: " + e.toString());
+    } catch (AccumuloException e) {
+      // Catch the expected failure when we try to rename a table into a new namespace
+      if (!srcNamespace.equals(newNamespace)) {
+        return;
+      }
+      log.debug("Rename " + srcTableName + " failed.", e);
+    }
+    
+    if (!srcNamespace.equals(newNamespace)) {
+      log.error("RenameTable operation should have failed when renaming across namespaces.");
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ccb6093b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Setup.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Setup.java
b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Setup.java
index edab2b5..cb481f8 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Setup.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Setup.java
@@ -42,11 +42,13 @@ public class Setup extends Test {
       namespaces.add(String.format("nspc_%03d", i));
     }
     
+    // Make tables in the default namespace
     double tableCeil = Math.ceil(numTables / (numNamespaces + 1));
     for (int i = 0; i < tableCeil; i++) {
       tables.add(String.format("ctt_%03d", i));
     }
     
+    // Make tables in each namespace
     double tableFloor = Math.floor(numTables / (numNamespaces + 1));
     for (String n : namespaces) {
       for (int i = 0; i < tableFloor; i++) {


Mime
View raw message