From de2e8d5028915112545a86b450f03484663f119c Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Tue, 29 Jan 2008 20:06:19 +0000 Subject: [PATCH] HADOOP-2631 2443 breaks HTable.getStartKeys when there is more than one table or table you are enumerating isn't the first table git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk/src/contrib/hbase@616505 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 ++ src/java/org/apache/hadoop/hbase/HTable.java | 16 +++++++++------- .../apache/hadoop/hbase/MultiRegionTable.java | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 125871abc59..43fbf9e6892 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -155,6 +155,8 @@ Trunk (unreleased changes) HADOOP-2718 Copy Constructor HBaseConfiguration(Configuration) will override hbase configurations if argumant is not an instance of HBaseConfiguration. + HADOOP-2631 2443 breaks HTable.getStartKeys when there is more than one + table or table you are enumerating isn't the first table IMPROVEMENTS HADOOP-2401 Add convenience put method that takes writable diff --git a/src/java/org/apache/hadoop/hbase/HTable.java b/src/java/org/apache/hadoop/hbase/HTable.java index ed18317d6ee..3933fb0f66c 100644 --- a/src/java/org/apache/hadoop/hbase/HTable.java +++ b/src/java/org/apache/hadoop/hbase/HTable.java @@ -197,7 +197,8 @@ public class HTable implements HConstants { Text startRow = new Text(tableName.toString() + ",,999999999999999"); HRegionLocation metaLocation = null; - + HRegionInterface server; + // scan over the each meta region do { try{ @@ -206,13 +207,13 @@ public class HTable implements HConstants { connection.locateRegion(META_TABLE_NAME, startRow); // connect to the server hosting the .META. region - HRegionInterface server = + server = connection.getHRegionConnection(metaLocation.getServerAddress()); // open a scanner over the meta region scannerId = server.openScanner( metaLocation.getRegionInfo().getRegionName(), - COLUMN_FAMILY_ARRAY, EMPTY_START_ROW, LATEST_TIMESTAMP, + COLUMN_FAMILY_ARRAY, tableName, LATEST_TIMESTAMP, null); // iterate through the scanner, accumulating unique table names @@ -233,19 +234,20 @@ public class HTable implements HConstants { } if (info.isOffline()) { - LOG.debug("Region " + info + " was offline!"); - break; + continue SCANNER_LOOP; } if (info.isSplit()) { - LOG.debug("Region " + info + " was split!"); - break; + continue SCANNER_LOOP; } keyList.add(info.getStartKey()); } } } + + // close that remote scanner + server.close(scannerId); // advance the startRow to the end key of the current region startRow = metaLocation.getRegionInfo().getEndKey(); diff --git a/src/test/org/apache/hadoop/hbase/MultiRegionTable.java b/src/test/org/apache/hadoop/hbase/MultiRegionTable.java index f9972d382a3..18c9dad8030 100644 --- a/src/test/org/apache/hadoop/hbase/MultiRegionTable.java +++ b/src/test/org/apache/hadoop/hbase/MultiRegionTable.java @@ -311,7 +311,7 @@ public class MultiRegionTable extends HBaseTestCase { * @param r * @throws IOException */ - private static void compact(final MiniHBaseCluster cluster, + protected static void compact(final MiniHBaseCluster cluster, final HRegionInfo r) throws IOException { if (r == null) {