hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ssrungar...@apache.org
Subject [1/2] hbase git commit: HBASE-13764 Backport HBASE-7782 (HBaseTestingUtility.truncateTable() not acting like CLI) to branch-1.x
Date Thu, 04 Jun 2015 14:04:51 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.0 0214c125e -> 9046b37ee


HBASE-13764 Backport HBASE-7782 (HBaseTestingUtility.truncateTable() not acting like CLI)
to branch-1.x

Signed-off-by: Srikanth Srungarapu <ssrungarapu@cloudera.com>


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

Branch: refs/heads/branch-1.0
Commit: e1d177cb8050fa2f3fce9319b4f6b8b04cd438ec
Parents: 0214c12
Author: Ashish Singhi <ashish.singhi@huawei.com>
Authored: Wed May 27 15:30:00 2015 +0530
Committer: Srikanth Srungarapu <ssrungarapu@cloudera.com>
Committed: Tue Jun 2 23:24:40 2015 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/HBaseTestingUtility.java       | 64 ++++++++++++++++++--
 .../hadoop/hbase/mapreduce/TestRowCounter.java  |  2 +-
 ...estReplicationChangingPeerRegionservers.java |  4 +-
 .../replication/TestReplicationSmallTests.java  |  4 +-
 .../regionserver/TestReplicationSink.java       |  4 +-
 5 files changed, 66 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/e1d177cb/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
index a95faf1..1e9f782 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
@@ -1804,22 +1804,24 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility
{
   // ==========================================================================
 
   /**
-   * Provide an existing table name to truncate
+   * Provide an existing table name to truncate.
+   * Scans the table and issues a delete for each row read.
    * @param tableName existing table
    * @return HTable to that new table
    * @throws IOException
    */
-  public HTable truncateTable(byte[] tableName) throws IOException {
-    return truncateTable(TableName.valueOf(tableName));
+  public HTable deleteTableData(byte[] tableName) throws IOException {
+    return deleteTableData(TableName.valueOf(tableName));
   }
 
   /**
-   * Provide an existing table name to truncate
+   * Provide an existing table name to truncate.
+   * Scans the table and issues a delete for each row read.
    * @param tableName existing table
    * @return HTable to that new table
    * @throws IOException
    */
-  public HTable truncateTable(TableName tableName) throws IOException {
+  public HTable deleteTableData(TableName tableName) throws IOException {
     HTable table = new HTable(getConfiguration(), tableName);
     Scan scan = new Scan();
     ResultScanner resScan = table.getScanner(scan);
@@ -1833,6 +1835,58 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility
{
   }
 
   /**
+   * Truncate a table using the admin command.
+   * Effectively disables, deletes, and recreates the table.
+   * @param tableName table which must exist.
+   * @param preserveRegions keep the existing split points
+   * @return HTable for the new table
+   */
+  public HTable truncateTable(final TableName tableName, final boolean preserveRegions)
+      throws IOException {
+    Admin admin = getHBaseAdmin();
+    admin.truncateTable(tableName, preserveRegions);
+    return new HTable(getConfiguration(), tableName);
+  }
+
+  /**
+   * Truncate a table using the admin command.
+   * Effectively disables, deletes, and recreates the table.
+   * For previous behavior of issuing row deletes, see
+   * deleteTableData.
+   * Expressly does not preserve regions of existing table.
+   * @param tableName table which must exist.
+   * @return HTable for the new table
+   */
+  public HTable truncateTable(final TableName tableName) throws IOException {
+    return truncateTable(tableName, false);
+  }
+
+  /**
+   * Truncate a table using the admin command.
+   * Effectively disables, deletes, and recreates the table.
+   * @param tableName table which must exist.
+   * @param preserveRegions keep the existing split points
+   * @return HTable for the new table
+   */
+  public HTable truncateTable(final byte[] tableName, final boolean preserveRegions)
+      throws IOException {
+    return truncateTable(TableName.valueOf(tableName), preserveRegions);
+  }
+
+  /**
+   * Truncate a table using the admin command.
+   * Effectively disables, deletes, and recreates the table.
+   * For previous behavior of issuing row deletes, see
+   * deleteTableData.
+   * Expressly does not preserve regions of existing table.
+   * @param tableName table which must exist.
+   * @return HTable for the new table
+   */
+  public HTable truncateTable(final byte[] tableName) throws IOException {
+    return truncateTable(tableName, false);
+  }
+
+  /**
    * Load table with rows from 'aaa' to 'zzz'.
    * @param t Table
    * @param f Family

http://git-wip-us.apache.org/repos/asf/hbase/blob/e1d177cb/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
index 53813d9..84c38ce 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestRowCounter.java
@@ -161,7 +161,7 @@ public class TestRowCounter {
     long ts;
 
     // clean up content of TABLE_NAME
-    HTable table = TEST_UTIL.truncateTable(TableName.valueOf(TABLE_NAME));
+    HTable table = TEST_UTIL.deleteTableData(TableName.valueOf(TABLE_NAME));
     ts = System.currentTimeMillis();
     put1.add(family, col1, ts, Bytes.toBytes("val1"));
     table.put(put1);

http://git-wip-us.apache.org/repos/asf/hbase/blob/e1d177cb/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationChangingPeerRegionservers.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationChangingPeerRegionservers.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationChangingPeerRegionservers.java
index d858321..5397c6c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationChangingPeerRegionservers.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationChangingPeerRegionservers.java
@@ -58,9 +58,9 @@ public class TestReplicationChangingPeerRegionservers extends TestReplicationBas
                           utility1.getHBaseCluster().getRegionServerThreads()) {
       utility1.getHBaseAdmin().rollWALWriter(r.getRegionServer().getServerName());
     }
-    utility1.truncateTable(tableName);
+    utility1.deleteTableData(tableName);
     // truncating the table will send one Delete per row to the slave cluster
-    // in an async fashion, which is why we cannot just call truncateTable on
+    // in an async fashion, which is why we cannot just call deleteTableData on
     // utility2 since late writes could make it to the slave in some way.
     // Instead, we truncate the first table and wait for all the Deletes to
     // make it to the slave.

http://git-wip-us.apache.org/repos/asf/hbase/blob/e1d177cb/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
index d8d735f..06f78e3 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java
@@ -79,9 +79,9 @@ public class TestReplicationSmallTests extends TestReplicationBase {
         utility1.getHBaseCluster().getRegionServerThreads()) {
       utility1.getHBaseAdmin().rollWALWriter(r.getRegionServer().getServerName());
     }
-    utility1.truncateTable(tableName);
+    utility1.deleteTableData(tableName);
     // truncating the table will send one Delete per row to the slave cluster
-    // in an async fashion, which is why we cannot just call truncateTable on
+    // in an async fashion, which is why we cannot just call deleteTableData on
     // utility2 since late writes could make it to the slave in some way.
     // Instead, we truncate the first table and wait for all the Deletes to
     // make it to the slave.

http://git-wip-us.apache.org/repos/asf/hbase/blob/e1d177cb/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSink.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSink.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSink.java
index 7efb4e3..db58ccb 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSink.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSink.java
@@ -118,8 +118,8 @@ public class TestReplicationSink {
    */
   @Before
   public void setUp() throws Exception {
-    table1 = TEST_UTIL.truncateTable(TABLE_NAME1);
-    table2 = TEST_UTIL.truncateTable(TABLE_NAME2);
+    table1 = TEST_UTIL.deleteTableData(TABLE_NAME1);
+    table2 = TEST_UTIL.deleteTableData(TABLE_NAME2);
   }
 
   /**


Mime
View raw message