diff --git a/CHANGES.txt b/CHANGES.txt index 33b96792853..720651bf3ec 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -29,6 +29,7 @@ Trunk (unreleased changes) HADOOP-1800 output should default utf8 encoding HADOOP-1814 TestCleanRegionServerExit fails too often on Hudson HADOOP-1821 Replace all String.getBytes() with String.getBytes("UTF-8") + HADOOP-1832 listTables() returns duplicate tables IMPROVEMENTS HADOOP-1737 Make HColumnDescriptor data publically members settable diff --git a/src/java/org/apache/hadoop/hbase/HConnectionManager.java b/src/java/org/apache/hadoop/hbase/HConnectionManager.java index cab6ed260a3..3dd1a01442f 100644 --- a/src/java/org/apache/hadoop/hbase/HConnectionManager.java +++ b/src/java/org/apache/hadoop/hbase/HConnectionManager.java @@ -247,7 +247,6 @@ public class HConnectionManager implements HConstants { COLUMN_FAMILY_ARRAY, EMPTY_START_ROW, System.currentTimeMillis(), null); - HRegionInfo info = new HRegionInfo(); while (true) { MapWritable values = server.next(scannerId); if (values == null || values.size() == 0) { @@ -256,6 +255,7 @@ public class HConnectionManager implements HConstants { for (Map.Entry e: values.entrySet()) { HStoreKey key = (HStoreKey) e.getKey(); if (key.getColumn().equals(COL_REGIONINFO)) { + HRegionInfo info = new HRegionInfo(); info = (HRegionInfo) Writables.getWritable( ((ImmutableBytesWritable) e.getValue()).get(), info); diff --git a/src/test/org/apache/hadoop/hbase/TestListTables.java b/src/test/org/apache/hadoop/hbase/TestListTables.java new file mode 100644 index 00000000000..5cab2b300f5 --- /dev/null +++ b/src/test/org/apache/hadoop/hbase/TestListTables.java @@ -0,0 +1,73 @@ +/** + * Copyright 2007 The Apache Software Foundation + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase; + +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; + +/** + * Tests the listTables client API + */ +public class TestListTables extends HBaseClusterTestCase { + HBaseAdmin admin = null; + + private static final HTableDescriptor[] tables = { + new HTableDescriptor("table1"), + new HTableDescriptor("table2"), + new HTableDescriptor("table3") + }; + + /** constructor */ + public TestListTables() { + super(); + } + + /** {@inheritDoc} */ + @Override + public void setUp() throws Exception { + super.setUp(); + + admin = new HBaseAdmin(conf); + + HColumnDescriptor family = + new HColumnDescriptor(HConstants.COLUMN_FAMILY_STR); + + for (int i = 0; i < tables.length; i++) { + tables[i].addFamily(family); + admin.createTable(tables[i]); + } + } + + /** + * the test + * @throws IOException + */ + public void testListTables() throws IOException { + HashSet result = + new HashSet(Arrays.asList(admin.listTables())); + + int size = result.size(); + assertEquals(tables.length, size); + for (int i = 0; i < tables.length && i < size; i++) { + assertTrue(result.contains(tables[i])); + } + } +}