accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [2/6] git commit: ACCUMULO-3271 Add splits to a table after it is created in MultiNode module.
Date Mon, 27 Oct 2014 23:52:50 GMT
ACCUMULO-3271 Add splits to a table after it is created in MultiNode module.


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

Branch: refs/heads/1.6
Commit: d3d6986e5fa007daa02a909c14d829a61ce6cb02
Parents: 351c70e
Author: Josh Elser <elserj@apache.org>
Authored: Mon Oct 27 19:35:01 2014 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Mon Oct 27 19:35:01 2014 -0400

----------------------------------------------------------------------
 .../test/randomwalk/multitable/CopyTable.java   | 36 +++++++++++++-------
 .../test/randomwalk/multitable/CreateTable.java | 19 +++++++++--
 2 files changed, 40 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/d3d6986e/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CopyTable.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CopyTable.java
b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CopyTable.java
index 5a2172d..1aa8384 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CopyTable.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CopyTable.java
@@ -19,29 +19,40 @@ package org.apache.accumulo.test.randomwalk.multitable;
 import java.util.ArrayList;
 import java.util.Properties;
 import java.util.Random;
+import java.util.TreeSet;
 
 import org.apache.accumulo.core.client.impl.Tables;
 import org.apache.accumulo.core.util.CachedConfiguration;
 import org.apache.accumulo.test.randomwalk.State;
 import org.apache.accumulo.test.randomwalk.Test;
+import org.apache.hadoop.io.Text;
 import org.apache.hadoop.util.ToolRunner;
 
 public class CopyTable extends Test {
-  
+
+  private final TreeSet<Text> splits;
+
+  public CopyTable() {
+    splits = new TreeSet<Text>();
+    for (int i = 1; i < 10; i++) {
+      splits.add(new Text(Integer.toString(i)));
+    }
+  }
+
   @Override
   public void visit(State state, Properties props) throws Exception {
-    
+
     @SuppressWarnings("unchecked")
     ArrayList<String> tables = (ArrayList<String>) state.get("tableList");
     if (tables.isEmpty())
       return;
-    
+
     Random rand = new Random();
     String srcTableName = tables.remove(rand.nextInt(tables.size()));
-    
+
     int nextId = ((Integer) state.get("nextId")).intValue();
     String dstTableName = String.format("%s_%d", state.getString("tableNamePrefix"), nextId);
-    
+
     String[] args = new String[8];
     args[0] = "-libjars";
     args[1] = state.getMapReduceJars();
@@ -51,24 +62,25 @@ public class CopyTable extends Test {
     args[5] = state.getInstance().getInstanceName();
     args[6] = state.getProperty("ZOOKEEPERS");
     args[7] = dstTableName;
-    
+
     log.debug("copying " + srcTableName + " to " + dstTableName);
-    
+
     state.getConnector().tableOperations().create(dstTableName);
-    
+    state.getConnector().tableOperations().addSplits(dstTableName, splits);
+
     if (ToolRunner.run(CachedConfiguration.getInstance(), new CopyTool(), args) != 0) {
       log.error("Failed to run map/red verify");
       return;
     }
-    
+
     String tableId = Tables.getNameToIdMap(state.getInstance()).get(dstTableName);
     log.debug("copied " + srcTableName + " to " + dstTableName + " (id - " + tableId + "
)");
-    
+
     tables.add(dstTableName);
-    
+
     state.getConnector().tableOperations().delete(srcTableName);
     log.debug("dropped " + srcTableName);
-    
+
     nextId++;
     state.set("nextId", Integer.valueOf(nextId));
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/d3d6986e/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CreateTable.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CreateTable.java
b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CreateTable.java
index 5f37913..3bcd0eb 100644
--- a/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CreateTable.java
+++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/multitable/CreateTable.java
@@ -18,23 +18,36 @@ package org.apache.accumulo.test.randomwalk.multitable;
 
 import java.util.ArrayList;
 import java.util.Properties;
+import java.util.TreeSet;
 
 import org.apache.accumulo.core.client.Connector;
 import org.apache.accumulo.core.client.TableExistsException;
 import org.apache.accumulo.core.client.impl.Tables;
 import org.apache.accumulo.test.randomwalk.State;
 import org.apache.accumulo.test.randomwalk.Test;
+import org.apache.hadoop.io.Text;
 
 public class CreateTable extends Test {
-  
+
+  private final TreeSet<Text> splits;
+
+  public CreateTable() {
+    splits = new TreeSet<Text>();
+    for (int i = 1; i < 10; i++) {
+      splits.add(new Text(Integer.toString(i)));
+    }
+  }
+
   @Override
   public void visit(State state, Properties props) throws Exception {
     Connector conn = state.getConnector();
-    
+
     int nextId = ((Integer) state.get("nextId")).intValue();
     String tableName = String.format("%s_%d", state.getString("tableNamePrefix"), nextId);
     try {
       conn.tableOperations().create(tableName);
+      // Add some splits to make the server's life easier
+      conn.tableOperations().addSplits(tableName, splits);
       String tableId = Tables.getNameToIdMap(state.getInstance()).get(tableName);
       log.debug("created " + tableName + " (id:" + tableId + ")");
       @SuppressWarnings("unchecked")
@@ -43,7 +56,7 @@ public class CreateTable extends Test {
     } catch (TableExistsException e) {
       log.warn("Failed to create " + tableName + " as it already exists");
     }
-    
+
     nextId++;
     state.set("nextId", Integer.valueOf(nextId));
   }


Mime
View raw message