hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r572826 - in /lucene/hadoop/trunk/src/contrib/hbase: CHANGES.txt src/java/org/apache/hadoop/hbase/HConnectionManager.java src/test/org/apache/hadoop/hbase/TestListTables.java
Date Tue, 04 Sep 2007 22:26:36 GMT
Author: jimk
Date: Tue Sep  4 15:26:02 2007
New Revision: 572826

URL: http://svn.apache.org/viewvc?rev=572826&view=rev
Log:
HADOOP-1832 listTables() returns duplicate tables

Added:
    lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestListTables.java
Modified:
    lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConnectionManager.java

Modified: lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt?rev=572826&r1=572825&r2=572826&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt Tue Sep  4 15:26:02 2007
@@ -29,6 +29,7 @@
     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

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConnectionManager.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConnectionManager.java?rev=572826&r1=572825&r2=572826&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConnectionManager.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HConnectionManager.java
Tue Sep  4 15:26:02 2007
@@ -247,7 +247,6 @@
               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 @@
             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);
 

Added: lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestListTables.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestListTables.java?rev=572826&view=auto
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestListTables.java
(added)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/test/org/apache/hadoop/hbase/TestListTables.java
Tue Sep  4 15:26:02 2007
@@ -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]));
+    }
+  }
+}



Mime
View raw message