HADOOP-1832 listTables() returns duplicate tables
git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@572826 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
844e56e704
commit
49d4f333f4
|
@ -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
|
||||
|
|
|
@ -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<Writable, Writable> 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);
|
||||
|
||||
|
|
|
@ -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<HTableDescriptor> result =
|
||||
new HashSet<HTableDescriptor>(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]));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue