HBASE-2556 Add convenience method to HBaseAdmin to get a collection of HRegionInfo objects for each table; fix some formatting

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1130322 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2011-06-01 22:10:15 +00:00
parent ac8a57e93b
commit f765254568
2 changed files with 14 additions and 19 deletions

View File

@ -1249,20 +1249,18 @@ public class HBaseAdmin implements Abortable, Closeable {
* @return Ordered list of {@link HRegionInfo}. *
* @throws IOException
*/
public List<HRegionInfo> getTableRegions(final byte[] tableName) throws IOException
{
CatalogTracker ct = getCatalogTracker();
List<HRegionInfo> Regions;
try {
Regions = MetaReader.getTableRegions(ct, tableName, true);
} finally {
cleanupCatalogTracker(ct);
}
return Regions;
public List<HRegionInfo> getTableRegions(final byte[] tableName)
throws IOException {
CatalogTracker ct = getCatalogTracker();
List<HRegionInfo> Regions;
try {
Regions = MetaReader.getTableRegions(ct, tableName, true);
} finally {
cleanupCatalogTracker(ct);
}
return Regions;
}
public void close() throws IOException {
if (this.connection != null) {
this.connection.close();

View File

@ -100,7 +100,6 @@ public class TestThriftServer extends HBaseClusterTestCase {
handler.deleteTable(tableAname);
}
/**
* Tests adding a series of Mutations and BatchMutations, including a
* delete mutation. Also tests data retrieval, and getting back multiple
@ -311,7 +310,6 @@ public class TestThriftServer extends HBaseClusterTestCase {
handler.disableTable(tableAname);
handler.deleteTable(tableAname);
}
/**
* For HBASE-2556
@ -321,16 +319,15 @@ public class TestThriftServer extends HBaseClusterTestCase {
*/
public void doTestGetTableRegions() throws Exception {
ThriftServer.HBaseHandler handler = new ThriftServer.HBaseHandler(this.conf);
handler.createTable(tableAname, getColumnDescriptors());
int RegionCount = handler.getTableRegions(tableAname).size();
int regionCount = handler.getTableRegions(tableAname).size();
assertEquals("empty table should have only 1 region, " +
"but found " + RegionCount, RegionCount, 1);
"but found " + regionCount, regionCount, 1);
handler.disableTable(tableAname);
handler.deleteTable(tableAname);
RegionCount = handler.getTableRegions(tableAname).size();
regionCount = handler.getTableRegions(tableAname).size();
assertEquals("non-existing table should have 0 region, " +
"but found " + RegionCount, RegionCount, 0);
"but found " + regionCount, regionCount, 0);
}
/**