accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [3/6] git commit: ACCUMULO-2857 Return a more real tableID
Date Thu, 05 Jun 2014 17:30:07 GMT
ACCUMULO-2857 Return a more real tableID


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

Branch: refs/heads/master
Commit: 9fcca2ede18a7b96bee4edb5ab105316ac383604
Parents: 6dfcf8f
Author: Josh Elser <elserj@apache.org>
Authored: Thu Jun 5 12:53:26 2014 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Thu Jun 5 12:53:26 2014 -0400

----------------------------------------------------------------------
 .../accumulo/core/client/mock/MockAccumulo.java     |  4 +++-
 .../apache/accumulo/core/client/mock/MockTable.java |  8 +++++++-
 .../core/client/mock/MockTableOperations.java       |  4 ++--
 .../core/client/mock/MockTableOperationsTest.java   | 11 +++++++++++
 .../master/balancer/TableLoadBalancerTest.java      | 16 +++++++++-------
 5 files changed, 32 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/9fcca2ed/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
index 5977d1d..272d1af 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockAccumulo.java
@@ -21,6 +21,7 @@ import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.SortedSet;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.BatchScanner;
@@ -38,6 +39,7 @@ public class MockAccumulo {
   final Map<String,String> systemProperties = new HashMap<String,String>();
   Map<String,MockUser> users = new HashMap<String,MockUser>();
   final FileSystem fs;
+  final AtomicInteger tableIdCounter = new AtomicInteger(0);
   
   MockAccumulo(FileSystem fs) {
     this.fs = fs;
@@ -76,7 +78,7 @@ public class MockAccumulo {
   }
   
   public void createTable(String username, String tableName, boolean useVersions, TimeType
timeType) {
-    MockTable t = new MockTable(useVersions, timeType);
+    MockTable t = new MockTable(useVersions, timeType, Integer.toString(tableIdCounter.incrementAndGet()));
     t.userPermissions.put(username, EnumSet.allOf(TablePermission.class));
     tables.put(tableName, t);
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/9fcca2ed/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
index 3dcab11..2e13d84 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTable.java
@@ -89,9 +89,11 @@ public class MockTable {
   private TimeType timeType;
   SortedSet<Text> splits = new ConcurrentSkipListSet<Text>();
   Map<String,Set<Text>> localityGroups = new TreeMap<String, Set<Text>>();
+  private String tableId;
   
-  MockTable(boolean limitVersion, TimeType timeType) {
+  MockTable(boolean limitVersion, TimeType timeType, String tableId) {
     this.timeType = timeType;
+    this.tableId = tableId;
     settings = IteratorUtil.generateInitialTableProperties(limitVersion);
     for (Entry<String,String> entry : AccumuloConfiguration.getDefaultConfiguration())
{
       String key = entry.getKey();
@@ -143,4 +145,8 @@ public class MockTable {
     if (reAdd)
       splits.add(start);
   }
+
+  public String getTableId() {
+    return this.tableId;
+  }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/9fcca2ed/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
index 64f8225..5b15351 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java
@@ -296,8 +296,8 @@ public class MockTableOperations extends TableOperationsHelper {
   @Override
   public Map<String,String> tableIdMap() {
     Map<String,String> result = new HashMap<String,String>();
-    for (String table : acu.tables.keySet()) {
-      result.put(table, table);
+    for (Entry<String,MockTable> entry : acu.tables.entrySet()) {
+      result.put(entry.getKey(), entry.getValue().getTableId());
     }
     return result;
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/9fcca2ed/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
b/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
index ea916e7..cea66a4 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/mock/MockTableOperationsTest.java
@@ -333,4 +333,15 @@ public class MockTableOperationsTest {
 
   }
 
+
+  @Test
+  public void testTableIdMap() throws Exception {
+    Instance inst = new MockInstance("testTableIdMap");
+    Connector conn = inst.getConnector("root", new PasswordToken(""));
+    TableOperations tops = conn.tableOperations();
+    tops.create("foo");
+
+    // Should get a table ID, not the table name
+    Assert.assertNotEquals("foo", tops.tableIdMap().get("foo"));
+  }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/9fcca2ed/server/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
----------------------------------------------------------------------
diff --git a/server/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
b/server/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
index 71ba50d..b7c6412 100644
--- a/server/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
+++ b/server/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java
@@ -128,12 +128,14 @@ public class TableLoadBalancerTest {
   @Test
   public void test() throws Exception {
     Connector c = instance.getConnector("user", new PasswordToken("pass"));
-    c.tableOperations().create("t1");
-    c.tableOperations().create("t2");
-    c.tableOperations().create("t3");
+    TableOperations tops = c.tableOperations();
+    tops.create("t1");
+    tops.create("t2");
+    tops.create("t3");
+    String t1Id = tops.tableIdMap().get("t1"), t2Id = tops.tableIdMap().get("t2"), t3Id =
tops.tableIdMap().get("t3");
     state = new TreeMap<TServerInstance,TabletServerStatus>();
     TServerInstance svr = mkts("10.0.0.1:1234", "0x01020304");
-    state.put(svr, status("t1", 10, "t2", 10, "t3", 10));
+    state.put(svr, status(t1Id, 10, t2Id, 10, t3Id, 10));
     
     Set<KeyExtent> migrations = Collections.emptySet();
     List<TabletMigration> migrationsOut = new ArrayList<TabletMigration>();
@@ -146,9 +148,9 @@ public class TableLoadBalancerTest {
     tls.balance(state, migrations, migrationsOut);
     int count = 0;
     Map<String,Integer> movedByTable = new HashMap<String,Integer>();
-    movedByTable.put("t1", new Integer(0));
-    movedByTable.put("t2", new Integer(0));
-    movedByTable.put("t3", new Integer(0));
+    movedByTable.put(t1Id, new Integer(0));
+    movedByTable.put(t2Id, new Integer(0));
+    movedByTable.put(t3Id, new Integer(0));
     for (TabletMigration migration : migrationsOut) {
       if (migration.oldServer.equals(svr))
         count++;


Mime
View raw message