Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9133117BD4 for ; Mon, 27 Oct 2014 23:52:50 +0000 (UTC) Received: (qmail 17986 invoked by uid 500); 27 Oct 2014 23:52:50 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 17948 invoked by uid 500); 27 Oct 2014 23:52:50 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 17932 invoked by uid 99); 27 Oct 2014 23:52:50 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 Oct 2014 23:52:50 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 031C6984F66; Mon, 27 Oct 2014 23:52:50 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: elserj@apache.org To: commits@accumulo.apache.org Date: Mon, 27 Oct 2014 23:52:50 -0000 Message-Id: <782687187f714e489993202f6a148567@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/6] git commit: ACCUMULO-3271 Add splits to a table after it is created in MultiNode module. 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 Authored: Mon Oct 27 19:35:01 2014 -0400 Committer: Josh Elser 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 splits; + + public CopyTable() { + splits = new TreeSet(); + 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 tables = (ArrayList) 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 splits; + + public CreateTable() { + splits = new TreeSet(); + 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)); }